# Using filters against parent object in nested facet

**URL:** https://discuss.elastic.co/t/using-filters-against-parent-object-in-nested-facet/11151
**Category:** Elasticsearch
**Created:** [March 14, 2013, 9:21am UTC](https://discuss.elastic.co/t/using-filters-against-parent-object-in-nested-facet/11151 "2013-03-14T09:21:14Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Pawel\_Mlynarczyk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pawel_mlynarczyk/32/1568_2.png) [@Pawel\_Mlynarczyk](https://discuss.elastic.co/u/Pawel_Mlynarczyk)
#### Post date: [March 14, 2013, 9:21am UTC](https://discuss.elastic.co/t/using-filters-against-parent-object-in-nested-facet/11151/1 "2013-03-14T09:21:14Z")

</div>

Hello everybody.

I've been working with nested objects and I hit an issue. I can't use a  
filter that applies to a parent object from the nested facet.

Mapping for my structure looks like this:

{  
"mappings" : {  
"Item" : {  
"dynamic" : false,  
"properties" : {  
"categories" : {  
"type" : "nested",  
"properties" : {  
"type" : {  
"type" : "string",  
"index" : "not\_analyzed"  
},  
"name" : {  
"type" : "string",  
"index" : "not\_analyzed"  
}  
}  
},  
"id" : {  
"type" : "string",  
"index" : "not\_analyzed"  
},  
"name" : {  
"type" : "string",  
"index" : "not\_analyzed"  
}  
}  
}  
}  
}

And the query that is in fact working looks like this one:

{  
"query" : {  
"match\_all" : {}  
},  
"facets" : {  
"my\_facet" : {  
"nested" : "categories",  
"terms" : { "field" : "categories.name" },  
"facet\_filter" : {  
"term" : { "categories.type" : "type1" }  
}  
}  
}  
}

But I've been trying to add a additional filter for the nested facet that  
limits the parent objects.  
It would look something like:

{  
"query" : {  
"match\_all" : {}  
},  
"facets" : {  
"my\_facet" : {  
"nested" : "categories",  
"terms" : { "field" : "categories.name" },  
"facet\_filter" : {  
"and" : [  
{ "term" : { "categories.type" : "type1" } },  
{ "prefix" : { "id" : "i" } }  
]  
}  
}  
}  
}

But that prefix filter won't work for the parent object. Is there a way to  
add a filter that applies to a parent object from a nested facet? If no,  
then is there any fine workaround?  
I'm using ES 0.90.0.Beta1.

Thanks in advance.

Paweł

--  
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: [March 14, 2013, 11:26am UTC](https://discuss.elastic.co/t/using-filters-against-parent-object-in-nested-facet/11151/2 "2013-03-14T11:26:25Z")

</div>

> But I've been trying to add a additional filter for the nested facet  
> that limits the parent objects.  
> It would look something like:
> 
> {  
> "query" : {  
> "match\_all" : {}  
> },  
> "facets" : {  
> "my\_facet" : {  
> "nested" : "categories",  
> "terms" : { "field" : "categories.name" },  
> "facet\_filter" : {  
> "and" : [  
> { "term" : { "categories.type" : "type1" } },  
> { "prefix" : { "id" : "i" } }  
> ]  
> }  
> }  
> }  
> }
> 
> But that prefix filter won't work for the parent object. Is there a  
> way to add a filter that applies to a parent object from a nested  
> facet? If no, then is there any fine workaround?  
> I'm using ES 0.90.0.Beta1.

Yeah. This is not currently supported. However, I'm pretty sure it  
could be supported with some major facet refactoring.

Please open an issue for this

ta

clint

--  
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: ![Patryk\_Wasik](https://avatars.discourse-cdn.com/v4/letter/p/e9bcb4/32.png) [@Patryk\_Wasik](https://discuss.elastic.co/u/Patryk_Wasik)
#### Post date: [June 26, 2013, 3:05pm UTC](https://discuss.elastic.co/t/using-filters-against-parent-object-in-nested-facet/11151/3 "2013-06-26T15:05:46Z")

</div>

Are there any plans to support this? Is there any ticket to track? I can't  
find one.

Patryk

W dniu czwartek, 14 marca 2013 12:26:25 UTC+1 użytkownik Clinton Gormley  
napisał:

> > But I've been trying to add a additional filter for the nested facet  
> > that limits the parent objects.  
> > It would look something like:
> > 
> > {  
> > "query" : {  
> > "match\_all" : {}  
> > },  
> > "facets" : {  
> > "my\_facet" : {  
> > "nested" : "categories",  
> > "terms" : { "field" : "categories.name" },  
> > "facet\_filter" : {  
> > "and" : [  
> > { "term" : { "categories.type" : "type1" } },  
> > { "prefix" : { "id" : "i" } }  
> > ]  
> > }  
> > }  
> > }  
> > }
> > 
> > But that prefix filter won't work for the parent object. Is there a  
> > way to add a filter that applies to a parent object from a nested  
> > facet? If no, then is there any fine workaround?  
> > I'm using ES 0.90.0.Beta1.
> 
> Yeah. This is not currently supported. However, I'm pretty sure it  
> could be supported with some major facet refactoring.
> 
> Please open an issue for this
> 
> ta
> 
> clint

--  
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:29am UTC](https://discuss.elastic.co/t/using-filters-against-parent-object-in-nested-facet/11151/4 "2017-07-06T02:29:21Z")

</div>


