Reputation: 171
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.
Upvotes: 1
Views: 758
Reputation: 3667
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"
}
}
}
Upvotes: 1