# Common terms query with cutoff\_frequency

**URL:** <https://discuss.elastic.co/t/common-terms-query-with-cutoff-frequency/15650>\
**Category:** Elasticsearch\
**Created:** [February 6, 2014, 6:58pm UTC](https://discuss.elastic.co/t/common-terms-query-with-cutoff-frequency/15650 "2014-02-06T18:58:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![vinamar](https://avatars.discourse-cdn.com/v4/letter/v/35a633/32.png) [@vinamar](https://discuss.elastic.co/u/vinamar)\
**Post date:** [February 6, 2014, 6:58pm UTC](https://discuss.elastic.co/t/common-terms-query-with-cutoff-frequency/15650/1 "2014-02-06T18:58:28Z")

</div>

Hi,

I have the following query given below. Currently any query term like "email not archived" excludes the not from the search results and highlighted results. i was planning to use common terms query to include this stop word in the results.

{  
"common": {  
"body": {  
"query": "this is bonsai cool",  
"cutoff\_frequency": 0.001  
}  
}  
}

I couldn't find any example of how to do this.

Can you please let me know how should i modify my query to include this ?

{  
"timeout": 30000,  
"highlight": {  
"pre\_tags": [  
""  
],  
"post\_tags": [  
""  
],  
"fields": {  
"srId": {  
"number\_of\_fragments": 0  
},  
"emails.emailBody": {  
"number\_of\_fragments": 0  
},  
"chatTextArray.text": {  
"number\_of\_fragments": 0  
}  
}  
},  
"query": {  
"filtered": {  
"filter": [  
{  
"range": {  
"closeDt": {  
"from": 1325404800000,  
"to": 1391760000000  
}  
}  
}  
],  
"query": {  
"query\_string": {  
"query": "payment button",  
"default\_operator": "AND",  
"fields": [  
[  
"emails.emailBody",  
"srId",  
"chatTextArray.text"  
]  
]  
}  
},  
"\_cache": true  
}  
},  
"size": 10  
}

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 10, 2014, 12:44pm UTC](https://discuss.elastic.co/t/common-terms-query-with-cutoff-frequency/15650/2 "2014-02-10T12:44:09Z")

</div>

Hey,

you need to replace the query\_string query with a match query, which in  
turn supports the cutoff\_frequency. Also make sure you change the default  
operator to AND. If you want to support multiple fields, you will need to  
use the multi\_field query

see

> **[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.

> **[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.

hope this helps...

--Alex

On Thu, Feb 6, 2014 at 7:58 PM, vinamar [vinamar@gmail.com](mailto:vinamar@gmail.com) wrote:

> Hi,
> 
> I have the following query given below. Currently any query term like  
> "email not archived" excludes the not from the search results and  
> highlighted results. i was planning to use common terms query to include  
> this stop word in the results.
> 
> {  
> "common": {  
> "body": {  
> "query": "this is bonsai cool",  
> "cutoff\_frequency": 0.001  
> }  
> }  
> }
> 
> I couldn't find any example of how to do this.
> 
> Can you please let me know how should i modify my query to include this ?
> 
> {  
> "timeout": 30000,  
> "highlight": {  
> "pre\_tags": [  
> ""  
> ],  
> "post\_tags": [  
> ""  
> ],  
> "fields": {  
> "srId": {  
> "number\_of\_fragments": 0  
> },  
> "emails.emailBody": {  
> "number\_of\_fragments": 0  
> },  
> "chatTextArray.text": {  
> "number\_of\_fragments": 0  
> }  
> }  
> },  
> "query": {  
> "filtered": {  
> "filter": [  
> {  
> "range": {  
> "closeDt": {  
> "from": 1325404800000,  
> "to": 1391760000000  
> }  
> }  
> }  
> ],  
> "query": {  
> "query\_string": {  
> "query": "payment button",  
> "default\_operator": "AND",  
> "fields": [  
> [  
> "emails.emailBody",  
> "srId",  
> "chatTextArray.text"  
> ]  
> ]  
> }  
> },  
> "\_cache": true  
> }  
> },  
> "size": 10  
> }
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/common-terms-query-with-cutoff-frequency-tp4049060.html](http://elasticsearch-users.115913.n3.nabble.com/common-terms-query-with-cutoff-frequency-tp4049060.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/1391713109922-4049060.post%40n3.nabble.com](https://groups.google.com/d/msgid/elasticsearch/1391713109922-4049060.post%40n3.nabble.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM\_c37QxQm7o73QKoKyxpzUWAtz\_8s12czN-oArm9SF6Nw%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM_c37QxQm7o73QKoKyxpzUWAtz_8s12czN-oArm9SF6Nw%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![vinamar](https://avatars.discourse-cdn.com/v4/letter/v/35a633/32.png) [@vinamar](https://discuss.elastic.co/u/vinamar)\
**Post date:** [February 11, 2014, 10:28pm UTC](https://discuss.elastic.co/t/common-terms-query-with-cutoff-frequency/15650/3 "2014-02-11T22:28:41Z")

</div>

Hi Alex,

I used the multi\_match query to query with stop words but the returned results doesn't contain the stop words. I used exact match with double quotes on the query string. Also the highlighted results - doesn't contain the stop words in the results.

"query": {  
"multi\_match": {  
"query": ""not%20received"",  
"operator": "AND",  
"zero\_terms\_query": "all",  
"fields": [  
[  
"emails.emailBody",  
"srId",  
"chatTextArray.text"  
]  
]  
}  
}

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 12, 2014, 1:43pm UTC](https://discuss.elastic.co/t/common-terms-query-with-cutoff-frequency/15650/4 "2014-02-12T13:43:05Z")

</div>

Hey,

you may have used an analyzer which removed stopwords? Try with another one  
and see if that works... side note: The default analyzer of elasticsearch  
0.90 removes stopwords, the default one of 1.x does not, so take care of  
the version you are trying this iwth.

--Alex

On Tue, Feb 11, 2014 at 11:28 PM, vinamar [vinamar@gmail.com](mailto:vinamar@gmail.com) wrote:

> Hi Alex,
> 
> I used the multi\_match query to query with stop words but the returned  
> results doesn't contain the stop words. I used exact match with double  
> quotes on the query string. Also the highlighted results - doesn't contain  
> the stop words in the results.
> 
> "query": {  
> "multi\_match": {  
> "query": ""not%20received"",  
> "operator": "AND",  
> "zero\_terms\_query": "all",  
> "fields": [  
> [  
> "emails.emailBody",  
> "srId",  
> "chatTextArray.text"  
> ]  
> ]  
> }  
> }
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/common-terms-query-with-cutoff-frequency-tp4049060p4049410.html](http://elasticsearch-users.115913.n3.nabble.com/common-terms-query-with-cutoff-frequency-tp4049060p4049410.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/1392157721335-4049410.post%40n3.nabble.com](https://groups.google.com/d/msgid/elasticsearch/1392157721335-4049410.post%40n3.nabble.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM8aomx\_f\_CkS%2BTK1W52wU%2BXPCHtPdWuzsHqKm5jNTtn4w%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM8aomx_f_CkS%2BTK1W52wU%2BXPCHtPdWuzsHqKm5jNTtn4w%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![vinamar](https://avatars.discourse-cdn.com/v4/letter/v/35a633/32.png) [@vinamar](https://discuss.elastic.co/u/vinamar)\
**Post date:** [February 12, 2014, 10:45pm UTC](https://discuss.elastic.co/t/common-terms-query-with-cutoff-frequency/15650/5 "2014-02-12T22:45:44Z")

</div>

Hi Alex,

I tested on our sandbox with ES 1.0 with a new data set - search defaults to including stop words in highlighted results.

For this change to happen do we need to re-index data after switching to ES 1.0 ? or the default analyzer would not be used during query time ?

Thanks, Vinoth

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 13, 2014, 9:05am UTC](https://discuss.elastic.co/t/common-terms-query-with-cutoff-frequency/15650/6 "2014-02-13T09:05:23Z")

</div>

Hey,

you need to reindex into a new index. Your old indices keep using the  
analyzer which has been defined earlier before the first data was indexed  
(switching that in between would lead to pretty unpredictable results from  
a search point of view).

--Alex

On Wed, Feb 12, 2014 at 11:45 PM, vinamar [vinamar@gmail.com](mailto:vinamar@gmail.com) wrote:

> Hi Alex,
> 
> I tested on our sandbox with ES 1.0 with a new data set - search  
> defaults  
> to including stop words in highlighted results.
> 
> For this change to happen do we need to re-index data after switching to ES  
> 1.0 ? or the default analyzer would not be used during query time ?
> 
> Thanks, Vinoth
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/common-terms-query-with-cutoff-frequency-tp4049060p4049504.html](http://elasticsearch-users.115913.n3.nabble.com/common-terms-query-with-cutoff-frequency-tp4049060p4049504.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).
> 
> --  
> You received this message because you are subscribed to the Google Groups  
> "elasticsearch" group.  
> To unsubscribe from this group and stop receiving emails from it, send an  
> email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/1392245145265-4049504.post%40n3.nabble.com](https://groups.google.com/d/msgid/elasticsearch/1392245145265-4049504.post%40n3.nabble.com)  
> .  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/CAGCwEM8FdrSutEcYMwiRum4QURNA6n0WE9D93fYcPUFcP%3DH6MA%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAGCwEM8FdrSutEcYMwiRum4QURNA6n0WE9D93fYcPUFcP%3DH6MA%40mail.gmail.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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, 1:50am UTC](https://discuss.elastic.co/t/common-terms-query-with-cutoff-frequency/15650/7 "2017-07-06T01:50:35Z")

</div>


