Parent-Child in ES 6.0

Hi,

I am using ElasticSearch 5.6.10 and TransportClient for JAVA. I want to migrate it to ES 6.3.

To add any child documents, I am using the below code:
bulkProcessor.add((new IndexRequest(indexName, typeName)).source(data,XContentType.JSON).
parent(dmcId));

But this is possible when we have multiple mappings. And in ES 6.3, we are having single mapping type.

So can you help me with modifying in above code so as to add documents in ES 6.3.

Thank You.

Regards,
Dibyakanta

See https://www.elastic.co/guide/en/elasticsearch/reference/7.0/parent-join.html

You need to use the join datatype within the same type.

--Alex

Thanks for the help.

I'll add join in my mapping file. As you can see below the way how a child document gets added.

PUT my_index/_doc/3?routing=1&refresh
{
"text": "This is an answer",
"my_join_field":
{
"name": "answer",
"parent": "1"
}
}

But how the documents will be added through Java(changes in the above Java code). Because while adding child documents, we have to add name, which is the child type and the parent.

Thank you.

Regards,
Dibyakanta

make sure that the type is the same for both documents, if you use _doc you will be compatible with 7.0 as well.

Thanks for the help.

But still I am not sure about the Java Code changes.

Thank You.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.