Boosting query
返回與positive
匹配的文檔,同時減小與negative
查詢匹配的文檔的相關性得分。html
能夠使用boosting
查詢降級某些文檔,而不將它們從搜索結果中排除。app
示例查詢
GET /_search { "query": { "boosting": { "positive": { "term": { "text": "apple" } }, "negative": { "term": { "text": "pie tart fruit crumble tree" } }, "negative_boost": 0.5 } } }
boosting 的 Top-level 參數
positive
elasticsearch
(必須,查詢對象)您但願運行的查詢。任何返回的文檔都必須匹配此查詢。ide
nagative
ui
(必須, 查詢對象)用來下降匹配文檔的相關性得分的查詢。code
若是返回的文檔匹配positive
查詢和此查詢,boosting
查詢將計算該文檔的最終相關性得分,以下所示:htm
-
從
positive
查詢中取原始的相關性分數。對象 -
將分數乘以
negative_boost
值。文檔
negative_boost
get
(Required, float) 0到1.0之間的浮點數,用於下降與negative
查詢匹配的文檔的相關性得分。
參考:Elasticsearch官方文檔:Boosting query