Fix FixedShingleFilter emitting a leading 0 position increment (GITHUB#14137) - #16384
Open
vismaytiwari wants to merge 1 commit into
Open
Fix FixedShingleFilter emitting a leading 0 position increment (GITHUB#14137)#16384vismaytiwari wants to merge 1 commit into
vismaytiwari wants to merge 1 commit into
Conversation
…B#14137) The shingle position increment was taken from the emitting base token, but base positions whose graph routes were too short to form a shingle emitted nothing and their increments were lost. A base reached as a graph alternative can itself carry a 0 increment, so the stream's first shingle could be emitted with posInc=0, which fails indexing with "first position increment must be > 0". Accumulate the base-position increments across bases that emit nothing and apply the total to the next emitted shingle (0 for further routes stacked at the same base), so the first token always keeps a valid increment.
Contributor
|
This PR has not had activity in the past 2 weeks, labeling it as stale. If the PR is waiting for review, notify the dev@lucene.apache.org list. Thank you for your contribution! |
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
Fixes #14137.
With a valid analyzer chain —
StandardTokenizer→WordDelimiterGraphFilter(GENERATE_WORD_PARTS | GENERATE_NUMBER_PARTS | CATENATE_NUMBERS)→FlattenGraphFilter→FixedShingleFilter— indexing input such as555,0throwsIllegalArgumentException: first position increment must be > 0 (got 0). This is the same chain Elasticsearch'ssearch_as_you_typeuses.FixedShingleFiltertook a shingle's position increment from the emitting base token. But when earlier base positions produce no shingle (their graph routes are too short to fill the window) their increments were dropped, and a base reached as a graph alternative can itself carry aposIncof 0 — so the stream's first shingle could be emitted withposInc=0, which the indexer rejects.For
555,0the flattened graph feeding the filter is"5550"(posInc=1),"555"(posInc=0),"0"(posInc=1). The"5550"base can't form a bigram and emits nothing, so the first emitted shingle"555 0"is based at"555"(posInc=0) and inherited that 0.The fix accumulates the base-position increments across bases that emit nothing and applies the total to the next emitted shingle (0 for further graph routes stacked at the same base). So
"555 0"now carries1 + 0 = 1. Normal streams are unchanged: a single base still contributes its own increment, and stacked graph routes at the same base still get 0.Added
TestFixedShingleFilter#testGraphInputDoesNotEmitLeadingZeroPositionIncrement, which builds the reported chain over555,0. It fails onmain(leadingposInc=0) and passes with this change. FullTestFixedShingleFilterand./gradlew tidyare green.