Closed
Description
Negative scores are not allowed in Lucene 8 so we should make sure that we don't produce any deliberately. The following is an (hopefully) exhaustive list of places where negative values should be forbidden in es 7 and deprecated in 6x:
- Query boosts should always be positive (Disallow negative query boost #34486)
- Field boosts should always be positive.
-
script_score
function should return positive scores. (Forbid negative scores in function_score query #35709) - Scripted similarity should return positive scores. (Add minimal sanity checks to custom/scripted similarities. #33564)
- Custom similarity should return positive scores. (Add minimal sanity checks to custom/scripted similarities. #33564)
Query and field boosts are trivial, negative values can be detected during the parsing of the query. For similarities and scripts we cannot infer easily if the values can be negative or not so we'll have to check scores during query execution and fail the request if a negative score is produced.