# Significant Terms - Exclude list of specific terms

**URL:** <https://discuss.elastic.co/t/significant-terms-exclude-list-of-specific-terms/179564>\
**Category:** Elasticsearch\
**Created:** [May 3, 2019, 4:26pm UTC](https://discuss.elastic.co/t/significant-terms-exclude-list-of-specific-terms/179564 "2019-05-03T16:26:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adahn](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/adahn/32/45475_2.png) [@adahn](https://discuss.elastic.co/u/adahn)\
**Post date:** [May 3, 2019, 4:26pm UTC](https://discuss.elastic.co/t/significant-terms-exclude-list-of-specific-terms/179564/1 "2019-05-03T16:26:08Z")

</div>

I'm using Significant Terms to find high frequency keywords in a text field. I'm using regex in the Include parameter, but want to Exclude certain exact terms I don't care about:

//"include": "([a-zA-Z]{2,10}\_)+[a-zA-Z]{2,10}",  
//"exclude" : ["not\_this","not\_that"]

I based this exclude statement on the model in the Terms Aggregation document, but I get an error when trying to apply it to my visualization

//[significant\_terms] failed to parse field [exclude]

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [May 3, 2019, 4:35pm UTC](https://discuss.elastic.co/t/significant-terms-exclude-list-of-specific-terms/179564/2 "2019-05-03T16:35:32Z")

</div>

> [@adahn](#):
>
> //"include": "([a-zA-Z]{2,10}\_)+[a-zA-Z]{2,10}",  
> //"exclude" : ["not\_this","not\_that"]

The [IncludeExclude class](https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/search/aggregations/bucket/terms/IncludeExclude.java#L328) that implements this has the limitation that an include list which is a regex can only be filtered by an exclude class which is also a regex. That means you'd need to rewrite as:

```
"include": "([a-zA-Z]{2,10}_)+[a-zA-Z]{2,10}",
"exclude" : "not_this|not_that"

```

---

<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:** [May 31, 2019, 4:35pm UTC](https://discuss.elastic.co/t/significant-terms-exclude-list-of-specific-terms/179564/3 "2019-05-31T16:35:34Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
