# Terms Facet - "Excluded" being ignored?

**URL:** <https://discuss.elastic.co/t/terms-facet-excluded-being-ignored/4122>\
**Category:** Elasticsearch\
**Created:** [March 17, 2011, 2:26pm UTC](https://discuss.elastic.co/t/terms-facet-excluded-being-ignored/4122 "2011-03-17T14:26:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Olafur\_Gauti\_Gudmund](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olafur_gauti_gudmund/32/2694_2.png) [@Olafur\_Gauti\_Gudmund](https://discuss.elastic.co/u/Olafur_Gauti_Gudmund)\
**Post date:** [March 17, 2011, 2:26pm UTC](https://discuss.elastic.co/t/terms-facet-excluded-being-ignored/4122/1 "2011-03-17T14:26:10Z")

</div>

Hi,  
I'm running ElasticSearch 0.15.0. For some reason, ElasticSearch is  
ignoring my "excluded" terms in a "terms" facet.  
I'm pretty sure this was working before.

Is there anything that has changed in this regard, or can you spot an  
error in my JSON below?

Many thanks,  
OGG

Here is my query (note the exclude setting on "categories" and  
"advType" facets):

{  
"from": 0,  
"size": 25,  
"query": {  
"match\_all": {}  
},  
"sort": [{  
"creationDate": {  
"reverse": true  
}  
}, "\_score"],  
"highlight": {  
"fields": {  
"headline": {},  
"body": {}  
}  
},  
"facets": {  
"categories": {  
"terms": {  
"field": "category",  
"size": 20,  
"order": "count",  
"exclude": [0, 22]  
}  
},  
"advTypes": {  
"terms": {  
"field": "advType",  
"size": 10,  
"order": "count",  
"exclude": [0]  
}  
},  
"tags": {  
"terms": {  
"field": "tags",  
"size": 10,  
"order": "count"  
}  
},  
"priceHistogram": {  
"histogram": {  
"field": "prices",  
"interval": 20000  
}  
},  
"dateRange": {  
"range": {  
"creationDate": [{  
"from": "2011-03-17"  
}, {  
"from": "2011-03-10"  
}, {  
"from": "2011-02-17"  
}, {  
"to": "2011-02-17"  
}]  
}  
}  
}  
}

And following is the facets part of the response I get back  
(irrelevant facets omitted for brevity):

"facets": {  
"categories": {  
"\_type": "terms",  
"missing": 0,  
"terms": [{  
"term": 8,  
"count": 6259  
}, {  
"term": 12,  
"count": 4588  
}, {  
"term": 4,  
"count": 4080  
}, {  
"term": 7,  
"count": 3391  
}, {  
"term": 1,  
"count": 2574  
}, {  
"term": 15,  
"count": 2224  
}, {  
"term": 3,  
"count": 2118  
}, {  
"term": 10,  
"count": 1458  
}, {  
"term": 13,  
"count": 1018  
}, {  
"term": 17,  
"count": 805  
}, {  
"term": 18,  
"count": 763  
}, {  
"term": 9,  
"count": 500  
}, {  
"term": 11,  
"count": 460  
}, {  
"term": 0,  
"count": 390  
}, {  
"term": 16,  
"count": 324  
}, {  
"term": 20,  
"count": 286  
}, {  
"term": 14,  
"count": 252  
}, {  
"term": 2,  
"count": 158  
}, {  
"term": 22,  
"count": 105  
}, {  
"term": 19,  
"count": 84  
}]  
},  
"advTypes": {  
"\_type": "terms",  
"missing": 0,  
"terms": [{  
"term": 1,  
"count": 23114  
}, {  
"term": 2,  
"count": 6571  
}, {  
"term": 0,  
"count": 1318  
}, {  
"term": 4,  
"count": 436  
}, {  
"term": 3,  
"count": 413  
}]  
}  
}

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 17, 2011, 6:37pm UTC](https://discuss.elastic.co/t/terms-facet-excluded-being-ignored/4122/2 "2011-03-17T18:37:25Z")

</div>

In 0.15, terms facet on numeric fields has been greatly enhanced when it comes to performance, but, the exclude functionally was not implemented for terms facet on numeric fields. It should have been..., can you open an issue?  
On Thursday, March 17, 2011 at 4:26 PM, Ãlafur Gauti GuÃ°mundsson wrote:

> Hi,  
> I'm running Elasticsearch 0.15.0. For some reason, Elasticsearch is  
> ignoring my "excluded" terms in a "terms" facet.  
> I'm pretty sure this was working before.
> 
> Is there anything that has changed in this regard, or can you spot an  
> error in my JSON below?
> 
> Many thanks,  
> OGG
> 
> Here is my query (note the exclude setting on "categories" and  
> "advType" facets):
> 
> {  
> "from": 0,  
> "size": 25,  
> "query": {  
> "match\_all": {}  
> },  
> "sort": [{  
> "creationDate": {  
> "reverse": true  
> }  
> }, "\_score"],  
> "highlight": {  
> "fields": {  
> "headline": {},  
> "body": {}  
> }  
> },  
> "facets": {  
> "categories": {  
> "terms": {  
> "field": "category",  
> "size": 20,  
> "order": "count",  
> "exclude": [0, 22]  
> }  
> },  
> "advTypes": {  
> "terms": {  
> "field": "advType",  
> "size": 10,  
> "order": "count",  
> "exclude": [0]  
> }  
> },  
> "tags": {  
> "terms": {  
> "field": "tags",  
> "size": 10,  
> "order": "count"  
> }  
> },  
> "priceHistogram": {  
> "histogram": {  
> "field": "prices",  
> "interval": 20000  
> }  
> },  
> "dateRange": {  
> "range": {  
> "creationDate": [{  
> "from": "2011-03-17"  
> }, {  
> "from": "2011-03-10"  
> }, {  
> "from": "2011-02-17"  
> }, {  
> "to": "2011-02-17"  
> }]  
> }  
> }  
> }  
> }
> 
> And following is the facets part of the response I get back  
> (irrelevant facets omitted for brevity):
> 
> "facets": {  
> "categories": {  
> "\_type": "terms",  
> "missing": 0,  
> "terms": [{  
> "term": 8,  
> "count": 6259  
> }, {  
> "term": 12,  
> "count": 4588  
> }, {  
> "term": 4,  
> "count": 4080  
> }, {  
> "term": 7,  
> "count": 3391  
> }, {  
> "term": 1,  
> "count": 2574  
> }, {  
> "term": 15,  
> "count": 2224  
> }, {  
> "term": 3,  
> "count": 2118  
> }, {  
> "term": 10,  
> "count": 1458  
> }, {  
> "term": 13,  
> "count": 1018  
> }, {  
> "term": 17,  
> "count": 805  
> }, {  
> "term": 18,  
> "count": 763  
> }, {  
> "term": 9,  
> "count": 500  
> }, {  
> "term": 11,  
> "count": 460  
> }, {  
> "term": 0,  
> "count": 390  
> }, {  
> "term": 16,  
> "count": 324  
> }, {  
> "term": 20,  
> "count": 286  
> }, {  
> "term": 14,  
> "count": 252  
> }, {  
> "term": 2,  
> "count": 158  
> }, {  
> "term": 22,  
> "count": 105  
> }, {  
> "term": 19,  
> "count": 84  
> }]  
> },  
> "advTypes": {  
> "\_type": "terms",  
> "missing": 0,  
> "terms": [{  
> "term": 1,  
> "count": 23114  
> }, {  
> "term": 2,  
> "count": 6571  
> }, {  
> "term": 0,  
> "count": 1318  
> }, {  
> "term": 4,  
> "count": 436  
> }, {  
> "term": 3,  
> "count": 413  
> }]  
> }  
> }

---

<div class="post-metadata">

**Author:** ![Olafur\_Gauti\_Gudmund](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/olafur_gauti_gudmund/32/2694_2.png) [@Olafur\_Gauti\_Gudmund](https://discuss.elastic.co/u/Olafur_Gauti_Gudmund)\
**Post date:** [March 17, 2011, 7:22pm UTC](https://discuss.elastic.co/t/terms-facet-excluded-being-ignored/4122/3 "2011-03-17T19:22:39Z")

</div>

Hi,  
Thanks for the quick reply.  
I created an issue for this: ["exclude" functionality missing for terms facet on numeric fields · Issue #789 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/789)

Regards,  
OGG

On Mar 17, 6:37 pm, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> In 0.15, terms facet on numeric fields has been greatly enhanced when it comes to performance, but, the exclude functionally was not implemented for terms facet on numeric fields. It should have been..., can you open an issue?
> 
> On Thursday, March 17, 2011 at 4:26 PM, Ólafur Gauti Guðmundsson wrote:
> 
> > Hi,  
> > I'm running Elasticsearch 0.15.0. For some reason, Elasticsearch is  
> > ignoring my "excluded" terms in a "terms" facet.  
> > I'm pretty sure this was working before.
> 
> > Is there anything that has changed in this regard, or can you spot an  
> > error in my JSON below?
> 
> > Many thanks,  
> > OGG
> 
> > Here is my query (note the exclude setting on "categories" and  
> > "advType" facets):
> 
> > {  
> > "from": 0,  
> > "size": 25,  
> > "query": {  
> > "match\_all": {}  
> > },  
> > "sort": [{  
> > "creationDate": {  
> > "reverse": true  
> > }  
> > }, "\_score"],  
> > "highlight": {  
> > "fields": {  
> > "headline": {},  
> > "body": {}  
> > }  
> > },  
> > "facets": {  
> > "categories": {  
> > "terms": {  
> > "field": "category",  
> > "size": 20,  
> > "order": "count",  
> > "exclude": [0, 22]  
> > }  
> > },  
> > "advTypes": {  
> > "terms": {  
> > "field": "advType",  
> > "size": 10,  
> > "order": "count",  
> > "exclude": [0]  
> > }  
> > },  
> > "tags": {  
> > "terms": {  
> > "field": "tags",  
> > "size": 10,  
> > "order": "count"  
> > }  
> > },  
> > "priceHistogram": {  
> > "histogram": {  
> > "field": "prices",  
> > "interval": 20000  
> > }  
> > },  
> > "dateRange": {  
> > "range": {  
> > "creationDate": [{  
> > "from": "2011-03-17"  
> > }, {  
> > "from": "2011-03-10"  
> > }, {  
> > "from": "2011-02-17"  
> > }, {  
> > "to": "2011-02-17"  
> > }]  
> > }  
> > }  
> > }  
> > }
> 
> > And following is the facets part of the response I get back  
> > (irrelevant facets omitted for brevity):
> 
> > "facets": {  
> > "categories": {  
> > "\_type": "terms",  
> > "missing": 0,  
> > "terms": [{  
> > "term": 8,  
> > "count": 6259  
> > }, {  
> > "term": 12,  
> > "count": 4588  
> > }, {  
> > "term": 4,  
> > "count": 4080  
> > }, {  
> > "term": 7,  
> > "count": 3391  
> > }, {  
> > "term": 1,  
> > "count": 2574  
> > }, {  
> > "term": 15,  
> > "count": 2224  
> > }, {  
> > "term": 3,  
> > "count": 2118  
> > }, {  
> > "term": 10,  
> > "count": 1458  
> > }, {  
> > "term": 13,  
> > "count": 1018  
> > }, {  
> > "term": 17,  
> > "count": 805  
> > }, {  
> > "term": 18,  
> > "count": 763  
> > }, {  
> > "term": 9,  
> > "count": 500  
> > }, {  
> > "term": 11,  
> > "count": 460  
> > }, {  
> > "term": 0,  
> > "count": 390  
> > }, {  
> > "term": 16,  
> > "count": 324  
> > }, {  
> > "term": 20,  
> > "count": 286  
> > }, {  
> > "term": 14,  
> > "count": 252  
> > }, {  
> > "term": 2,  
> > "count": 158  
> > }, {  
> > "term": 22,  
> > "count": 105  
> > }, {  
> > "term": 19,  
> > "count": 84  
> > }]  
> > },  
> > "advTypes": {  
> > "\_type": "terms",  
> > "missing": 0,  
> > "terms": [{  
> > "term": 1,  
> > "count": 23114  
> > }, {  
> > "term": 2,  
> > "count": 6571  
> > }, {  
> > "term": 0,  
> > "count": 1318  
> > }, {  
> > "term": 4,  
> > "count": 436  
> > }, {  
> > "term": 3,  
> > "count": 413  
> > }]  
> > }  
> > }

---

<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:09am UTC](https://discuss.elastic.co/t/terms-facet-excluded-being-ignored/4122/4 "2017-07-06T04:09:45Z")

</div>


