# Facet on child type

**URL:** https://discuss.elastic.co/t/facet-on-child-type/7072
**Category:** Elasticsearch
**Created:** [March 20, 2012, 3:09pm UTC](https://discuss.elastic.co/t/facet-on-child-type/7072 "2012-03-20T15:09:50Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Ridvan\_Gyundogan](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@Ridvan\_Gyundogan](https://discuss.elastic.co/u/Ridvan_Gyundogan)
#### Post date: [March 20, 2012, 3:09pm UTC](https://discuss.elastic.co/t/facet-on-child-type/7072/1 "2012-03-20T15:09:50Z")

</div>

Hi guys,  
first my gist: [https://gist.github.com/2136557](https://gist.github.com/2136557)

I have ParentType and ChildType, the ParentType s defined as "\_parent"  
of ChildType.  
I have ChildType.title field and ParentType.titles field.  
ParentType.titles is array duplicating the ChildType.title.

I want a facet on the title field which I am currently doing on the  
ParentType.titles but now I want to remove this field and define the  
facet on the ChildType.title.

Unfortunately I couldn't do the "scope" property of the facet working

- it is just ignored and the facet is always defined on the  
ParentType. If I define facet on "titles" property it works if I  
define facet on "title" property it doesn't.

Any idea what is wrong with my query?

Somewhere ot the group I found that this should be done with nested  
documents but then I am not able to query directly the ChildType.

Any help is very appreciated.

---

<div class="post-metadata">

### Author: ![Ridvan\_Gyundogan](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@Ridvan\_Gyundogan](https://discuss.elastic.co/u/Ridvan_Gyundogan)
#### Post date: [March 21, 2012, 7:05am UTC](https://discuss.elastic.co/t/facet-on-child-type/7072/2 "2012-03-21T07:05:34Z")

</div>

Did someone tried facets on parent-child or nested documents?

On Mar 20, 5:09 pm, Ridvan Gyundogan [ridva...@gmail.com](mailto:ridva...@gmail.com) wrote:

> Hi guys,  
> first my gist:[parent child facet using scope · GitHub](https://gist.github.com/2136557)
> 
> I have ParentType and ChildType, the ParentType s defined as "\_parent"  
> of ChildType.  
> I have ChildType.title field and ParentType.titles field.  
> ParentType.titles is array duplicating the ChildType.title.
> 
> I want a facet on the title field which I am currently doing on the  
> ParentType.titles but now I want to remove this field and define the  
> facet on the ChildType.title.
> 
> Unfortunately I couldn't do the "scope" property of the facet working
> 
> - it is just ignored and the facet is always defined on the  
> ParentType. If I define facet on "titles" property it works if I  
> define facet on "title" property it doesn't.
> 
> Any idea what is wrong with my query?
> 
> Somewhere ot the group I found that this should be done with nested  
> documents but then I am not able to query directly the ChildType.
> 
> Any help is very appreciated.

---

<div class="post-metadata">

### Author: ![Radu\_Gheorghe1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/radu_gheorghe1/32/2688_2.png) [@Radu\_Gheorghe1](https://discuss.elastic.co/u/Radu_Gheorghe1)
#### Post date: [March 24, 2012, 11:54am UTC](https://discuss.elastic.co/t/facet-on-child-type/7072/3 "2012-03-24T11:54:23Z")

</div>

I didn't, but can you post here your query? Maybe we get lucky and  
find out what's wrong with it 🙂

On 21 mar., 09:05, Ridvan Gyundogan [ridva...@gmail.com](mailto:ridva...@gmail.com) wrote:

> Did someone tried facets on parent-child or nested documents?
> 
> On Mar 20, 5:09 pm, Ridvan Gyundogan [ridva...@gmail.com](mailto:ridva...@gmail.com) wrote:
> 
> > Hi guys,  
> > first my gist:[parent child facet using scope · GitHub](https://gist.github.com/2136557)
> 
> > I have ParentType and ChildType, the ParentType s defined as "\_parent"  
> > of ChildType.  
> > I have ChildType.title field and ParentType.titles field.  
> > ParentType.titles is array duplicating the ChildType.title.
> 
> > I want a facet on the title field which I am currently doing on the  
> > ParentType.titles but now I want to remove this field and define the  
> > facet on the ChildType.title.
> 
> > Unfortunately I couldn't do the "scope" property of the facet working
> > 
> > - it is just ignored and the facet is always defined on the  
> > ParentType. If I define facet on "titles" property it works if I  
> > define facet on "title" property it doesn't.
> 
> > Any idea what is wrong with my query?
> 
> > Somewhere ot the group I found that this should be done with nested  
> > documents but then I am not able to query directly the ChildType.
> 
> > Any help is very appreciated.

---

<div class="post-metadata">

### Author: ![Ridvan\_Gyundogan](https://avatars.discourse-cdn.com/v4/letter/r/e495f1/32.png) [@Ridvan\_Gyundogan](https://discuss.elastic.co/u/Ridvan_Gyundogan)
#### Post date: [April 22, 2012, 5:04pm UTC](https://discuss.elastic.co/t/facet-on-child-type/7072/4 "2012-04-22T17:04:07Z")

</div>

Hi Radu,  
the query and the mappings are on the gist link.

On Mar 24, 2:54 pm, Radu Gheorghe [radu0gheor...@gmail.com](mailto:radu0gheor...@gmail.com) wrote:

> I didn't, but can you post here your query? Maybe we get lucky and  
> find out what's wrong with it 🙂
> 
> On 21 mar., 09:05,RidvanGyundogan[ridva...@gmail.com](mailto:ridva...@gmail.com) wrote:
> 
> > Did someone tried facets on parent-child or nested documents?
> 
> > On Mar 20, 5:09 pm,RidvanGyundogan[ridva...@gmail.com](mailto:ridva...@gmail.com) wrote:
> 
> > > Hi guys,  
> > > first my gist:[parent child facet using scope · GitHub](https://gist.github.com/2136557)
> 
> > > I have ParentType and ChildType, the ParentType s defined as "\_parent"  
> > > of ChildType.  
> > > I have ChildType.title field and ParentType.titles field.  
> > > ParentType.titles is array duplicating the ChildType.title.
> 
> > > I want a facet on the title field which I am currently doing on the  
> > > ParentType.titles but now I want to remove this field and define the  
> > > facet on the ChildType.title.
> 
> > > Unfortunately I couldn't do the "scope" property of the facet working
> > > 
> > > - it is just ignored and the facet is always defined on the  
> > > ParentType. If I define facet on "titles" property it works if I  
> > > define facet on "title" property it doesn't.
> 
> > > Any idea what is wrong with my query?
> 
> > > Somewhere ot the group I found that this should be done with nested  
> > > documents but then I am not able to query directly the ChildType.
> 
> > > Any help is very appreciated.

---

<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, 3:31am UTC](https://discuss.elastic.co/t/facet-on-child-type/7072/5 "2017-07-06T03:31:25Z")

</div>


