Skip to content

BugFix: Fixed Advance() API implementation in Optimized Composite Searchers#2146

Merged
CascadingRadium merged 4 commits into
masterfrom
bugFIx
May 23, 2025
Merged

BugFix: Fixed Advance() API implementation in Optimized Composite Searchers#2146
CascadingRadium merged 4 commits into
masterfrom
bugFIx

Conversation

@CascadingRadium

@CascadingRadium CascadingRadium commented Feb 24, 2025

Copy link
Copy Markdown
Member
  • When using the Advance() API on an IndexSnapshotTermFieldReader, a special replacement mechanism is applied during a Rewind— when the requested document ID is behind the current document ID pointed to by the reader. In such cases, the object itself gets replaced.
  • However, this approach fails when the IndexSnapshotTermFieldReader is created by the optimizeCompositeSearcher method, which is used to construct optimized conjunction or disjunction searchers.
  • The issue arises because the unadornedTermFieldReader is initialized with the term set to <optimization-type> and field set to *. As a result, calling Advance() renders the entire TFR unusable, as it gets replaced by a dummy TFR that no longer functions.
  • This problem occurs specifically when calling Advance() on the unadornedTermFieldReader with an ID less than the current posting ID (triggering the rewind mechanism).
  • The issue is resolved by resetting the underlying unadornedPostingsIteratorBitmap, which effectively achieves the same result as the TFR replacement technique without rendering it unusable.

@CascadingRadium CascadingRadium changed the title BugFIx: Fixed Advance() API implementation in Optimized Composite Searchers BugFix: Fixed Advance() API implementation in Optimized Composite Searchers Feb 24, 2025
@abhinavdangeti

Copy link
Copy Markdown
Member

@CascadingRadium would you add a unit test for the code in question here demonstrating the issue which your commit is meant to address.

@CascadingRadium

CascadingRadium commented Feb 25, 2025

Copy link
Copy Markdown
Member Author

Done, The added test TestUnadornedDisjunctionAdvance fails on master but passes on this branch.

The reason why this issue was uncaught was that the existing implementation does not utilize the Rewind feature.

Thanks.

@abhinavdangeti abhinavdangeti added this to the v2.5.1 milestone Feb 25, 2025
@abhinavdangeti abhinavdangeti modified the milestones: v2.5.1, v2.5.2 Apr 16, 2025
abhinavdangeti
abhinavdangeti previously approved these changes May 22, 2025
@CascadingRadium CascadingRadium merged commit 98577e1 into master May 23, 2025
9 checks passed
@CascadingRadium CascadingRadium deleted the bugFIx branch May 23, 2025 05:58
CascadingRadium added a commit that referenced this pull request Aug 21, 2025
…rchers (#2146)

- When using the `Advance()` API on an `IndexSnapshotTermFieldReader`, a
special replacement mechanism is applied during a `Rewind`— when the
requested document ID is behind the current document ID pointed to by
the reader. In such cases, the object itself gets replaced.
- However, this approach fails when the `IndexSnapshotTermFieldReader`
is created by the `optimizeCompositeSearcher` method, which is used to
construct optimized `conjunction` or `disjunction` searchers.
- The issue arises because the `unadornedTermFieldReader` is initialized
with the `term` set to `<optimization-type>` and `field` set to `*`. As
a result, calling `Advance()` renders the entire `TFR` unusable, as it
gets replaced by a dummy `TFR` that no longer functions.
- This problem occurs specifically when calling `Advance()` on the
`unadornedTermFieldReader` with an ID less than the current posting ID
(triggering the rewind mechanism).
- The issue is resolved by resetting the underlying
`unadornedPostingsIteratorBitmap`, which effectively achieves the same
result as the `TFR` replacement technique without rendering it unusable.
CascadingRadium added a commit that referenced this pull request Sep 3, 2025
- Add a Filter query for Boolean queries, which filters the document set
returned by the
Boolean query itself.
- The filter query does not affect scores, and any document returned by
the Boolean query
must also satisfy the filter query.
- The key difference between using a Filter query and placing an
equivalent query in the
Must clause is that queries in the Must clause contribute to the score.
The Filter
query is intended purely for filtering purposes without modifying the
document scores
set by the base Boolean query.
- Requires a Bug Fix (#2146)
to allow for the usage of the Advanced API in case the FilterQuery is an
optimized
composite searcher.
- Resolves #2037
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants