# How do Elasticsearch calculate term freq when using CutoffFrequency in CommonTermsQuery?

**URL:** <https://discuss.elastic.co/t/how-do-elasticsearch-calculate-term-freq-when-using-cutofffrequency-in-commontermsquery/155126>\
**Category:** Elasticsearch\
**Created:** [November 2, 2018, 7:12am UTC](https://discuss.elastic.co/t/how-do-elasticsearch-calculate-term-freq-when-using-cutofffrequency-in-commontermsquery/155126 "2018-11-02T07:12:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![david30907d](https://avatars.discourse-cdn.com/v4/letter/d/6de8d8/32.png) [@david30907d](https://discuss.elastic.co/u/david30907d)\
**Post date:** [November 2, 2018, 7:12am UTC](https://discuss.elastic.co/t/how-do-elasticsearch-calculate-term-freq-when-using-cutofffrequency-in-commontermsquery/155126/1 "2018-11-02T07:12:53Z")

</div>

I'm trying to understand how CutoffFrequency works.  
And i found that the frequency calculated by elastic is not what i assumed.

here's my env:

- i builded my index with `1 shard , 0 replicas`

- my query written in GO: `elastic.NewCommonTermsQuery("title", "batman official trailers").Analyzer("synonym").CutoffFrequency(0.006).LowFreqMinimumShouldMatch(4)`

- synonym:

- target doc:

- statistics from requesting `/_termvectors`:

- the frequency i assumed:

but it turns out that `CutoffFrequency(0.006)` would not retrieve target doc and `CutoffFrequency(0.007)` would retire the target doc  
Would anyone know how elasticsearch calculate term frequency?

---

<div class="post-metadata">

**Author:** ![david30907d](https://avatars.discourse-cdn.com/v4/letter/d/6de8d8/32.png) [@david30907d](https://discuss.elastic.co/u/david30907d)\
**Post date:** [November 2, 2018, 9:10am UTC](https://discuss.elastic.co/t/how-do-elasticsearch-calculate-term-freq-when-using-cutofffrequency-in-commontermsquery/155126/2 "2018-11-02T09:10:23Z")

</div>

OK, i figured it out by myself

the Frequency here is doc freq of a term

e.q.:

- batman: 2/155
- official: 2/155
- bruce: 2/155
- trailers: 2/155

---

<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:** [November 30, 2018, 9:10am UTC](https://discuss.elastic.co/t/how-do-elasticsearch-calculate-term-freq-when-using-cutofffrequency-in-commontermsquery/155126/3 "2018-11-30T09:10:26Z")

</div>

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