原文地址: https://www.elastic.co/guide/en/elasticsearch/reference/7.7/query-dsl-boosting-query.html, 原文档版权归 www.elastic.co 所有
IMPORTANT: No additional bug fixes or documentation updates
will be released for this version. For the latest information, see the
current release documentation.
Boosting queryedit
Returns documents matching a positive
query while reducing the
relevance score of documents that also match a
negative
query.
You can use the boosting
query to demote certain documents without
excluding them from the search results.
Example requestedit
GET /_search { "query": { "boosting" : { "positive" : { "term" : { "text" : "apple" } }, "negative" : { "term" : { "text" : "pie tart fruit crumble tree" } }, "negative_boost" : 0.5 } } }
Top-level parameters for boosting
edit
-
positive
- (Required, query object) Query you wish to run. Any returned documents must match this query.
-
negative
-
(Required, query object) Query used to decrease the relevance score of matching documents.
If a returned document matches the
positive
query and this query, theboosting
query calculates the final relevance score for the document as follows:-
Take the original relevance score from the
positive
query. -
Multiply the score by the
negative_boost
value.
-
Take the original relevance score from the
-
negative_boost
-
(Required, float) Floating point number between
0
and1.0
used to decrease the relevance scores of documents matching thenegative
query.