# How to get grand parent details also in the response when querying for grandchild documents

**URL:** <https://discuss.elastic.co/t/how-to-get-grand-parent-details-also-in-the-response-when-querying-for-grandchild-documents/141139>\
**Category:** Elasticsearch\
**Created:** [July 23, 2018, 10:25am UTC](https://discuss.elastic.co/t/how-to-get-grand-parent-details-also-in-the-response-when-querying-for-grandchild-documents/141139 "2018-07-23T10:25:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![muthucse](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/muthucse/32/45217_2.png) [@muthucse](https://discuss.elastic.co/u/muthucse)\
**Post date:** [July 23, 2018, 10:25am UTC](https://discuss.elastic.co/t/how-to-get-grand-parent-details-also-in-the-response-when-querying-for-grandchild-documents/141139/1 "2018-07-23T10:25:19Z")

</div>

I have a mapping structure of

parent -\> child -\> grandchild.  
Company -\> brand -\> product  
search filters applied at company and brand level. Sorting applied at product level. How to get company details also as inner hits.

Sample:

POST my\_index/search  
{  
"query": {  
"bool":{  
"must:[  
{  
"has\_parent": "brand",  
"query":{  
"has\_parent":"company",  
"query":{  
"match\_all":{}  
}, "inner\_hits":{}

```
     }

   }

```

]  
}  
}  
"sort": "product.id"  
}  
How to get those details at company level as well by getting product level as a base ?

---

<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:** [August 20, 2018, 10:25am UTC](https://discuss.elastic.co/t/how-to-get-grand-parent-details-also-in-the-response-when-querying-for-grandchild-documents/141139/2 "2018-08-20T10:25:24Z")

</div>

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