# Im trying to understand child/parent/grandparent

**URL:** <https://discuss.elastic.co/t/im-trying-to-understand-child-parent-grandparent/67224>\
**Category:** Elasticsearch\
**Created:** [November 25, 2016, 10:55pm UTC](https://discuss.elastic.co/t/im-trying-to-understand-child-parent-grandparent/67224 "2016-11-25T22:55:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![teebu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/teebu/32/10119_2.png) [@teebu](https://discuss.elastic.co/u/teebu)\
**Post date:** [November 25, 2016, 10:55pm UTC](https://discuss.elastic.co/t/im-trying-to-understand-child-parent-grandparent/67224/1 "2016-11-25T22:55:58Z")

</div>

im trying to understand child/parent/grandparent, the doc says if you add a child of a parent, it is likely not to be created on the same shard as the grandparent. why?

[https://www.elastic.co/guide/en/elasticsearch/guide/current/grandparents.html#grandparents](https://www.elastic.co/guide/en/elasticsearch/guide/current/grandparents.html#grandparents)

"document was routed to a shard by its own parent ID—uk. It is very likely that the grandchild would end up on a different shard from its parent and grandparent"

If the child and parent are on the same shard, wouldn't the child of that child get put on the same shard?

---

<div class="post-metadata">

**Author:** ![teebu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/teebu/32/10119_2.png) [@teebu](https://discuss.elastic.co/u/teebu)\
**Post date:** [November 26, 2016, 1:22am UTC](https://discuss.elastic.co/t/im-trying-to-understand-child-parent-grandparent/67224/3 "2016-11-26T01:22:42Z")

</div>

I think I understand why you need routing, because the value you pass for \_parent is different and it treats it like a string, not an actual lookup to the parent's shard.

`shard_num = hash(_routing) % num_primary_shards`

\_parent = \_routing if \_routing is not set (its just a string, nothing more)

---

<div class="post-metadata">

**Author:** ![teebu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/teebu/32/10119_2.png) [@teebu](https://discuss.elastic.co/u/teebu)\
**Post date:** [November 27, 2016, 2:06am UTC](https://discuss.elastic.co/t/im-trying-to-understand-child-parent-grandparent/67224/4 "2016-11-27T02:06:12Z")

</div>

I need some advice, maybe someone has good strategies for child/parent/grandparent routing number? My child docs don't have a relationship with the grandparent to pull a routing number.

---

<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:** [December 25, 2016, 2:06am UTC](https://discuss.elastic.co/t/im-trying-to-understand-child-parent-grandparent/67224/5 "2016-12-25T02:06:16Z")

</div>

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