Is it possible to fetch original query's score in rescore query?


(Yinqiwen) #1

Hi,
I'm implementing a plugin to solve a rank problem which need original score as the base value. I already tried using script but it's slow than expected. Rescore query is faster but seems there is no direct way to fetch the original query's score. Is there any example to fetch it?


(Jimferenczi) #2

You can use a script inside a function score directly in the rescorer:

     "rescore_query" : {
        "function_score" : {
           "script_score": {
              "script": {
                "inline": "_score * ...."
              }
           }
        }
     }

You can access the original score in the script with the special field _score.


(Yinqiwen) #3

Already tried this , the score is always 1.0 which seems is the default match_all query's score for 'function_score' .


(Jimferenczi) #4

Ah right, _score is the score of the rescorer query not the original one, sorry. Then I don't think it's possible, can you open a feature request on ES github repo ?


(Yinqiwen) #5

ok, i'll create one.


(system) #6

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.