Skip to content

Commit

Permalink
handle negative values in ranking field (#3450)
Browse files Browse the repository at this point in the history
really should not have negative values,
but trigger counters need to be fixed to avoid bad data
in a later commit.
  • Loading branch information
stereosteve authored Jul 13, 2022
1 parent 923fed8 commit 27b598f
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions discovery-provider/src/queries/search_es.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,16 +365,11 @@ def personalize_dsl(dsl, current_user_id, must_saved):
def default_function_score(dsl, ranking_field):
return {
"query": {
"function_score": {
"script_score": {
"query": {"bool": dsl},
"functions": [
{
"field_value_factor": {
"field": ranking_field,
"modifier": "ln2p",
}
},
],
"script": {
"source": f" Math.log(Math.max(doc['{ranking_field}'].value, 0) + 2)"
},
}
},
}
Expand Down

0 comments on commit 27b598f

Please sign in to comment.