# \[ Parent / Child \] Search on child but facet on parents

**URL:** https://discuss.elastic.co/t/parent-child-search-on-child-but-facet-on-parents/15828
**Category:** Elasticsearch
**Created:** [February 16, 2014, 12:01pm UTC](https://discuss.elastic.co/t/parent-child-search-on-child-but-facet-on-parents/15828 "2014-02-16T12:01:00Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Tchinkatchuk](https://avatars.discourse-cdn.com/v4/letter/t/958977/32.png) [@Tchinkatchuk](https://discuss.elastic.co/u/Tchinkatchuk)
#### Post date: [February 16, 2014, 12:01pm UTC](https://discuss.elastic.co/t/parent-child-search-on-child-but-facet-on-parents/15828/1 "2014-02-16T12:01:00Z")

</div>

Hi all,

I have 2 types of documents ( categories & products ).

Categories could have parent (other categories) so it is a kind of nested  
tree.  
Products have a parent (categories)

I am doing search on products terms. But I want to have classifications  
facets for those results (ideally as a nested tree).

I have no clue of the solution. Could anyone telle me if this is possible ?

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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/2008a14f-d127-4791-9653-1be316d492d2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2008a14f-d127-4791-9653-1be316d492d2%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)
#### Post date: [February 20, 2014, 9:03am UTC](https://discuss.elastic.co/t/parent-child-search-on-child-but-facet-on-parents/15828/2 "2014-02-20T09:03:54Z")

</div>

Hey,

not too sure, what you are after with your classification, but you could  
execute an aggregation with a has\_child filter, which returns the product  
category of a certain product.  
However I am not sure, if this is the right approach, as in most systems a  
product can have more than one category I guess (and you can only define  
one parent). Maybe you want to put your category ids into an array of the  
product and call aggregations on that array to get category statistics, but  
this is highly dependent on your use-case.

--Alex

On Sun, Feb 16, 2014 at 1:01 PM, Georges@Bibtol [sg@quable.fr](mailto:sg@quable.fr) wrote:

> Hi all,
> 
> I have 2 types of documents ( categories & products ).
> 
> Categories could have parent (other categories) so it is a kind of nested  
> tree.  
> Products have a parent (categories)
> 
> I am doing search on products terms. But I want to have classifications  
> facets for those results (ideally as a nested tree).
> 
> I have no clue of the solution. Could anyone telle me if this is possible ?
> 
> 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).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/2008a14f-d127-4791-9653-1be316d492d2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/2008a14f-d127-4791-9653-1be316d492d2%40googlegroups.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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9f-W9ycBe%3Db-jfuQNyi61YOn4S8mRmwT-GruF9-hUELA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM9f-W9ycBe%3Db-jfuQNyi61YOn4S8mRmwT-GruF9-hUELA%40mail.gmail.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, 1:48am UTC](https://discuss.elastic.co/t/parent-child-search-on-child-but-facet-on-parents/15828/3 "2017-07-06T01:48:48Z")

</div>


