WARNING: The 2.x versions of Elasticsearch have passed their EOL dates. If you are running a 2.x version, we strongly advise you to upgrade.
This documentation is no longer maintained and may be removed. For the latest information, see the current Elasticsearch documentation.
Closer Is Betteredit
Whereas a phrase query simply excludes documents that don’t contain the exact
query phrase, a proximity query—a phrase query where slop
is greater
than 0
—incorporates the proximity of the query terms into the final
relevance _score
. By setting a high slop
value like 50
or 100
, you can
exclude documents in which the words are really too far apart, but give a higher
score to documents in which the words are closer together.
The following proximity query for quick dog
matches both documents that
contain the words quick
and dog
, but gives a higher score to the
document in which the words are nearer to each other:
POST /my_index/my_type/_search { "query": { "match_phrase": { "title": { "query": "quick dog", "slop": 50 } } } }