應用場景:
希望 包含了 某項內容的結果 不是不出現,
而是 排序靠後。
example :
curl -X GET "localhost:9200/_search?pretty" -H 'Content-Type: application/json' -d'
{
"query": {
"boosting" : {
"positive" : {
"term" : {
"text" : "apple"
}
},
"negative" : {
"term" : {
"text" : "pie tart fruit crumble tree"
}
},
"negative_boost" : 0.5
}
}
}
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.
參考地址
https://www.elastic.co/guide/en/elasticsearch/reference/7.1/query-dsl-boosting-query.html