Skip to content

Filter deferred points sparse search - #8299

Merged
JojiiOfficial merged 4 commits into
devfrom
filter-deferred-points-sparse-search
Mar 11, 2026
Merged

JojiiOfficial merged 4 commits into
devfrom
filter-deferred-points-sparse-search

Conversation

@JojiiOfficial

Copy link
Copy Markdown
Member

Depends on #8283

Implements efficient filtering of deferred points in sparse vector search.

@JojiiOfficial
JojiiOfficial force-pushed the filter-deferred-points-sparse-search branch from 567a56f to 6d8c036 Compare March 5, 2026 15:57
@IvanPleshkov IvanPleshkov added this to the deferred updates milestone Mar 5, 2026
@JojiiOfficial
JojiiOfficial force-pushed the filter-deferred-points-in-read-op branch from c761a90 to b1f3f8b Compare March 6, 2026 11:27
@JojiiOfficial
JojiiOfficial force-pushed the filter-deferred-points-sparse-search branch from c44e937 to 13eeb9e Compare March 6, 2026 11:32
@IvanPleshkov
IvanPleshkov self-requested a review March 6, 2026 14:24
@IvanPleshkov
IvanPleshkov force-pushed the filter-deferred-points-in-read-op branch from b1f3f8b to 097c0b8 Compare March 10, 2026 11:01
Comment thread lib/sparse/src/index/search_context.rs Outdated
// Select appropriate last-id by also considering deferred points.
let max_point = self
.deferred_internal_id
.map_or(PointOffsetType::MAX, |defered_id| {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deferred_id :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JojiiOfficial
JojiiOfficial force-pushed the filter-deferred-points-sparse-search branch from 13eeb9e to 8bfe14a Compare March 10, 2026 14:09

@IvanPleshkov IvanPleshkov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked code passes:

SparseVectorIndex::search_scored
SparseVectorIndex::search_plain
SparseVectorIndex::search_sparse
SparseVectorIndex::search_nearest_query
SparseVectorIndex::search_query
VectorIndex::search

The deferred point IDs are covered everywhere. Need approval from @agourlay with additional checks on SearchContext changes. From my side, it looks OK, but I'm not 100% sure

.map_or(PointOffsetType::MAX, |deferred_id| {
// `for_each_till_id` expects the last ID to be included.
// Therefore we have to subtract 1.
deferred_id.saturating_sub(1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If deferred id is equal to Some(0). We're gonna include the first point in the search. I propose to return if the deferred id is zero. In practice, we don't expect such a situation, but we can do it after release for additional safety.

pooled: PooledScoresHandle<'b>, // handle to pooled scores
use_pruning: bool,
hardware_counter: &'a HardwareCounterCell,
deferred_internal_id: Option<PointOffsetType>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can remove SearchContext::deferred_internal_id and patch max_record_id in the constructor. As a result, we may skip all other changes in SearchContext.
For now, it's not critical to fix, let's investigate this thread after release

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me "max_id" always sounds as if this point itself is included. I couldn't find another term that empathizes the exclusion so I decided to name it 'deferred_internal_id'.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can discuss it after the release. As the variant to handle this case, search context creation returns None and the search fallbacks to return nothing

@IvanPleshkov
IvanPleshkov requested a review from agourlay March 10, 2026 15:29
Base automatically changed from filter-deferred-points-in-read-op to dev March 11, 2026 08:18
@JojiiOfficial
JojiiOfficial force-pushed the filter-deferred-points-sparse-search branch from 8bfe14a to ac5706a Compare March 11, 2026 08:22
@coderabbitai

coderabbitai Bot commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fef7cfaf-09c5-4d73-86ff-3b59173f72d8

📥 Commits

Reviewing files that changed from the base of the PR and between 6c2e5ad and ac5706a.

📒 Files selected for processing (7)
  • lib/segment/src/index/sparse_index/sparse_vector_index.rs
  • lib/segment/src/segment/tests.rs
  • lib/sparse/benches/search.rs
  • lib/sparse/src/index/search_context.rs
  • lib/sparse/src/index/tests/hw_counter_test.rs
  • lib/sparse/src/index/tests/indexed_vs_plain_test.rs
  • lib/sparse/src/index/tests/search_context_tests.rs

📝 Walkthrough

Walkthrough

This pull request introduces support for deferred internal IDs across sparse vector indexing and search operations. The changes replace hardcoded None values in filter and query paths with dynamic deferred internal IDs derived from vector_query_context. This is implemented by:

  1. Adding a new deferred_internal_id: Option<PointOffsetType> field and constructor parameter to SearchContext
  2. Updating SearchContext::new call sites across sparse vector index, benchmarks, and tests to accept and propagate this parameter
  3. Modifying search logic in search_context.rs to respect deferred points during posting list iteration, pruning, and batch processing
  4. Extending segment tests with sparse vector configurations and a new test validating deferred point behavior

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • agourlay
  • IvanPleshkov
  • timvisee
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 78.57% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Filter deferred points sparse search' clearly summarizes the main change: implementing filtering of deferred points in sparse vector search operations.
Description check ✅ Passed The description directly relates to the changeset, explaining that it implements efficient filtering of deferred points in sparse vector search, which aligns with the detailed changes across multiple files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch filter-deferred-points-sparse-search

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@JojiiOfficial
JojiiOfficial merged commit e38d3d6 into dev Mar 11, 2026
16 checks passed
@JojiiOfficial
JojiiOfficial deleted the filter-deferred-points-sparse-search branch March 11, 2026 09:09
generall pushed a commit that referenced this pull request Mar 26, 2026
* Implement filtering deferred: Sparse search

* Add tests for deferred sparse vectors

* Clippy

* Review remark
KShivendu pushed a commit that referenced this pull request Mar 30, 2026
* Implement filtering deferred: Sparse search

* Add tests for deferred sparse vectors

* Clippy

* Review remark
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