[英]Is it possible to discard results with higher score than a given threshold in ElasticSearch?
In the same way that there is a min_score
parameter to discard results with small scores, is there a way to discard results with higher score than a given value?就像有一个
min_score
参数来丢弃分数较小的结果一样,有没有办法丢弃分数高于给定值的结果?
I use item price to calculate the score, but I need to do a query that ensures the price is between some limits (max and min).我使用商品价格来计算分数,但我需要进行查询以确保价格介于某些限制(最大值和最小值)之间。 The price is calculated using function_score field function summing several fields.
价格是使用 function_score 字段函数将几个字段相加来计算的。
Cheers.干杯。
My first idea was to use the post_filter with a range query, but the _score is not available in the post_filter我的第一个想法是将 post_filter 与范围查询一起使用,但_score在post_filter 中不可用
But in the meanwhile, as a workaround, just define a script_score in order to exclude higher scores:但与此同时,作为一种解决方法,只需定义一个 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.