-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve explanation in rescore (#30629)
Currently in a rescore request if window_size is smaller than the top N documents returned (N=size), explanation of scores could be incorrect for documents that were a part of topN and not part of rescoring. This PR corrects this by saving in RescoreContext docIDs of documents for which rescoring was applied, and adding rescoring explanation only for these docIDs. Closes #28725
- Loading branch information
1 parent
ec98d15
commit af017d4
Showing
3 changed files
with
77 additions
and
15 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
rest-api-spec/src/main/resources/rest-api-spec/test/search/210_rescore_explain.yml
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,47 @@ | ||
--- | ||
"Score should match explanation in rescore": | ||
- skip: | ||
version: " - 6.2.99" | ||
reason: Explanation for rescoring was corrected after these versions | ||
- do: | ||
indices.create: | ||
index: test_index | ||
body: | ||
settings: | ||
index: | ||
number_of_shards: 1 | ||
number_of_replicas: 0 | ||
- do: | ||
bulk: | ||
refresh: true | ||
body: | ||
- '{"index": {"_index": "test_index", "_type": "_doc", "_id": "1"}}' | ||
- '{"f1": "1"}' | ||
- '{"index": {"_index": "test_index", "_type": "_doc", "_id": "2"}}' | ||
- '{"f1": "2"}' | ||
- '{"index": {"_index": "test_index", "_type": "_doc", "_id": "3"}}' | ||
- '{"f1": "3"}' | ||
|
||
- do: | ||
search: | ||
index: test_index | ||
body: | ||
explain: true | ||
query: | ||
match_all: {} | ||
rescore: | ||
window_size: 2 | ||
query: | ||
rescore_query: | ||
match_all: {} | ||
query_weight: 5 | ||
rescore_query_weight: 10 | ||
|
||
- match: { hits.hits.0._score: 15 } | ||
- match: { hits.hits.0._explanation.value: 15 } | ||
|
||
- match: { hits.hits.1._score: 15 } | ||
- match: { hits.hits.1._explanation.value: 15 } | ||
|
||
- match: { hits.hits.2._score: 5 } | ||
- match: { hits.hits.2._explanation.value: 5 } |
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