I am using java and Jest (https://github.com/searchbox-io/Jest) as a client for elastic search cluster. Trying to create and index with the below structure in http://localhost:9200/myindex/mytype
{
"doc": {
"_content": "mycontent",
"_name": "mypdf.pdf",
"_content_type": "application/pdf"
}
}
XContentBuilder docObject = jsonBuilder().startObject().field("_content", doc).field("_name", name).field("_content_type", contentType)
.field("title", title).field("author", author).endObject();
index1 = new Index.Builder(docObject).build();
source = jsonBuilder()
.startObject()
.field("doc", docObject.string())
.endObject().string();
Index index = new Index.Builder(source).index(baseIndexName).type(ElasticConstants.BASE_TYPE).build();
But when this gets executed , the source is not passed as a Json and value for the key "doc" is passed as a string literal because of which the index is not getting created . How do I pass nested json objects to the Index.Builder using Jest ?