Add minScore filter across CLI, HTTP, MCP, and web UI#52
Merged
antoninbas merged 1 commit intomainfrom Apr 19, 2026
Merged
Conversation
Expose a score floor for search results, wired through every consumer. Default 0 (no filtering) because the meaningful threshold varies by mode and by corpus — any non-zero default risks hiding legitimate matches on small corpora. Users can opt in; help text documents the per-mode scale. Per-mode behavior: - bm25: searchLex has no minScore option in qmd, so filter post-hoc. - vector: same — searchVector has no minScore option, filter post-hoc. - hybrid: pass minScore to store.search(). qmd applies the filter against the real fused RRF score before overwriting score with 1/(rank+1), so the filter works on real relevance even though we surface the value from explain.rrf.totalScore. Scale documentation (CLI help, MCP description, web UI hint): - bm25: sigmoid of BM25 in [0, 1); ~0.3 weak, ~0.6 medium, ~0.9 strong - vector: cosine similarity in [0, 1]; ~0.3 noise floor, ~0.5 related - hybrid: fused RRF; ~0.02–0.08 for good matches (much smaller scale) HTTP API and CLI validate the value (non-negative finite number) and return 400 / throw on garbage input. Web UI shows a dynamic hint that updates with the selected mode. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Summary
Now that
bm25/vector/hybridall return real relevance scores (PR #51), expose aminScorefloor so callers can drop low-relevance results.Default is 0 (no filtering). A non-zero default would hide legitimate matches on small corpora, and qmd's three modes have different score scales, so there's no single good value.
Surfaces
search({ minScore })— post-hoc filter for bm25/vector (qmd'ssearchLex/searchVectordon't accept it); passed through to qmd for hybrid (qmd filters against the real fused score before the1/rankoverwrite)?minScore=<float>— validated, 400 on garbageknotes search <q> --min-score <n>with per-mode scale docs in--helpknotes_searchtool, same description in the schemaPer-mode scale documented in help text
[0, 1)— ~0.3 weak, ~0.6 medium, ~0.9 strong[0, 1]— ~0.3 noise floor, ~0.5 relatedTest plan
npx vitest run— 146/146 pass (new: minScore threshold test + HTTP validation test)npx tsc --noEmitclean for both backend and frontend