최근에 Java의 ElasticSearch 인덱싱에서이 문제가 발생했습니다. serialized json 바이트 배열에서 ElasticSearch에 레코드를 쓸 때 필드 중 하나가 없거나 삭제됩니다.ElasticSearch는 Java로 인덱싱 할 때 필드를 삭제합니다.
꽤 인쇄 byte[] content
예 :
{
"created_at": 1468390585000,
"name": "Lucy",
"id": 123,
"message": "Hi how are you",
"thread_id": 456,
"user_id": 789
}
자바 인덱스 호 : 인덱싱에서
IndexRequest indexRequest = new IndexRequest(INDEX, TYPE, data.getId().toString())
.source(content)
.versionType(VersionType.EXTERNAL)
.version(data.getCreatedAt().getTime());
는, 모든 필드가 name
제외 결과에 존재한다 :
GET /my_index/post/123
{
"_index": "my_index",
"_type": "post",
"_id": "123",
"_version": 1468390585000,
"found": true,
"_source": {
"id": 123,
"user_id": 456,
"created_at": 1468390585000,
"message": "Hi how are you",
"thread_id": 789
}
}
name
은 새로 만든 필드입니다.
{
"my_index":{
"mappings":{
"post":{
"properties":{
"created_at":{
"type":"long"
},
"name":{
"type":"string"
},
"id":{
"type":"long"
},
"message":{
"type":"string",
"analyzer":"english_text"
},
"thread_id":{
"type":"long"
},
"user_id":{
"type":"long"
}
}
}
}
}
}
기타 필드는 post
유형의 생성으로 작성되었습니다.
Java API에서 데이터 쓰기/색인 생성에 몇 가지 필터링이 있다고 생각됩니다. 나는 PUT
명령 줄에서 동일한 json을 볼 수 있으며 결과에 name
이 포함되어 있습니다. Java API 만 필드를 삭제하는 것 같습니다. 그러나 나는 확실하지 않다.
아이디어가 있으면 알려 주시면 감사하겠습니다.