Skip to content

fix(local): exclude ids mentioned in prefetches from every prefetch - #1598

Open
digit50 wants to merge 1 commit into
qdrant:devfrom
digit50:fix/prefetch-mentioned-ids
Open

digit50 wants to merge 1 commit into
qdrant:devfrom
digit50:fix/prefetch-mentioned-ids

Conversation

@digit50

@digit50 digit50 commented Oct 16, 2026

Copy link
Copy Markdown

closes #1596

When a prefetch references a point by id, for example NearestQuery(nearest=7) or a RecommendQuery with positive=[7], local mode excluded that id only from the same prefetch. A sibling prefetch could still return it, so it took an RRF rank there and ended up in the fused result. The server excludes ids referenced anywhere in the request from every prefetch.

_resolve_prefetch_input now returns the ids mentioned in its own query and in its nested prefetches, instead of adding them to its own filter. query_points and query_points_groups add these ids, together with the ids mentioned by the root query, to the root query_filter with ignore_mentioned_ids_filter. The existing filter propagation in LocalCollection._prefetch then applies them to every prefetch. Ids looked up from another collection through lookup_from are still not excluded, as before. The async local client has the same change.

The new test in tests/test_in_memory.py runs RRF over an id-referencing prefetch and a plain vector prefetch whose top hit is that id. It covers a NearestQuery prefetch, a RecommendQuery prefetch and a NearestQuery nested one level down, and checks that both query_points and query_points_groups leave the id out and return the same scores as an explicit root must_not has_id filter.

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Local mode excluded a point referenced by a prefetch query only from that prefetch, so a sibling prefetch could still return it and it ended up in the fused result. The ids referenced anywhere in the prefetch tree are now added to the root filter together with the root query's ids, and the existing filter propagation applies them to every prefetch, as the server does.
@digit50
digit50 requested a review from joein as a code owner October 16, 2026 14:24
@netlify

netlify Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for poetic-froyo-8baba7 ready!

Name Link
🔨 Latest commit 01908cf
🔍 Latest deploy log https://app.netlify.com/projects/poetic-froyo-8baba7/deploys/6ad233be43ea726a1d180efa
😎 Deploy Preview https://deploy-preview-1598--poetic-froyo-8baba7.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai

coderabbitai Bot commented Oct 16, 2026

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: af40396b-8301-4e4b-b011-b602f80847b2
📥 Commits

Reviewing files that changed from the base of the PR and between 0eb4d9e and 01908cf.

📒 Files selected for processing: 3
  • qdrant_client/local/async_qdrant_local.py
  • qdrant_client/local/qdrant_local.py
  • tests/test_in_memory.py

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

📝 Walkthrough

The sync and async local clients now collect point IDs referenced by the main query and throughout nested prefetches. They exclude those IDs through the root query filter for point and grouped queries. In-memory tests cover nearest, recommendation, and nested prefetch references under RRF.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to 01908

This change makes local mode exclude point IDs referenced anywhere in the prefetch tree from every prefetch, as the linked issue requests. No merge-blocking risk was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 30.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 3 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: excluding IDs mentioned in prefetches from every prefetch in local mode.
Description check Passed The description directly explains the bug, implementation, affected methods, limitations, and test coverage. It is related to the changeset.
Linked Issues check Passed Direct issue [#1596] requires same-collection IDs referenced by the root query or any prefetch level to be excluded from every prefetch, with RRF behavior equivalent to a root must_not has_id filter…
Out of Scope Changes check Passed The reported changes are limited to local synchronous and asynchronous prefetch resolution, root-filter propagation, and focused in-memory tests. These changes directly implement [#1596]. No unrelated…
Full details: Linked Issues check

Explanation

Direct issue [#1596] requires same-collection IDs referenced by the root query or any prefetch level to be excluded from every prefetch, with RRF behavior equivalent to a root must_not has_id filter. The supplied PR summary reports this flow in both local clients: _resolve_prefetch_input collects IDs recursively, and query_points plus query_points_groups add the IDs to the root filter. The head test adds RRF coverage for NearestQuery, RecommendQuery, and one nested prefetch, and checks both query methods against the expected scores. The summary also preserves the issue scope for lookup_from IDs.

Full details: Out of Scope Changes check

Explanation

The reported changes are limited to local synchronous and asynchronous prefetch resolution, root-filter propagation, and focused in-memory tests. These changes directly implement [#1596]. No unrelated production area or unrelated behavior appears in the supplied change summary. No files are listed as ignored.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

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.

1 participant