'2017/12/13'에 해당되는 글 1건

  1. 2017.12.13 [Elasticsearch] copy_to mapping 예제

[Elasticsearch] copy_to mapping 예제

Elastic/ElasticsearchReferences 2017. 12. 13. 16:31

nested mapping 구조를 가지는 경우 copy_to 에 대한 동작 오류가 몇 건 보고 된게 있어서 코드 보다가 살짝 올려 봅니다.

공식문서는 아래 링크 참고하세요.

https://www.elastic.co/guide/en/elasticsearch/reference/current/copy-to.html


XContentBuilder mapping = jsonBuilder().startObject()
.startObject("type")
.startObject("properties")
.startObject("target")
.field("type", "long")
.field("doc_values", false)
.endObject()
.startObject("n1")
.field("type", "nested")
.startObject("properties")
.startObject("target")
.field("type", "long")
.field("doc_values", false)
.endObject()
.startObject("n2")
.field("type", "nested")
.startObject("properties")
.startObject("target")
.field("type", "long")
.field("doc_values", false)
.endObject()
.startObject("source")
.field("type", "long")
.field("doc_values", false)
.startArray("copy_to")
.value("target") // should go to the root doc
.value("n1.target") // should go to the parent doc
.value("n1.n2.target") // should go to the current doc
.endArray()
.endObject()
.endObject()
.endObject()
.endObject()
.endObject()
.endObject()
.endObject()
.endObject();


: