![](/img/trans.png)
[英]Getting ElasticSearch to score number of total nested hits across results (idf?) higher than tf of single hit?
[英]Is it possible to discard results with higher score than a given threshold in ElasticSearch?
就像有一個min_score
參數來丟棄分數較小的結果一樣,有沒有辦法丟棄分數高於給定值的結果?
我使用商品價格來計算分數,但我需要進行查詢以確保價格介於某些限制(最大值和最小值)之間。 價格是使用 function_score 字段函數將幾個字段相加來計算的。
干杯。
我的第一個想法是將 post_filter 與范圍查詢一起使用,但_score在post_filter 中不可用
但與此同時,作為一種解決方法,只需定義一個 script_score 以排除更高的分數:
GET _search
{
"query": {
"function_score": {
"query": {
...
},
"script_score" : {
"script" : {
"params": {
"max_score": 10
},
"source": "_score > params.max_score ? 0 : _score"
}
},
"boost_mode": "replace"
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.