Skip to content

[9.0] Knn vector rescoring to sort score docs (#122653) #122674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 15, 2025

Conversation

javanna
Copy link
Member

@javanna javanna commented Feb 15, 2025

Backports the following commits to 9.0:

RescoreKnnVectorQuery rewrites to KnnScoreDocQuery, which takes a sorted array of
doc ids and corresponding array including scores fo such docs. A binary search is
performed on top of the docs array, and such global ids are converted back to
segment level ids (subtracting the context docbase) when scoring docs.

RescoreKnnVectoryQuery did not sort the array of docs which caused binary search
to return non deterministic results, which in turn made us look up wrong docs,
something using out of bound ids. One symptom of this was observed in a DFSProfilerIT
test failure which triggered a Lucene assertion around doc id being outside of the
range of the bitset of live docs.

The fix is to simply sort the score docs array before extracting docs ids and scores
and providing them to KnnScoreDocQuery upon rewrite.

Relates to elastic#116663

Closes elastic#119711
@javanna javanna added :Search Relevance/Vectors Vector search >bug auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) backport Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch labels Feb 15, 2025
@elasticsearchmachine elasticsearchmachine merged commit 9f3bf64 into elastic:9.0 Feb 15, 2025
16 checks passed
@javanna javanna deleted the backport/9.0/pr-122653 branch February 15, 2025 14:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) backport >bug :Search Relevance/Vectors Vector search Team:Search Relevance Meta label for the Search Relevance team in Elasticsearch v9.0.1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants