# Parent-Child in ES 6.0

**URL:** <https://discuss.elastic.co/t/parent-child-in-es-6-0/176234>\
**Category:** Elasticsearch\
**Created:** [April 10, 2019, 1:58pm UTC](https://discuss.elastic.co/t/parent-child-in-es-6-0/176234 "2019-04-10T13:58:59Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dibyakanta](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@Dibyakanta](https://discuss.elastic.co/u/Dibyakanta)\
**Post date:** [April 10, 2019, 1:58pm UTC](https://discuss.elastic.co/t/parent-child-in-es-6-0/176234/1 "2019-04-10T13:58:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 11, 2019, 2:24pm UTC](https://discuss.elastic.co/t/parent-child-in-es-6-0/176234/2 "2019-04-11T14:24:03Z")

</div>

See [https://www.elastic.co/guide/en/elasticsearch/reference/7.0/parent-join.html](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

---

<div class="post-metadata">

**Author:** ![Dibyakanta](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@Dibyakanta](https://discuss.elastic.co/u/Dibyakanta)\
**Post date:** [April 11, 2019, 3:35pm UTC](https://discuss.elastic.co/t/parent-child-in-es-6-0/176234/3 "2019-04-11T15:35:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [April 11, 2019, 3:58pm UTC](https://discuss.elastic.co/t/parent-child-in-es-6-0/176234/4 "2019-04-11T15:58:40Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Dibyakanta](https://avatars.discourse-cdn.com/v4/letter/d/4491bb/32.png) [@Dibyakanta](https://discuss.elastic.co/u/Dibyakanta)\
**Post date:** [April 12, 2019, 9:51am UTC](https://discuss.elastic.co/t/parent-child-in-es-6-0/176234/5 "2019-04-12T09:51:59Z")

</div>

Thanks for the help.

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

Thank You.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [May 10, 2019, 9:52am UTC](https://discuss.elastic.co/t/parent-child-in-es-6-0/176234/6 "2019-05-10T09:52:00Z")

</div>

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