# Getting entire hierarchy in parent child type

**URL:** <https://discuss.elastic.co/t/getting-entire-hierarchy-in-parent-child-type/12065>\
**Category:** Elasticsearch\
**Created:** [May 22, 2013, 8:07am UTC](https://discuss.elastic.co/t/getting-entire-hierarchy-in-parent-child-type/12065 "2013-05-22T08:07:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chetana](https://avatars.discourse-cdn.com/v4/letter/c/dbc845/32.png) [@Chetana](https://discuss.elastic.co/u/Chetana)\
**Post date:** [May 22, 2013, 8:07am UTC](https://discuss.elastic.co/t/getting-entire-hierarchy-in-parent-child-type/12065/1 "2013-05-22T08:07:55Z")

</div>

I have a tree like document structure and using parent child mapping. Using  
hasChildQuery and hasParentQuery I can get the immediate parent and  
children. Does elasticsearch support some filter and/or some querybuilder  
combination mechanism for returning entire hierachy i.e. all documents  
occur between matching node (at some level) till root node(docment)\*

Thanks  
\*

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)\
**Post date:** [May 23, 2013, 10:10am UTC](https://discuss.elastic.co/t/getting-entire-hierarchy-in-parent-child-type/12065/2 "2013-05-23T10:10:41Z")

</div>

No - you'd have to add a field to your doc to allow this, eg a path of all  
ancestor IDs: 1/5/10 etc

On 22 May 2013 10:07, Chetana [ambha.career@gmail.com](mailto:ambha.career@gmail.com) wrote:

> I have a tree like document structure and using parent child mapping.  
> Using hasChildQuery and hasParentQuery I can get the immediate parent and  
> children. Does elasticsearch support some filter and/or some querybuilder  
> combination mechanism for returning entire hierachy i.e. all documents  
> occur between matching node (at some level) till root node(docment)\*
> 
> Thanks  
> \*
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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 6, 2017, 2:35am UTC](https://discuss.elastic.co/t/getting-entire-hierarchy-in-parent-child-type/12065/3 "2017-07-06T02:35:10Z")

</div>


