Do not drop strictly competitive boundary candidates in filtered HNSW search#16409
Open
Incheonkirin wants to merge 2 commits into
Open
Do not drop strictly competitive boundary candidates in filtered HNSW search#16409Incheonkirin wants to merge 2 commits into
Incheonkirin wants to merge 2 commits into
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
FilteredHnswGraphSearchercan stop before exploring a candidate whose score is equal to the current result floor, and it rejects neighbors whose score is exactlyMath.nextUp(results.minCompetitiveSimilarity()).The latter score is strictly better than the current minimum and is competitive. The base
HnswGraphSearcheralready handles both boundaries:>to>=because a score equal toMath.nextUp(minCompetitiveSimilarity)is better.The filtered searcher was added before those follow-ups and retained the earlier boundary behavior. This change applies the same contract to the filtered path:
minAcceptedSimilarity;maxScore > results.minCompetitiveSimilarity(), the same bound the base searcher uses;Regression tests
Both tests call
FilteredHnswGraphSearcherdirectly, so they do not depend on the filtered-search dispatch heuristic.The first test uses a four-node graph with two accepted nodes and
k=1. The entry node scores0.5; its accepted neighbor scoresMath.nextUp(0.5). Before this change, filtered HNSW returns the0.5entry and never considers the strictly better neighbor. After the change, it returns the neighbor.The second test searches a chain where every node has the same score and asserts that visitation stays bounded: one candidate tied with the current minimum may be explored, then the search stops.
Validation
./gradlew :lucene:core:checkpasses: 8,534 tests, 307 skippedRelated history: #14160, #14215, #14249, #14366, #15500.