# How to use min\_term\_freq with bool query?

**URL:** <https://discuss.elastic.co/t/how-to-use-min-term-freq-with-bool-query/160996>\
**Category:** Elasticsearch\
**Created:** [December 15, 2018, 9:11am UTC](https://discuss.elastic.co/t/how-to-use-min-term-freq-with-bool-query/160996 "2018-12-15T09:11:35Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mia](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@mia](https://discuss.elastic.co/u/mia)\
**Post date:** [December 15, 2018, 9:11am UTC](https://discuss.elastic.co/t/how-to-use-min-term-freq-with-bool-query/160996/1 "2018-12-15T09:11:35Z")

</div>

I have this query:

```auto
{
   "bool":{
      "must":[
         {
            "multi_match":{
               "query":"foo",
               "fields":[
                  "title",
                  "body"
               ]
            }
         }
      ]
   }
}

```

and I want to exclude results that have the term mentioned 1 times.

I have already tried [more like this](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/query-dsl-mlt-query.html) api without any luck. I have also looked to [term vector](https://www.elastic.co/guide/en/elasticsearch/reference/5.5/docs-termvectors.html#docs-termvectors-terms-filtering) but it also did not work.

---

<div class="post-metadata">

**Author:** ![klof](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klof/32/31590_2.png) [@klof](https://discuss.elastic.co/u/klof)\
**Post date:** [December 16, 2018, 6:05am UTC](https://discuss.elastic.co/t/how-to-use-min-term-freq-with-bool-query/160996/2 "2018-12-16T06:05:43Z")

</div>

For the exclusion you could use the `must_not` clause :  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)

---

<div class="post-metadata">

**Author:** ![mia](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@mia](https://discuss.elastic.co/u/mia)\
**Post date:** [December 16, 2018, 12:16pm UTC](https://discuss.elastic.co/t/how-to-use-min-term-freq-with-bool-query/160996/3 "2018-12-16T12:16:07Z")

</div>

What exactly should I exclude? Can you give me example please?

Thanks.

---

<div class="post-metadata">

**Author:** ![mia](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@mia](https://discuss.elastic.co/u/mia)\
**Post date:** [December 16, 2018, 11:21pm UTC](https://discuss.elastic.co/t/how-to-use-min-term-freq-with-bool-query/160996/4 "2018-12-16T23:21:48Z")

</div>

bump

---

<div class="post-metadata">

**Author:** ![klof](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/klof/32/31590_2.png) [@klof](https://discuss.elastic.co/u/klof)\
**Post date:** [December 17, 2018, 6:25am UTC](https://discuss.elastic.co/t/how-to-use-min-term-freq-with-bool-query/160996/5 "2018-12-17T06:25:57Z")

</div>

I think I misunderstood what you want to achieve here :  
But if you want to exclude ONLY the terms mentioned once?  
There's one approach where you could add the `term_vectors` data (term\_frequency), into your documents during the indexing process, then query on the term\_frequency for the specific term.

---

<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:** [January 14, 2019, 6:26am UTC](https://discuss.elastic.co/t/how-to-use-min-term-freq-with-bool-query/160996/6 "2019-01-14T06:26:02Z")

</div>

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