# Combining proximity with min number of words

**URL:** <https://discuss.elastic.co/t/combining-proximity-with-min-number-of-words/254283>\
**Category:** Elasticsearch\
**Created:** [November 4, 2020, 2:18pm UTC](https://discuss.elastic.co/t/combining-proximity-with-min-number-of-words/254283 "2020-11-04T14:18:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![flm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flm/32/3169_2.png) [@flm](https://discuss.elastic.co/u/flm)\
**Post date:** [November 4, 2020, 2:18pm UTC](https://discuss.elastic.co/t/combining-proximity-with-min-number-of-words/254283/1 "2020-11-04T14:18:33Z")

</div>

Is there a way to create a query to match a minimum number of words from a sentence, with the additional condition that the matching words must be at a maximum total distance from each other?

Here's an example:

Searching for "There are many science fiction and fantasy geeks." with minimum 3 words and max distance 6 would match:  
"He was a **science**  **fiction** and **fantasy** lover."  
but not:  
"In a **science**  **fiction** story, the world is presented as being scientifically possible, while a science **fantasy** world contains elements which violate the scientific laws of the real world."

---

<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:** [December 2, 2020, 2:18pm UTC](https://discuss.elastic.co/t/combining-proximity-with-min-number-of-words/254283/2 "2020-12-02T14:18:35Z")

</div>

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