# Parent/Child functionality

**URL:** <https://discuss.elastic.co/t/parent-child-functionality/2045>\
**Category:** Elasticsearch\
**Created:** [June 5, 2015, 9:14pm UTC](https://discuss.elastic.co/t/parent-child-functionality/2045 "2015-06-05T21:14:25Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![MikeB](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@MikeB](https://discuss.elastic.co/u/MikeB)\
**Post date:** [June 5, 2015, 9:14pm UTC](https://discuss.elastic.co/t/parent-child-functionality/2045/1 "2015-06-05T21:14:25Z")

</div>

I'm trying to get some more information about Parent Child (\_parent) mapping functionality in elasticsearch, I have not been able to find a definitive answer to these questions:

Can parent child mappings be nested to more than two levels?  
Can a document have multiple parents of different types?  
Can a document have multiple children of different types?

It seems like the answer to all these questions is probably "yes" but I don't want to guess, and was hoping to avoid conducting experiments.

Thanks,  
Mike

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [June 5, 2015, 10:49pm UTC](https://discuss.elastic.co/t/parent-child-functionality/2045/2 "2015-06-05T22:49:09Z")

</div>

> [@MikeB](#):
>
> Can parent child mappings be nested to more than two levels?Can a document have multiple parents of different types?Can a document have multiple children of different types?

You can have multiple levels of children, but not multiple parents.

---

<div class="post-metadata">

**Author:** ![MikeB](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@MikeB](https://discuss.elastic.co/u/MikeB)\
**Post date:** [June 8, 2015, 1:13pm UTC](https://discuss.elastic.co/t/parent-child-functionality/2045/3 "2015-06-08T13:13:51Z")

</div>

Hi Mark, thanks for your reply. I wanted to be sure I have this right. So, in a relational schema, a table can have multiple foreign keys, which correspond to multiple parents. So ES doesn't support this concept of multiple "FKs" in a document, it would only allow a single "FK"/\_parent designation?

Thanks,  
Mike

---

<div class="post-metadata">

**Author:** ![mosiddi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mosiddi/32/577_2.png) [@mosiddi](https://discuss.elastic.co/u/mosiddi)\
**Post date:** [June 9, 2015, 12:36pm UTC](https://discuss.elastic.co/t/parent-child-functionality/2045/4 "2015-06-09T12:36:16Z")

</div>

@warkolm - If we have to choose b/w parent-child and nested type where we expect a lot of updates flowing in.  
Do you think nested will be better -

1. Assuming we are ok taking a disk hit, we store \_source and do partial update.
2. Assuming performance of parent-child is not as good as nested.

---

<div class="post-metadata">

**Author:** ![MikeB](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@MikeB](https://discuss.elastic.co/u/MikeB)\
**Post date:** [June 9, 2015, 2:47pm UTC](https://discuss.elastic.co/t/parent-child-functionality/2045/5 "2015-06-09T14:47:40Z")

</div>

I don't understand why a parent/child would be used when nested works. I see \_parent as an approach to use when the parent must be maintained as a separate document, probably because of its other relationships outside any single document to which it is being declared as \_parent

---

<div class="post-metadata">

**Author:** ![MikeB](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@MikeB](https://discuss.elastic.co/u/MikeB)\
**Post date:** [June 9, 2015, 2:56pm UTC](https://discuss.elastic.co/t/parent-child-functionality/2045/6 "2015-06-09T14:56:01Z")

</div>

An example would be an ES implementation of a relational dimensional star design, where each dimension is a parent to a fact, but dimensions can be associated with more than one fact (table)- each dimension would have multiple children, and each fact would have multiple parents.

---

<div class="post-metadata">

**Author:** ![mosiddi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mosiddi/32/577_2.png) [@mosiddi](https://discuss.elastic.co/u/mosiddi)\
**Post date:** [June 9, 2015, 3:49pm UTC](https://discuss.elastic.co/t/parent-child-functionality/2045/7 "2015-06-09T15:49:43Z")

</div>

Situation where u have updates coming, like children getting added. In case parent-child, a child could be easily added independent of parent getting updated while in nested the document will be updated (delete/add) - OR does ES intelligently adds a new nested (child) document w/o touching parent?

---

<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:** [July 6, 2017, 12:08am UTC](https://discuss.elastic.co/t/parent-child-functionality/2045/8 "2017-07-06T00:08:46Z")

</div>


