# Nested facet filters

**URL:** <https://discuss.elastic.co/t/nested-facet-filters/5339>\
**Category:** Elasticsearch\
**Created:** [September 9, 2011, 3:50pm UTC](https://discuss.elastic.co/t/nested-facet-filters/5339 "2011-09-09T15:50:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Wojciech\_Durczynski](https://avatars.discourse-cdn.com/v4/letter/w/fbc32d/32.png) [@Wojciech\_Durczynski](https://discuss.elastic.co/u/Wojciech_Durczynski)\
**Post date:** [September 9, 2011, 3:50pm UTC](https://discuss.elastic.co/t/nested-facet-filters/5339/1 "2011-09-09T15:50:15Z")

</div>

Hello Shay.  
I have some problems with facets on nested documents.  
Let's say my documents have following structure (contain name and list of  
specifications, and each specification contains name and list of  
characteristics, specifications have "nested" mapping):  
{  
"name":"off8",  
"specifications":[{  
"name":"1",  
"characteristics":[{  
"color":"blue"  
},{  
"size":"small"  
},{  
"color":"blue"  
}]  
},{  
"name":"5",  
"characteristics":[{  
"color":"blue"  
}]  
}]  
}

I can facet on colors in root context (how many documents have particular  
color):  
termsFacet("color").field("specifications.characteristics.color")

Also I can easily facet on names of specifications that contain color blue:  
termsFacet("blue  
specs").field("specifications.name").nested("specifications").facetFilter(  
termFilter("specifications.characteristics.color", "blue")  
)

But I cannot add in previous example:

1. filter on root document, something like:  
termsFacet("blue  
specs").field("specifications.name").nested("specifications").facetFilter(  
andFilter(termFilter("specifications.characteristics.color",  
"blue"), prefixFilter("name", "off"))  
)
2. global scope to ignore query and filters

Is it possible? Maybe facetFilters set on nested facet should have their own  
scopes?

Regards  
Wojciech Durczyński

---

<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:54am UTC](https://discuss.elastic.co/t/nested-facet-filters/5339/2 "2017-07-06T03:54:56Z")

</div>


