Scoring - Elasticsearch 权威指南中文版

返回介绍

Scoring

发布于 2019-07-04 字数 1553 浏览 718 评论 0

=== Closer Is Better

Whereas a phrase query simply excludes documents that don’t contain the exact
query phrase, a proximity query—a (((“proximity matching”, “proximity queries”)))(((“slop parameter”, “proximity queries and”)))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(((“relevance scores”, “for proximity queries”))) in which the words are nearer to each other:

[source,js]

POST /my_index/my_type/_search { “query”: { “match_phrase”: { “title”: { “query”: “quick dog”, “slop”: 50 } } } }

// SENSE: 120_Proximity_Matching/20_Scoring.json

Note the high `slop` value.

[source,js]

{ “hits”: [ { “_id”: “3”, “_score”: 0.75, “_source”: { “title”: “The quick brown fox jumps over the quick dog” } }, { “_id”: “2”, “_score”: 0.28347334, “_source”: { “title”: “The quick brown fox jumps over the lazy dog” } } ] }

Higher score because `quick` and `dog` are close together
Lower score because `quick` and `dog` are further apart

上一篇:Multi value fields

下一篇:Relevance

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!