Fix VectorScorer#bulk eagerly advancing its iterator#16377
Open
michaeljmarshall wants to merge 1 commit into
Open
Fix VectorScorer#bulk eagerly advancing its iterator#16377michaeljmarshall wants to merge 1 commit into
michaeljmarshall wants to merge 1 commit into
Conversation
The default bulk() implementation advanced its iterator as a side
effect of construction, unlike Bulk.fromRandomScorerDense/Sparse,
which defer positioning to the first nextDocsAndScores call. Move
the positioning into the returned Bulk to match, and update the
javadoc.
The current behavior is problematic when combining the iterator
with others via conjunction. Given that this API is evolving
and the behavior is split I propose adopting the lazy behavior.
In one case, I hit the following error:
Caused by: java.lang.IllegalArgumentException: Sub-iterators of ConjunctionDISI are not on the same document!
at ConjunctionDISI.throwSubIteratorsNotOnSameDocument(ConjunctionDISI.java:149)
at ConjunctionDISI.createConjunction(ConjunctionDISI.java:104)
at ConjunctionUtils.intersectScorers(ConjunctionUtils.java:44)
at ConjunctionScorer.<init>(ConjunctionScorer.java:36)
at BooleanScorerSupplier.requiredBulkScorer(BooleanScorerSupplier.java:453)
at BooleanScorerSupplier.booleanScorer(BooleanScorerSupplier.java:219)
at BooleanScorerSupplier.bulkScorer(BooleanScorerSupplier.java:177)
The tests don't hit this error because it's trivial to confirm
that the bulk call is side effect free.
michaeljmarshall
added a commit
to carlosdelest/elasticsearch
that referenced
this pull request
Jul 8, 2026
Build the bulk scorer lazily; building it eagerly broke conjunctions with sibling filter clauses. Test added in this commit failed without the change. See apache/lucene#16377.
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
The default bulk() implementation advanced its iterator as a side effect of construction, unlike Bulk.fromRandomScorerDense/Sparse, which defer positioning to the first nextDocsAndScores call. Move the positioning into the returned Bulk to match, and update the javadoc.
The current behavior is problematic when combining the iterator with others via conjunction. Given that this API is evolving and the behavior is split I propose adopting the lazy behavior.
In one case, I hit the following error:
The tests don't hit this error because it's trivial to confirm that the bulk call is side effect free.