Fix incorrect position increment generated by FixedShingleFilter - #16577
Draft
kkharbas wants to merge 2 commits into
Draft
Fix incorrect position increment generated by FixedShingleFilter#16577kkharbas wants to merge 2 commits into
kkharbas wants to merge 2 commits into
Conversation
kkharbas
force-pushed
the
fix/fixed-shingle-filter-pos-incr
branch
from
August 28, 2026 20:25
bd9782c to
da39af1
Compare
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.
Summary
FixedShingleFiltercould emit shingles with an incorrect position increment when a route in the graph cannot form a shingle, but another route can. In that case, after reseting the base token, the position increment is set to0since its an alternate path. However this is incorrect if the previous route did not generate any token.Example: For
FixedShingleFilter("Secure Wi-Fi:2/Wi, Fi", 2)withWi-Fias base token, the first route does not yield token, the next route withWiincorrectly uses position increment = 0Fix
pendingPosIncto accumulate position increments from base tokens that don't produce a shingle, so the next emitted shingle carries the full, correct increment.end()override to fold any remainingpendingPosIncinto the final position increment reported byTokenStream.end().reset()override to clearpendingPosIncon reuse.testPositionIncrementAfterSkippedGraphTokenandtestFirstShinglePositionIncrementAfterSkippedGraphToken) that reproduce the bug and verify the fix.Testing
./gradlew :lucene:analysis:common:test --tests "*.TestFixedShingleFilter"passesFixedShingleFiltertests continue to pass unchanged