# Elasticsearch query to search word occurred as n times in document

**URL:** <https://discuss.elastic.co/t/elasticsearch-query-to-search-word-occurred-as-n-times-in-document/127688>\
**Category:** Elasticsearch\
**Created:** [April 11, 2018, 6:38pm UTC](https://discuss.elastic.co/t/elasticsearch-query-to-search-word-occurred-as-n-times-in-document/127688 "2018-04-11T18:38:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JoshuaIn](https://avatars.discourse-cdn.com/v4/letter/j/59ef9b/32.png) [@JoshuaIn](https://discuss.elastic.co/u/JoshuaIn)\
**Post date:** [April 11, 2018, 6:38pm UTC](https://discuss.elastic.co/t/elasticsearch-query-to-search-word-occurred-as-n-times-in-document/127688/1 "2018-04-11T18:38:18Z")

</div>

Is it possible to query in elasticsearch if i want certain word to be occurred more than n times. For e.g. I want to search for word "Bill Gate" only if "Bill Gate" is present more than or equal to 3 times in a document.  
I am storing field name as "content" which is type text that stores the full text of the story. Within this field I want to search for "Bill Gates" and return only those document that has "Bill Gates" word occurred more than or equal to 3 times.

I need to build query that will be generated dynamically based on no of occurrences user want to search for specific words within the content field.

Is this possible in elasticsearch. I tried searching lot on forum including stackoverflow but i couldnt find any solution/answers to my questions. I may be missing something here. Meanwhile am using elasticsearch version 6.2

Any help would be greatly appreciated. Please anyone!

---

<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 9, 2018, 6:38pm UTC](https://discuss.elastic.co/t/elasticsearch-query-to-search-word-occurred-as-n-times-in-document/127688/2 "2018-05-09T18:38:19Z")

</div>

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