# I have about 500,000 children for each parent

**URL:** <https://discuss.elastic.co/t/i-have-about-500-000-children-for-each-parent/264215>\
**Category:** Elasticsearch\
**Created:** [February 13, 2021, 11:52am UTC](https://discuss.elastic.co/t/i-have-about-500-000-children-for-each-parent/264215 "2021-02-13T11:52:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbawazir](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@mbawazir](https://discuss.elastic.co/u/mbawazir)\
**Post date:** [February 13, 2021, 11:52am UTC](https://discuss.elastic.co/t/i-have-about-500-000-children-for-each-parent/264215/1 "2021-02-13T11:52:48Z")

</div>

Can I use "Inner Objects" for Managing Relations Inside Elasticsearch when I have about 500,000 children for each parent? or what is the best way to deal with it

---

<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:** [February 13, 2021, 11:57am UTC](https://discuss.elastic.co/t/i-have-about-500-000-children-for-each-parent/264215/2 "2021-02-13T11:57:00Z")

</div>

If you are referring to nested objects I do not think it is a good idea as it would lead to very large documents that potentially would get added to and modified frequently. I would instead recommend looking into denormalizing the data if possible and store the parents data on each child or if the parent might get updated frequently or is very large look at parent-child relationships instead.

---

<div class="post-metadata">

**Author:** ![mbawazir](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@mbawazir](https://discuss.elastic.co/u/mbawazir)\
**Post date:** [February 13, 2021, 1:43pm UTC](https://discuss.elastic.co/t/i-have-about-500-000-children-for-each-parent/264215/3 "2021-02-13T13:43:26Z")

</div>

Many Thanks, Christian\_Dahlqvist for your help.

When I embed the parent in each child, how can I get only parents from documents without duplicate?

---

<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:** [February 13, 2021, 2:13pm UTC](https://discuss.elastic.co/t/i-have-about-500-000-children-for-each-parent/264215/4 "2021-02-13T14:13:17Z")

</div>

You can not, although you could index parents by themselves if you want to just query parents. As you have not specified how you need to query the data it is hard to know which approach may be most suitable.

---

<div class="post-metadata">

**Author:** ![mbawazir](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@mbawazir](https://discuss.elastic.co/u/mbawazir)\
**Post date:** [February 13, 2021, 6:44pm UTC](https://discuss.elastic.co/t/i-have-about-500-000-children-for-each-parent/264215/5 "2021-02-13T18:44:13Z")

</div>

for example when I have two tables  
1- schools (parent)  
2- students (child)  
each school has about 500,000 students, as you mentioned I need to create one index including information student and school in the same document  
example (students index) :  
student ID  
student name,  
student age,  
student level,  
school ID  
school name,  
school address ....

and I need to create another index for schools, so we can get the schools information  
example (schools index) :  
school ID  
school name,  
school address .....

**Knowing that** we don't need to modify the tables frequently because we just need them as an archive

---

<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:** [March 13, 2021, 6:45pm UTC](https://discuss.elastic.co/t/i-have-about-500-000-children-for-each-parent/264215/6 "2021-03-13T18:45:09Z")

</div>

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