# Return results with match\_phrase if document count is greater than 1

**URL:** <https://discuss.elastic.co/t/return-results-with-match-phrase-if-document-count-is-greater-than-1/294143>\
**Category:** Kibana\
**Created:** [January 12, 2022, 10:37am UTC](https://discuss.elastic.co/t/return-results-with-match-phrase-if-document-count-is-greater-than-1/294143 "2022-01-12T10:37:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![liam.gallagher](https://avatars.discourse-cdn.com/v4/letter/l/ebca7d/32.png) [@liam.gallagher](https://discuss.elastic.co/u/liam.gallagher)\
**Post date:** [January 12, 2022, 10:37am UTC](https://discuss.elastic.co/t/return-results-with-match-phrase-if-document-count-is-greater-than-1/294143/1 "2022-01-12T10:37:13Z")

</div>

Good morning,

Is it possible to use match\_phrase to count the occurrence of the phrase per document and only return results if the phrase count in the document in greater than 1?

```auto
{
  "query": {
    "bool": {
      "should": [
        {
          "match_phrase": {
            "logComments.content": "IF DEEMED VULNERABLE FROM COMPLETION OF THRIVE THEN REMEMBER TO FLAG INCIDENT AS VULNERABLE"
          }
        }
      ]
    }
  }
}

```

So in a data table for example, the result would only be shown for documents where "IF DEEMED VULNERABLE FROM COMPLETION OF THRIVE THEN REMEMBER TO FLAG INCIDENT AS VULNERABLE" appears more than once.

---

<div class="post-metadata">

**Author:** ![Tomo\_M](https://avatars.discourse-cdn.com/v4/letter/t/848f3c/32.png) [@Tomo\_M](https://discuss.elastic.co/u/Tomo_M)\
**Post date:** [January 13, 2022, 9:42am UTC](https://discuss.elastic.co/t/return-results-with-match-phrase-if-document-count-is-greater-than-1/294143/2 "2022-01-13T09:42:58Z")

</div>

Hello,

Unfortunately, as far as I know, there is no paramter to set minimum frequency of the matching phrase.

One possible option could be using wildcard field and wildcard query with something like "IF DEEMED VULNERABLE FROM COMPLETION OF THRIVE THEN REMEMBER TO FLAG INCIDENT AS VULNERABLE \* IF DEEMED VULNERABLE FROM COMPLETION OF THRIVE THEN REMEMBER TO FLAG INCIDENT AS VULNERABLE".

---

<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:** [February 10, 2022, 9:43am UTC](https://discuss.elastic.co/t/return-results-with-match-phrase-if-document-count-is-greater-than-1/294143/3 "2022-02-10T09:43:39Z")

</div>

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