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?
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.
Cheers.
My first idea was to use the post_filter with a range query, but the _score is not available in the post_filter
But in the meanwhile, as a workaround, just define a script_score in order to exclude higher scores:
GET _search
{
"query": {
"function_score": {
"query": {
...
},
"script_score" : {
"script" : {
"params": {
"max_score": 10
},
"source": "_score > params.max_score ? 0 : _score"
}
},
"boost_mode": "replace"
}
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.