Use reciprocal ranking fusion to combine the results of two queries

Hi everyone,
I'm trying to use reciprocal ranking fusion (RRF) to combine the results of two query performed with the following code:

GET /books_index/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "title": "the"
          }
        },
        {
          "match": {
            "description": "in"
          }
        }
      ]
    }
  }
}

In practice what I need to do is returning a single list of document based on the new score obtained by computing the RRF of each document.

The new score of each document should be: 1/(document position in the result list of the query on title) + 1/(document position in the result list of the query on description).

Maybe it can be done with scripted_metric? But I do not know how.
I was also thinking on using aggregation, but I did not succeeded.

I have found that there is an open pull request.

There is no way to get it with function_score/script_score?

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