# Facet\_filters, es 0.16.2

**URL:** <https://discuss.elastic.co/t/facet-filters-es-0-16-2/4752>\
**Category:** Elasticsearch\
**Created:** [July 1, 2011, 9:11pm UTC](https://discuss.elastic.co/t/facet-filters-es-0-16-2/4752 "2011-07-01T21:11:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinny](https://avatars.discourse-cdn.com/v4/letter/v/b9e5f3/32.png) [@vinny](https://discuss.elastic.co/u/vinny)\
**Post date:** [July 1, 2011, 9:11pm UTC](https://discuss.elastic.co/t/facet-filters-es-0-16-2/4752/1 "2011-07-01T21:11:12Z")

</div>

I'm trying to get facet\_filters working and I seem to be stuck. Here  
is my test:

{  
"query":{  
"match\_all":{}  
},  
"facets":{  
"tag":{  
"terms":{  
"field":"file\_stages\_filetype\_result\_extension"  
}  
},  
"facet\_filter":{  
"terms":{  
"file\_stages\_filetype\_result\_extension":["txt",  
"htm"  
]  
}  
}  
}  
}

If I remove the facet\_filter it works fine and shows me all of the  
facet data for that fields. The exception I get is here:  
Failed to execute  
[org.elasticsearch.action.search.SearchRequest@17a8b43]  
org.elasticsearch.search.SearchParseException:  
[96b46884fdddbf5b95a0568d84638da9][1]:  
query[ConstantScore(_:_)],from[-1],size[-1]: Parse Failure [Failed to  
parse source [{"query":{"match\_all":{}},"facets":{"tag":{"terms":  
{"field":"file\_stages\_filetype\_result\_extension"}},"facet\_filter":  
{"terms":{"file\_stages\_filetype\_result\_extension":["txt","htm"]}}}}]]  
at  
org.elasticsearch.search.SearchService.parseSource(SearchService.java:  
473)

I have also tried to get an and filter working with my facet\_filter  
and that doesn't seem to work either. The filters do work in a  
standalone query filter just not with the facet\_filter.

thanks,  
Vinny

---

<div class="post-metadata">

**Author:** ![Hari\_Shankar](https://avatars.discourse-cdn.com/v4/letter/h/ad7895/32.png) [@Hari\_Shankar](https://discuss.elastic.co/u/Hari_Shankar)\
**Post date:** [July 2, 2011, 4:22am UTC](https://discuss.elastic.co/t/facet-filters-es-0-16-2/4752/2 "2011-07-02T04:22:15Z")

</div>

Hi Vinny,

Try this:

{  
"query":{  
"match\_all":{}  
},  
"facets":{  
"tag":{  
"terms":{  
"field":"file\_stages\_filetype\_result\_extension"  
},  
"facet\_filter":{  
"terms":{  
"file\_stages\_filetype\_result\_extension":["txt",  
"htm"  
]  
}  
}  
}  
}  
}

Facet filter is a property of the specific facet so it should come within  
the facet.

Hari

On Sat, Jul 2, 2011 at 2:41 AM, vinny [agnellvj@gmail.com](mailto:agnellvj@gmail.com) wrote:

> I'm trying to get facet\_filters working and I seem to be stuck. Here  
> is my test:
> 
> {  
> "query":{  
> "match\_all":{}  
> },  
> "facets":{  
> "tag":{  
> "terms":{  
> "field":"file\_stages\_filetype\_result\_extension"  
> }  
> },  
> "facet\_filter":{  
> "terms":{  
> "file\_stages\_filetype\_result\_extension":["txt",  
> "htm"  
> ]  
> }  
> }  
> }  
> }
> 
> If I remove the facet\_filter it works fine and shows me all of the  
> facet data for that fields. The exception I get is here:  
> Failed to execute  
> [org.elasticsearch.action.search.SearchRequest@17a8b43]  
> org.elasticsearch.search.SearchParseException:  
> [96b46884fdddbf5b95a0568d84638da9][1]:  
> query[ConstantScore(_:_)],from[-1],size[-1]: Parse Failure [Failed to  
> parse source [{"query":{"match\_all":{}},"facets":{"tag":{"terms":  
> {"field":"file\_stages\_filetype\_result\_extension"}},"facet\_filter":  
> {"terms":{"file\_stages\_filetype\_result\_extension":["txt","htm"]}}}}]]  
> at  
> org.elasticsearch.search.SearchService.parseSource(SearchService.java:  
> 473)
> 
> I have also tried to get an and filter working with my facet\_filter  
> and that doesn't seem to work either. The filters do work in a  
> standalone query filter just not with the facet\_filter.
> 
> thanks,  
> Vinny

---

<div class="post-metadata">

**Author:** ![vinny](https://avatars.discourse-cdn.com/v4/letter/v/b9e5f3/32.png) [@vinny](https://discuss.elastic.co/u/vinny)\
**Post date:** [July 5, 2011, 1:26pm UTC](https://discuss.elastic.co/t/facet-filters-es-0-16-2/4752/3 "2011-07-05T13:26:01Z")

</div>

Thanks, that's what it was. I didn't realize I was one level outside  
of what I should have been. I blame to many curly braces.

On Jul 2, 12:22 am, Hari Shankar [shaan.h...@gmail.com](mailto:shaan.h...@gmail.com) wrote:

> Hi Vinny,
> 
> Try this:
> 
> {  
> "query":{  
> "match\_all":{}  
> },  
> "facets":{  
> "tag":{  
> "terms":{  
> "field":"file\_stages\_filetype\_result\_extension"  
> },  
> "facet\_filter":{  
> "terms":{  
> "file\_stages\_filetype\_result\_extension":["txt",  
> "htm"  
> ]  
> }  
> }  
> }  
> }
> 
> }
> 
> Facet filter is a property of the specific facet so it should come within  
> the facet.
> 
> Hari

---

<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, 4:01am UTC](https://discuss.elastic.co/t/facet-filters-es-0-16-2/4752/4 "2017-07-06T04:01:44Z")

</div>


