# How to use parent child relationships between types residing in different index in ElasticSearch 6.5

**URL:** https://discuss.elastic.co/t/how-to-use-parent-child-relationships-between-types-residing-in-different-index-in-elasticsearch-6-5/164849
**Category:** Elasticsearch
**Created:** [January 18, 2019, 7:11pm UTC](https://discuss.elastic.co/t/how-to-use-parent-child-relationships-between-types-residing-in-different-index-in-elasticsearch-6-5/164849 "2019-01-18T19:11:32Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![akkash.bansal](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@akkash.bansal](https://discuss.elastic.co/u/akkash.bansal)
#### Post date: [January 18, 2019, 7:11pm UTC](https://discuss.elastic.co/t/how-to-use-parent-child-relationships-between-types-residing-in-different-index-in-elasticsearch-6-5/164849/1 "2019-01-18T19:11:32Z")

</div>

Hi,

I am trying to migrate from ES 5.x to 6.5 and I am stuck at migrating mappings of parent child relationships. Right now in ES 5 I have all the types in one index but the ES6.5 does not support multiple types in same index. So I am thinking to have one type per index. But the problem is I don't know how I can create parent child relationship using new join type when the types exist in two different index. For example 'parent' type exist in 'es\_001' index while 'child' type exist in 'es\_002' index.

Any help in this regard is greatly appreciated.

Regards,  
Akash

---

<div class="post-metadata">

### Author: ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)
#### Post date: [January 19, 2019, 9:57am UTC](https://discuss.elastic.co/t/how-to-use-parent-child-relationships-between-types-residing-in-different-index-in-elasticsearch-6-5/164849/2 "2019-01-19T09:57:55Z")

</div>

Documents within a parent-child hierarchy still need to be located within the same index and shard. As long as the mappings do not conflict, store all types in a single index under the a single type. If you need to be able to filter by type you can add a custom field that contains the type name to support that.

---

<div class="post-metadata">

### Author: ![akkash.bansal](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@akkash.bansal](https://discuss.elastic.co/u/akkash.bansal)
#### Post date: [January 19, 2019, 5:11pm UTC](https://discuss.elastic.co/t/how-to-use-parent-child-relationships-between-types-residing-in-different-index-in-elasticsearch-6-5/164849/3 "2019-01-19T17:11:47Z")

</div>

Thanks Christian. I was able to create parent child relationship in single index as you explained.

I have one more problem with LogStash as to how to populate parent and child. My mapping is something like below :

{  
"mappings": {  
"\_doc": {  
"properties": {  
"my\_join\_field": {  
"type": "join",  
"relations": {  
"parent": "child"  
}  
},  
"parent": {  
"title": { "type": "text" },  
"gender": { "type": "text" },  
"hair\_color": { "type": "text" }  
},  
"child": {  
"title": { "type": "text" },  
"id\_details": {"type": "nested",  
"properties": {  
"id\_title": {"type": "text"},  
"id\_num": {"type": "keyword"}  
}  
}  
}  
}  
}  
}  
}

And I am having difficulty as to how to use filter plugin to index specific type. Because the document type is the "\_doc", I have no way to index the data into specific type for example in above mapping the "parent" and "child" type.

Any help is greatly appreciated.

Regards,  
Akash

---

<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: [February 16, 2019, 5:11pm UTC](https://discuss.elastic.co/t/how-to-use-parent-child-relationships-between-types-residing-in-different-index-in-elasticsearch-6-5/164849/4 "2019-02-16T17:11:48Z")

</div>

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