CLOUDP-415919 - Backports WANDScorer and leading wildcard query fixes to 10.4.0 - #20
Merged
Conversation
Lucene apache#13408 (released in 10.0) dropped a guard in BooleanScorerSupplier.optionalBulkScorer that previously kept TOP_SCORES + minShouldMatch > 1 queries on WANDScorer. As a side effect, when matches are dense, dispatch now lands on BooleanScorer, which has no top-K impact pruning — causing 10–100× latency regressions on pure-should compound queries with minimumShouldMatch > 1.
MultiTermQuery constant-score wrapper now defers term collection to ScorerSupplier#get() for queries with an unknown term count (automaton queries such as wildcard/regexp/prefix/range), instead of scanning the term dictionary while building the ScorerSupplier. This keeps the ScorerSupplier "planning" phase cheap so a parent conjunction can short-circuit (e.g. a sibling clause matching no documents) before a non-seekable scan, such as a leading wildcard, runs. If the term dictionary is large and a leading wildcard query matches very few times (<16 (BOOLEAN_REWRITE_TERM_COUNT_THRESHOLD)), using lazy instead of eager evaluation could save a lot of unnecessary term collection.
txwei
marked this pull request as ready for review
June 22, 2026 20:09
mccullocht
approved these changes
Jun 22, 2026
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
This PR backports commits 01a6272 and 8c5a4be