# Facets don't appear with query filtered

**URL:** <https://discuss.elastic.co/t/facets-dont-appear-with-query-filtered/6434>\
**Category:** Elasticsearch\
**Created:** [January 18, 2012, 9:37pm UTC](https://discuss.elastic.co/t/facets-dont-appear-with-query-filtered/6434 "2012-01-18T21:37:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![BobbyTables](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bobbytables/32/2444_2.png) [@BobbyTables](https://discuss.elastic.co/u/BobbyTables)\
**Post date:** [January 18, 2012, 9:37pm UTC](https://discuss.elastic.co/t/facets-dont-appear-with-query-filtered/6434/1 "2012-01-18T21:37:03Z")

</div>

When I try to use facets with my filtered search I don't get facets.  
Remove the "filtered" element and it works.

Without filtered:  
curl -X GET "[http://localhost:9200/products/product/\_search](http://localhost:9200/products/product/_search)?  
pretty=true" -d '{  
"query": {  
"bool": {  
"must": [{  
"query\_string": {  
"query": "\*",  
"default\_operator": "AND"  
}  
}]  
}  
},  
"facets": {  
"tags": {  
"terms": {  
"field": "tag\_names",  
"size": 10,  
"all\_terms": false  
}  
}  
}  
}'

This returns my facets as expected:

{  
"took" : 3,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 2,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "encore\_dev\_product",  
"\_type" : "product",  
"\_id" : "1",  
"\_score" : 1.0, "\_source" : {"client\_id":  
1,"description":"","name":"Green Day concert  
tickets","location\_coordinates":["32.716254,-117.160118"],"tag\_names":  
["concert","entertainment"]}  
}, {  
"\_index" : "encore\_dev\_product",  
"\_type" : "product",  
"\_id" : "2",  
"\_score" : 1.0, "\_source" : {"client\_id":  
1,"description":null,"name":"Gift certificate","location\_coordinates":  
["32.716254,-117.160118","33.8095868,-117.9229975"],"tag\_names":  
["food","restaurant"]}  
} ]  
},  
"facets" : {  
"tags" : {  
"\_type" : "terms",  
"missing" : 0,  
"total" : 4,  
"other" : 0,  
"terms" : [ {  
"term" : "restaurant",  
"count" : 1  
}, {  
"term" : "food",  
"count" : 1  
}, {  
"term" : "entertainment",  
"count" : 1  
}, {  
"term" : "concert",  
"count" : 1  
} ]  
}  
}

With filtered:

curl -X GET "[http://localhost:9200/products/product/\_search](http://localhost:9200/products/product/_search)?  
pretty=true" -d '{  
"query": {  
"bool": {  
"must": [{  
"query\_string": {  
"query": "\*",  
"default\_operator": "AND"  
}  
}]  
},  
"filtered": {  
"filter": [{  
"geo\_distance": {  
"location\_coordinates": "33.6147846,-117.637617",  
"distance": "90mi"  
}  
}]  
}  
},  
"facets": {  
"tags": {  
"terms": {  
"field": "tag\_names",  
"size": 10,  
"all\_terms": false  
}  
}  
}  
}'

Returns no facets...

{  
"took" : 2,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 2,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "products",  
"\_type" : "product",  
"\_id" : "1",  
"\_score" : 1.0, "\_source" : {"client\_id":  
1,"description":"","name":"Green Day concert  
tickets","location\_coordinates":["32.716254,-117.160118"],"tag\_names":  
["concert","entertainment"]}  
}, {  
"\_index" : "products",  
"\_type" : "product",  
"\_id" : "2",  
"\_score" : 1.0, "\_source" : {"client\_id":  
1,"description":null,"name":"Gift certificate","location\_coordinates":  
["32.716254,-117.160118","33.8095868,-117.9229975"],"tag\_names":  
["food","restaurant"]}  
} ]  
}

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)\
**Post date:** [January 18, 2012, 10:04pm UTC](https://discuss.elastic.co/t/facets-dont-appear-with-query-filtered/6434/2 "2012-01-18T22:04:36Z")

</div>

shouldn't your query go into filtered?

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

[http://groups.google.com/group/elasticsearch/browse\_thread/thread/655f9706efc7240e/90eb6b56c7898959?lnk=gst&q=facet+filter#90eb6b56c7898959](http://groups.google.com/group/elasticsearch/browse_thread/thread/655f9706efc7240e/90eb6b56c7898959?lnk=gst&q=facet+filter#90eb6b56c7898959)

BTW: Also have a look into the filter element which does not apply to  
the facets:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

Peter.

On 18 Jan., 22:37, Bobby Tables [rob...@maintainedauto.com](mailto:rob...@maintainedauto.com) wrote:

> When I try to use facets with my filtered search I don't get facets.  
> Remove the "filtered" element and it works.
> 
> Without filtered:  
> curl -X GET "[http://localhost:9200/products/product/\_search](http://localhost:9200/products/product/_search)?  
> pretty=true" -d '{  
> "query": {  
> "bool": {  
> "must": [{  
> "query\_string": {  
> "query": "\*",  
> "default\_operator": "AND"  
> }  
> }]  
> }  
> },  
> "facets": {  
> "tags": {  
> "terms": {  
> "field": "tag\_names",  
> "size": 10,  
> "all\_terms": false  
> }  
> }  
> }
> 
> }'
> 
> This returns my facets as expected:
> 
> {  
> "took" : 3,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 2,  
> "max\_score" : 1.0,  
> "hits" : [ {  
> "\_index" : "encore\_dev\_product",  
> "\_type" : "product",  
> "\_id" : "1",  
> "\_score" : 1.0, "\_source" : {"client\_id":  
> 1,"description":"","name":"Green Day concert  
> tickets","location\_coordinates":["32.716254,-117.160118"],"tag\_names":  
> ["concert","entertainment"]}  
> }, {  
> "\_index" : "encore\_dev\_product",  
> "\_type" : "product",  
> "\_id" : "2",  
> "\_score" : 1.0, "\_source" : {"client\_id":  
> 1,"description":null,"name":"Gift certificate","location\_coordinates":  
> ["32.716254,-117.160118","33.8095868,-117.9229975"],"tag\_names":  
> ["food","restaurant"]}  
> } ]  
> },  
> "facets" : {  
> "tags" : {  
> "\_type" : "terms",  
> "missing" : 0,  
> "total" : 4,  
> "other" : 0,  
> "terms" : [ {  
> "term" : "restaurant",  
> "count" : 1  
> }, {  
> "term" : "food",  
> "count" : 1  
> }, {  
> "term" : "entertainment",  
> "count" : 1  
> }, {  
> "term" : "concert",  
> "count" : 1  
> } ]  
> }  
> }
> 
> With filtered:
> 
> curl -X GET "[http://localhost:9200/products/product/\_search](http://localhost:9200/products/product/_search)?  
> pretty=true" -d '{  
> "query": {  
> "bool": {  
> "must": [{  
> "query\_string": {  
> "query": "\*",  
> "default\_operator": "AND"  
> }  
> }]  
> },  
> "filtered": {  
> "filter": [{  
> "geo\_distance": {  
> "location\_coordinates": "33.6147846,-117.637617",  
> "distance": "90mi"  
> }  
> }]  
> }  
> },  
> "facets": {  
> "tags": {  
> "terms": {  
> "field": "tag\_names",  
> "size": 10,  
> "all\_terms": false  
> }  
> }  
> }
> 
> }'
> 
> Returns no facets...
> 
> {  
> "took" : 2,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 2,  
> "max\_score" : 1.0,  
> "hits" : [ {  
> "\_index" : "products",  
> "\_type" : "product",  
> "\_id" : "1",  
> "\_score" : 1.0, "\_source" : {"client\_id":  
> 1,"description":"","name":"Green Day concert  
> tickets","location\_coordinates":["32.716254,-117.160118"],"tag\_names":  
> ["concert","entertainment"]}  
> }, {  
> "\_index" : "products",  
> "\_type" : "product",  
> "\_id" : "2",  
> "\_score" : 1.0, "\_source" : {"client\_id":  
> 1,"description":null,"name":"Gift certificate","location\_coordinates":  
> ["32.716254,-117.160118","33.8095868,-117.9229975"],"tag\_names":  
> ["food","restaurant"]}  
> } ]  
> }
> 
> What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![BobbyTables](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bobbytables/32/2444_2.png) [@BobbyTables](https://discuss.elastic.co/u/BobbyTables)\
**Post date:** [January 18, 2012, 11:48pm UTC](https://discuss.elastic.co/t/facets-dont-appear-with-query-filtered/6434/3 "2012-01-18T23:48:16Z")

</div>

I'm not sure I understand. I hate to ask but would you mind moving the  
elements around to be correct so I can see it right?

On Jan 18, 2:04 pm, Karussell [tableyourt...@googlemail.com](mailto:tableyourt...@googlemail.com) wrote:

> shouldn't your query go into filtered?
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/filtered-query...http://groups.google.com/group/elasticsearch/browse_thread/thread/655)...
> 
> BTW: Also have a look into the filter element which does not apply to  
> the facets:[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/filter.html)
> 
> Peter.
> 
> On 18 Jan., 22:37, Bobby Tables [rob...@maintainedauto.com](mailto:rob...@maintainedauto.com) wrote:
> 
> > When I try to use facets with my filtered search I don't get facets.  
> > Remove the "filtered" element and it works.
> 
> > Without filtered:  
> > curl -X GET "[http://localhost:9200/products/product/\_search](http://localhost:9200/products/product/_search)?  
> > pretty=true" -d '{  
> > "query": {  
> > "bool": {  
> > "must": [{  
> > "query\_string": {  
> > "query": "\*",  
> > "default\_operator": "AND"  
> > }  
> > }]  
> > }  
> > },  
> > "facets": {  
> > "tags": {  
> > "terms": {  
> > "field": "tag\_names",  
> > "size": 10,  
> > "all\_terms": false  
> > }  
> > }  
> > }
> 
> > }'
> 
> > This returns my facets as expected:
> 
> > {  
> > "took" : 3,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 5,  
> > "successful" : 5,  
> > "failed" : 0  
> > },  
> > "hits" : {  
> > "total" : 2,  
> > "max\_score" : 1.0,  
> > "hits" : [ {  
> > "\_index" : "encore\_dev\_product",  
> > "\_type" : "product",  
> > "\_id" : "1",  
> > "\_score" : 1.0, "\_source" : {"client\_id":  
> > 1,"description":"","name":"Green Day concert  
> > tickets","location\_coordinates":["32.716254,-117.160118"],"tag\_names":  
> > ["concert","entertainment"]}  
> > }, {  
> > "\_index" : "encore\_dev\_product",  
> > "\_type" : "product",  
> > "\_id" : "2",  
> > "\_score" : 1.0, "\_source" : {"client\_id":  
> > 1,"description":null,"name":"Gift certificate","location\_coordinates":  
> > ["32.716254,-117.160118","33.8095868,-117.9229975"],"tag\_names":  
> > ["food","restaurant"]}  
> > } ]  
> > },  
> > "facets" : {  
> > "tags" : {  
> > "\_type" : "terms",  
> > "missing" : 0,  
> > "total" : 4,  
> > "other" : 0,  
> > "terms" : [ {  
> > "term" : "restaurant",  
> > "count" : 1  
> > }, {  
> > "term" : "food",  
> > "count" : 1  
> > }, {  
> > "term" : "entertainment",  
> > "count" : 1  
> > }, {  
> > "term" : "concert",  
> > "count" : 1  
> > } ]  
> > }  
> > }
> 
> > With filtered:
> 
> > curl -X GET "[http://localhost:9200/products/product/\_search](http://localhost:9200/products/product/_search)?  
> > pretty=true" -d '{  
> > "query": {  
> > "bool": {  
> > "must": [{  
> > "query\_string": {  
> > "query": "\*",  
> > "default\_operator": "AND"  
> > }  
> > }]  
> > },  
> > "filtered": {  
> > "filter": [{  
> > "geo\_distance": {  
> > "location\_coordinates": "33.6147846,-117.637617",  
> > "distance": "90mi"  
> > }  
> > }]  
> > }  
> > },  
> > "facets": {  
> > "tags": {  
> > "terms": {  
> > "field": "tag\_names",  
> > "size": 10,  
> > "all\_terms": false  
> > }  
> > }  
> > }
> 
> > }'
> 
> > Returns no facets...
> 
> > {  
> > "took" : 2,  
> > "timed\_out" : false,  
> > "\_shards" : {  
> > "total" : 5,  
> > "successful" : 5,  
> > "failed" : 0  
> > },  
> > "hits" : {  
> > "total" : 2,  
> > "max\_score" : 1.0,  
> > "hits" : [ {  
> > "\_index" : "products",  
> > "\_type" : "product",  
> > "\_id" : "1",  
> > "\_score" : 1.0, "\_source" : {"client\_id":  
> > 1,"description":"","name":"Green Day concert  
> > tickets","location\_coordinates":["32.716254,-117.160118"],"tag\_names":  
> > ["concert","entertainment"]}  
> > }, {  
> > "\_index" : "products",  
> > "\_type" : "product",  
> > "\_id" : "2",  
> > "\_score" : 1.0, "\_source" : {"client\_id":  
> > 1,"description":null,"name":"Gift certificate","location\_coordinates":  
> > ["32.716254,-117.160118","33.8095868,-117.9229975"],"tag\_names":  
> > ["food","restaurant"]}  
> > } ]  
> > }
> 
> > What am I doing wrong?

---

<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:** [January 19, 2012, 9:04am UTC](https://discuss.elastic.co/t/facets-dont-appear-with-query-filtered/6434/4 "2012-01-19T09:04:16Z")

</div>

On Wed, 2012-01-18 at 15:48 -0800, Bobby Tables wrote:

> I'm not sure I understand. I hate to ask but would you mind moving the  
> elements around to be correct so I can see it right?

I answered a similar question yesterday, with examples:

> <https://stackoverflow.com/questions/584497/apache-derby-check-database-already-created/891361#891361>

clint

> On Jan 18, 2:04 pm, Karussell [tableyourt...@googlemail.com](mailto:tableyourt...@googlemail.com) wrote:
> 
> > shouldn't your query go into filtered?
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/filtered-query...http://groups.google.com/group/elasticsearch/browse_thread/thread/655)...
> > 
> > BTW: Also have a look into the filter element which does not apply to  
> > the facets:[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/filter.html)
> > 
> > Peter.
> > 
> > On 18 Jan., 22:37, Bobby Tables [rob...@maintainedauto.com](mailto:rob...@maintainedauto.com) wrote:
> > 
> > > When I try to use facets with my filtered search I don't get facets.  
> > > Remove the "filtered" element and it works.
> > 
> > > Without filtered:  
> > > curl -X GET "[http://localhost:9200/products/product/\_search](http://localhost:9200/products/product/_search)?  
> > > pretty=true" -d '{  
> > > "query": {  
> > > "bool": {  
> > > "must": [{  
> > > "query\_string": {  
> > > "query": "\*",  
> > > "default\_operator": "AND"  
> > > }  
> > > }]  
> > > }  
> > > },  
> > > "facets": {  
> > > "tags": {  
> > > "terms": {  
> > > "field": "tag\_names",  
> > > "size": 10,  
> > > "all\_terms": false  
> > > }  
> > > }  
> > > }
> > 
> > > }'
> > 
> > > This returns my facets as expected:
> > 
> > > {  
> > > "took" : 3,  
> > > "timed\_out" : false,  
> > > "\_shards" : {  
> > > "total" : 5,  
> > > "successful" : 5,  
> > > "failed" : 0  
> > > },  
> > > "hits" : {  
> > > "total" : 2,  
> > > "max\_score" : 1.0,  
> > > "hits" : [ {  
> > > "\_index" : "encore\_dev\_product",  
> > > "\_type" : "product",  
> > > "\_id" : "1",  
> > > "\_score" : 1.0, "\_source" : {"client\_id":  
> > > 1,"description":"","name":"Green Day concert  
> > > tickets","location\_coordinates":["32.716254,-117.160118"],"tag\_names":  
> > > ["concert","entertainment"]}  
> > > }, {  
> > > "\_index" : "encore\_dev\_product",  
> > > "\_type" : "product",  
> > > "\_id" : "2",  
> > > "\_score" : 1.0, "\_source" : {"client\_id":  
> > > 1,"description":null,"name":"Gift certificate","location\_coordinates":  
> > > ["32.716254,-117.160118","33.8095868,-117.9229975"],"tag\_names":  
> > > ["food","restaurant"]}  
> > > } ]  
> > > },  
> > > "facets" : {  
> > > "tags" : {  
> > > "\_type" : "terms",  
> > > "missing" : 0,  
> > > "total" : 4,  
> > > "other" : 0,  
> > > "terms" : [ {  
> > > "term" : "restaurant",  
> > > "count" : 1  
> > > }, {  
> > > "term" : "food",  
> > > "count" : 1  
> > > }, {  
> > > "term" : "entertainment",  
> > > "count" : 1  
> > > }, {  
> > > "term" : "concert",  
> > > "count" : 1  
> > > } ]  
> > > }  
> > > }
> > 
> > > With filtered:
> > 
> > > curl -X GET "[http://localhost:9200/products/product/\_search](http://localhost:9200/products/product/_search)?  
> > > pretty=true" -d '{  
> > > "query": {  
> > > "bool": {  
> > > "must": [{  
> > > "query\_string": {  
> > > "query": "\*",  
> > > "default\_operator": "AND"  
> > > }  
> > > }]  
> > > },  
> > > "filtered": {  
> > > "filter": [{  
> > > "geo\_distance": {  
> > > "location\_coordinates": "33.6147846,-117.637617",  
> > > "distance": "90mi"  
> > > }  
> > > }]  
> > > }  
> > > },  
> > > "facets": {  
> > > "tags": {  
> > > "terms": {  
> > > "field": "tag\_names",  
> > > "size": 10,  
> > > "all\_terms": false  
> > > }  
> > > }  
> > > }
> > 
> > > }'
> > 
> > > Returns no facets...
> > 
> > > {  
> > > "took" : 2,  
> > > "timed\_out" : false,  
> > > "\_shards" : {  
> > > "total" : 5,  
> > > "successful" : 5,  
> > > "failed" : 0  
> > > },  
> > > "hits" : {  
> > > "total" : 2,  
> > > "max\_score" : 1.0,  
> > > "hits" : [ {  
> > > "\_index" : "products",  
> > > "\_type" : "product",  
> > > "\_id" : "1",  
> > > "\_score" : 1.0, "\_source" : {"client\_id":  
> > > 1,"description":"","name":"Green Day concert  
> > > tickets","location\_coordinates":["32.716254,-117.160118"],"tag\_names":  
> > > ["concert","entertainment"]}  
> > > }, {  
> > > "\_index" : "products",  
> > > "\_type" : "product",  
> > > "\_id" : "2",  
> > > "\_score" : 1.0, "\_source" : {"client\_id":  
> > > 1,"description":null,"name":"Gift certificate","location\_coordinates":  
> > > ["32.716254,-117.160118","33.8095868,-117.9229975"],"tag\_names":  
> > > ["food","restaurant"]}  
> > > } ]  
> > > }
> > 
> > > What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)\
**Post date:** [January 19, 2012, 12:34pm UTC](https://discuss.elastic.co/t/facets-dont-appear-with-query-filtered/6434/5 "2012-01-19T12:34:29Z")

</div>

There is filtered query, there is filter and finally there is  
facet\_filter ... probably a bit too much, now explained in a quick  
post:

> **[Bird’s Eye View on ElasticSearch its Query DSL](https://karussell.wordpress.com/2012/01/19/birds-eye-view-on-elasticsearch-its-query-dsl/)**
>
> I’ve copied the whole post into a gist so that you can simply clone, copy and paste the important stuff and even could contribute easily. Several times per month there pop up questions regard…

Bobby, let me know if this solves a bit of your problem and how I  
could improve my explanation there!

Peter.

On 19 Jan., 10:04, Clinton Gormley [cl...@traveljury.com](mailto:cl...@traveljury.com) wrote:

> On Wed, 2012-01-18 at 15:48 -0800, Bobby Tables wrote:
> 
> > I'm not sure I understand. I hate to ask but would you mind moving the  
> > elements around to be correct so I can see it right?
> 
> I answered a similar question yesterday, with examples:[Elasticsearch: excluding filters while faceting possible? (like in Solr) - Stack Overflow](http://stackoverflow.com/questions/8908325/elasticsearch-excluding-fi)...
> 
> clint
> 
> > On Jan 18, 2:04 pm, Karussell [tableyourt...@googlemail.com](mailto:tableyourt...@googlemail.com) wrote:
> > 
> > > shouldn't your query go into filtered?
> 
> > > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/filtered-query)......
> 
> > > BTW: Also have a look into the filter element which does not apply to  
> > > the facets:[Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/filter.html)
> 
> > > Peter.
> 
> > > On 18 Jan., 22:37, Bobby Tables [rob...@maintainedauto.com](mailto:rob...@maintainedauto.com) wrote:
> 
> > > > When I try to use facets with my filtered search I don't get facets.  
> > > > Remove the "filtered" element and it works.
> 
> > > > Without filtered:  
> > > > curl -X GET "[http://localhost:9200/products/product/\_search](http://localhost:9200/products/product/_search)?  
> > > > pretty=true" -d '{  
> > > > "query": {  
> > > > "bool": {  
> > > > "must": [{  
> > > > "query\_string": {  
> > > > "query": "\*",  
> > > > "default\_operator": "AND"  
> > > > }  
> > > > }]  
> > > > }  
> > > > },  
> > > > "facets": {  
> > > > "tags": {  
> > > > "terms": {  
> > > > "field": "tag\_names",  
> > > > "size": 10,  
> > > > "all\_terms": false  
> > > > }  
> > > > }  
> > > > }
> 
> > > > }'
> 
> > > > This returns my facets as expected:
> 
> > > > {  
> > > > "took" : 3,  
> > > > "timed\_out" : false,  
> > > > "\_shards" : {  
> > > > "total" : 5,  
> > > > "successful" : 5,  
> > > > "failed" : 0  
> > > > },  
> > > > "hits" : {  
> > > > "total" : 2,  
> > > > "max\_score" : 1.0,  
> > > > "hits" : [ {  
> > > > "\_index" : "encore\_dev\_product",  
> > > > "\_type" : "product",  
> > > > "\_id" : "1",  
> > > > "\_score" : 1.0, "\_source" : {"client\_id":  
> > > > 1,"description":"","name":"Green Day concert  
> > > > tickets","location\_coordinates":["32.716254,-117.160118"],"tag\_names":  
> > > > ["concert","entertainment"]}  
> > > > }, {  
> > > > "\_index" : "encore\_dev\_product",  
> > > > "\_type" : "product",  
> > > > "\_id" : "2",  
> > > > "\_score" : 1.0, "\_source" : {"client\_id":  
> > > > 1,"description":null,"name":"Gift certificate","location\_coordinates":  
> > > > ["32.716254,-117.160118","33.8095868,-117.9229975"],"tag\_names":  
> > > > ["food","restaurant"]}  
> > > > } ]  
> > > > },  
> > > > "facets" : {  
> > > > "tags" : {  
> > > > "\_type" : "terms",  
> > > > "missing" : 0,  
> > > > "total" : 4,  
> > > > "other" : 0,  
> > > > "terms" : [ {  
> > > > "term" : "restaurant",  
> > > > "count" : 1  
> > > > }, {  
> > > > "term" : "food",  
> > > > "count" : 1  
> > > > }, {  
> > > > "term" : "entertainment",  
> > > > "count" : 1  
> > > > }, {  
> > > > "term" : "concert",  
> > > > "count" : 1  
> > > > } ]  
> > > > }  
> > > > }
> 
> > > > With filtered:
> 
> > > > curl -X GET "[http://localhost:9200/products/product/\_search](http://localhost:9200/products/product/_search)?  
> > > > pretty=true" -d '{  
> > > > "query": {  
> > > > "bool": {  
> > > > "must": [{  
> > > > "query\_string": {  
> > > > "query": "\*",  
> > > > "default\_operator": "AND"  
> > > > }  
> > > > }]  
> > > > },  
> > > > "filtered": {  
> > > > "filter": [{  
> > > > "geo\_distance": {  
> > > > "location\_coordinates": "33.6147846,-117.637617",  
> > > > "distance": "90mi"  
> > > > }  
> > > > }]  
> > > > }  
> > > > },  
> > > > "facets": {  
> > > > "tags": {  
> > > > "terms": {  
> > > > "field": "tag\_names",  
> > > > "size": 10,  
> > > > "all\_terms": false  
> > > > }  
> > > > }  
> > > > }
> 
> > > > }'
> 
> > > > Returns no facets...
> 
> > > > {  
> > > > "took" : 2,  
> > > > "timed\_out" : false,  
> > > > "\_shards" : {  
> > > > "total" : 5,  
> > > > "successful" : 5,  
> > > > "failed" : 0  
> > > > },  
> > > > "hits" : {  
> > > > "total" : 2,  
> > > > "max\_score" : 1.0,  
> > > > "hits" : [ {  
> > > > "\_index" : "products",  
> > > > "\_type" : "product",  
> > > > "\_id" : "1",  
> > > > "\_score" : 1.0, "\_source" : {"client\_id":  
> > > > 1,"description":"","name":"Green Day concert  
> > > > tickets","location\_coordinates":["32.716254,-117.160118"],"tag\_names":  
> > > > ["concert","entertainment"]}  
> > > > }, {  
> > > > "\_index" : "products",  
> > > > "\_type" : "product",  
> > > > "\_id" : "2",  
> > > > "\_score" : 1.0, "\_source" : {"client\_id":  
> > > > 1,"description":null,"name":"Gift certificate","location\_coordinates":  
> > > > ["32.716254,-117.160118","33.8095868,-117.9229975"],"tag\_names":  
> > > > ["food","restaurant"]}  
> > > > } ]  
> > > > }
> 
> > > > What am I doing wrong?

---

<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:42am UTC](https://discuss.elastic.co/t/facets-dont-appear-with-query-filtered/6434/6 "2017-07-06T03:42:09Z")

</div>


