-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Reciprocal Rank Fusion to the search API (#93396)
This change at a high level adds global ranking on the coordinating node at the end of query reduction prior to the fetch phase. Individual rank methods are defined in plugins. The first rank plugin added as part of this change is reciprocal rank fusion (RRF). RRF uses a relatively simple formula for merging 1...n results sets together with sum(1/(k+d)) where k is a ranking constant and d is a document's scored position within a result set from a query.
- Loading branch information
Showing
59 changed files
with
4,141 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
pr: 93396 | ||
summary: Add support for Reciprocal Rank Fusion to the search API | ||
area: Ranking | ||
type: feature | ||
issues: [] | ||
highlight: | ||
title: Add support for Reciprocal Rank Fusion (RRF) to the search API | ||
body: |- | ||
This change adds reciprocal rank fusion (RRF) which follows the basic formula | ||
for merging `1...n` sets of results sets together with `sum(1/(k+d))` where `k` | ||
is a ranking constant and `d` is a document's scored position within a result set | ||
from a query. The main advantage of ranking this way is the scores for the sets | ||
of results do not have to be normalized relative to each other because RRF only | ||
relies upon positions within each result set. | ||
The API for this change adds a `rank` top-level element to the search | ||
endpoint. An example: | ||
[source,Java] | ||
---- | ||
{ | ||
"query": { | ||
"match": { | ||
"product": { | ||
"query": "brown shoes" | ||
} | ||
} | ||
}, | ||
"knn": { | ||
"field": "product-vector", | ||
"query_vector": [54, 10, -2], | ||
"k": 20, | ||
"num_candidates": 75 | ||
}, | ||
"rank": { | ||
"rrf": { | ||
"window_size": 100, | ||
"rank_constant": 20 | ||
} | ||
} | ||
} | ||
---- | ||
The above example will execute the search query and the knn search separately. | ||
It will preserve separate result sets up to the point where the queries are | ||
ranked on the coordinating node using RRF. | ||
notable: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[[rrf]] | ||
=== Reciprocal rank fusion | ||
|
||
Reciprocal Rank Fusion (RRF) is a simple method to combine document result sets | ||
from multiple queries where the queries' document scores may be unrelated. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.