Skip to content

Fix score_threshold applied backwards for Recommend/Discover/Context on Euclidean/Manhattan collections - #1374

Open
TarunSinghChauhan wants to merge 1 commit into
qdrant:masterfrom
TarunSinghChauhan:fix-score-threshold-backwards-1370
Open

Fix score_threshold applied backwards for Recommend/Discover/Context on Euclidean/Manhattan collections#1374
TarunSinghChauhan wants to merge 1 commit into
qdrant:masterfrom
TarunSinghChauhan:fix-score-threshold-backwards-1370

Conversation

@TarunSinghChauhan

Copy link
Copy Markdown

Fixes #1370. The isinstance override that marks Recommend (best_score/sum_scores), Discover, and Context queries as bigger-is-better was applied to sort direction but not to the score_threshold comparison, causing local-mode queries on Euclidean/Manhattan collections to return zero results for any reasonable threshold. Extracted the check into a single bigger_is_better variable used by both.

…on Euclidean/Manhattan collections

In local/in-memory mode, LocalCollection.search() has an isinstance
override that correctly treats Recommend (best_score/sum_scores),
Discover, and Context queries as bigger-is-better (since they use
sigmoid-based synthetic scores), regardless of the collection's
underlying distance metric. This override was applied to the sort
direction but not repeated for the score_threshold comparison a few
lines below, which branched on required_order alone. On a Euclidean
or Manhattan collection this caused the threshold check to use the
comparison direction meant for raw distances, breaking the loop on
the very first (best-scoring) point and returning zero results for
any non-extreme threshold. Extracted the override into a single
bigger_is_better variable used consistently by both the sort and
the threshold check. Fixes qdrant#1370.
@netlify

netlify Bot commented Aug 25, 2026

Copy link
Copy Markdown

Deploy Preview for poetic-froyo-8baba7 ready!

Name Link
🔨 Latest commit 95ed825
🔍 Latest deploy log https://app.netlify.com/projects/poetic-froyo-8baba7/deploys/6a8d07548870c00008ded1fb
😎 Deploy Preview https://deploy-preview-1374--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 Aug 25, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ec4d90dc-71fc-4f1b-950f-b83507932d97

📥 Commits

Reviewing files that changed from the base of the PR and between 550484d and 95ed825.

📒 Files selected for processing (1)
  • qdrant_client/local/local_collection.py

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

LocalCollection.search now stores score direction in bigger_is_better. The flag covers distance metrics and synthetic scores from recommendation, discovery, and context queries. Score-threshold filtering now uses the same direction as result ordering.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 95ed8

This localized fix corrects score-threshold handling for affected query types; no actionable merge-blocking risk remains beyond normal checks and review.

Suggested reviewers: joein

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the score_threshold bug, affected query types, and affected distance metrics.
Description check ✅ Passed The description accurately explains the root cause and the shared bigger_is_better fix for threshold comparison and sorting.
Linked Issues check ✅ Passed The changes satisfy issue #1370 by applying bigger-is-better threshold semantics to Recommend, Discover, and Context synthetic scores on Euclidean and Manhattan collections.
Out of Scope Changes check ✅ Passed The changes are limited to the described threshold and ordering logic in LocalCollection.search. No unrelated changes are identified.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

score_threshold is applied backwards for Recommend/Discover/Context queries on Euclidean or Manhattan collections (local mode)

1 participant