# Proximity between more than 2 words

**URL:** <https://discuss.elastic.co/t/proximity-between-more-than-2-words/60503>\
**Category:** Elasticsearch\
**Created:** [September 14, 2016, 12:26pm UTC](https://discuss.elastic.co/t/proximity-between-more-than-2-words/60503 "2016-09-14T12:26:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nivke2000](https://avatars.discourse-cdn.com/v4/letter/n/a88e4f/32.png) [@nivke2000](https://discuss.elastic.co/u/nivke2000)\
**Post date:** [September 14, 2016, 12:26pm UTC](https://discuss.elastic.co/t/proximity-between-more-than-2-words/60503/1 "2016-09-14T12:26:03Z")

</div>

Hi,

If I write the query "fox brown"~5, i will get results in which those words are no more than 5 words apart.

Can I also write a query "fox brown fast"~5? If so, which results shall be returned?

Thanks,

Niv

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [September 14, 2016, 1:35pm UTC](https://discuss.elastic.co/t/proximity-between-more-than-2-words/60503/2 "2016-09-14T13:35:55Z")

</div>

Hi,

Why not just try it out with some sample data? I just did and it seems like the slop factor (the ~5) account for the maximum number of other tokens allowed in the phrase (other than the ones specified in the query):

```auto
PUT /slop/test/1
{
  "text": "the fox one two three brown four five fast"
}

PUT /slop/test/2
{
  "text": "the fox one two three brown four five six fast"
}

GET /slop/test/_search
{
  "query": { "simple_query_string": {
    "query": "\"fox brown fast\"~5",
    "fields": ["text"]
  }}
}

==>

"hits": {
    "total": 1,
    "max_score": 0.27927625,
    "hits": [
      {
        "_index": "slop",
        "_type": "test",
        "_id": "4",
        "_score": 0.27927625,
        "_source": {
          "text": "the fox one two three brown four five fast"
        }
      }
    ]
  }

```

So the last query matches `fox one two three brown four five fast` (doc1) but not if you put six token enywhere inbetween tokens in the phrase

---

<div class="post-metadata">

**Author:** ![nivke2000](https://avatars.discourse-cdn.com/v4/letter/n/a88e4f/32.png) [@nivke2000](https://discuss.elastic.co/u/nivke2000)\
**Post date:** [September 14, 2016, 1:40pm UTC](https://discuss.elastic.co/t/proximity-between-more-than-2-words/60503/3 "2016-09-14T13:40:15Z")

</div>

Hey,

Thanks for your answer.  
I am researching this search engine, but unfortunately don't have it install on my machine.  
Tried to install it, but it got complicated, so I thought I can get help here.

---

<div class="post-metadata">

**Author:** ![cbuescher](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cbuescher/32/60402_2.png) [@cbuescher](https://discuss.elastic.co/u/cbuescher)\
**Post date:** [September 14, 2016, 1:41pm UTC](https://discuss.elastic.co/t/proximity-between-more-than-2-words/60503/4 "2016-09-14T13:41:30Z")

</div>

You can get help installing it if you like 😉

---

<div class="post-metadata">

**Author:** ![nivke2000](https://avatars.discourse-cdn.com/v4/letter/n/a88e4f/32.png) [@nivke2000](https://discuss.elastic.co/u/nivke2000)\
**Post date:** [September 14, 2016, 1:43pm UTC](https://discuss.elastic.co/t/proximity-between-more-than-2-words/60503/5 "2016-09-14T13:43:27Z")

</div>

Thanks.  
For my current needs, this was easier.  
If I see I need further experiments I will ask for installation help 😃

---

<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:** [July 5, 2017, 10:20pm UTC](https://discuss.elastic.co/t/proximity-between-more-than-2-words/60503/6 "2017-07-05T22:20:17Z")

</div>


