# ElasticSearch - Is Parent Child relationship the best approach?

**URL:** <https://discuss.elastic.co/t/elasticsearch-is-parent-child-relationship-the-best-approach/124225>\
**Category:** Elasticsearch\
**Created:** [March 16, 2018, 7:29am UTC](https://discuss.elastic.co/t/elasticsearch-is-parent-child-relationship-the-best-approach/124225 "2018-03-16T07:29:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vignesh\_Kalai](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vignesh_kalai/32/18864_2.png) [@Vignesh\_Kalai](https://discuss.elastic.co/u/Vignesh_Kalai)\
**Post date:** [March 16, 2018, 7:29am UTC](https://discuss.elastic.co/t/elasticsearch-is-parent-child-relationship-the-best-approach/124225/1 "2018-03-16T07:29:02Z")

</div>

down vote  
favorite

Problem:

I have two types of repositories one is document and another one pages. There is a relationship between document and pages. You can think of them as one document(book) with 1 or more pages. Practically I may need to query pages from a document which matches certain criteria and vice versa. So what I am saying is I may some time query certain pages if not all from pages where the document matches.

Currently, I have created a Parent-Child relation in the Parent I have indexed the documents and in Child, I have indexed the pages with reference to the document.

But we have performance issues in our setup, the search and index queries are becoming very slow as the documents increases. I also found out that using Parent-Child relationship is not recommended as it is time-consuming for the elasticsearch site.

Is there any other Data modelling that I could use for this problem.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 16, 2018, 7:51am UTC](https://discuss.elastic.co/t/elasticsearch-is-parent-child-relationship-the-best-approach/124225/2 "2018-03-16T07:51:44Z")

</div>

> Is there any other Data modelling that I could use for this problem.

Yes. Index in the page object all the informations you have in document.  
If I put that in another way: do join at index time and not search time.

---

<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:** [April 13, 2018, 7:51am UTC](https://discuss.elastic.co/t/elasticsearch-is-parent-child-relationship-the-best-approach/124225/3 "2018-04-13T07:51:55Z")

</div>

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