# Parent Child - One to Many Relation ship

**URL:** <https://discuss.elastic.co/t/parent-child-one-to-many-relation-ship/26307>\
**Category:** Elasticsearch\
**Created:** [July 26, 2015, 5:02pm UTC](https://discuss.elastic.co/t/parent-child-one-to-many-relation-ship/26307 "2015-07-26T17:02:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sivaprakash\_Shanmuga](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@Sivaprakash\_Shanmuga](https://discuss.elastic.co/u/Sivaprakash_Shanmuga)\
**Post date:** [July 26, 2015, 5:02pm UTC](https://discuss.elastic.co/t/parent-child-one-to-many-relation-ship/26307/1 "2015-07-26T17:02:33Z")

</div>

Hi

I've to persist documents and list of users who likes the document. During search I want retrieve/check whether that particular user has selected that document.

> {"searchDocument": [{ "documentId": 1952, "isFavorite": null}, {"documentId": 1952, "isFavorite": "1"}], "userId": "845632"}

In the above same result (which I would like to achieve) there are 2 documents, userId is the user who makes search request. It is one - many relationship. One user can like multiple documents.

Can Parent - Child model be a right approach to solve this. It would be great if I get list of documents and it's Like Status together in one result. Any reference?

---

<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:** [July 26, 2015, 9:38pm UTC](https://discuss.elastic.co/t/parent-child-one-to-many-relation-ship/26307/2 "2015-07-26T21:38:15Z")

</div>

Yes, you can have the parent as the user and the documents as the child.

---

<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 5, 2017, 11:58pm UTC](https://discuss.elastic.co/t/parent-child-one-to-many-relation-ship/26307/3 "2017-07-05T23:58:55Z")

</div>


