Add path filtering and explain metadata to search APIs#665
Open
fa1k3 wants to merge 3 commits into
Open
Conversation
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
Adds folder-scoped search filtering and richer score explanation metadata across qmd search APIs.
Changes
pathPrefixfiltering to SDK/MCP/REST search paths and--path/-pto the CLI.documents.original_pathand use them for user-facing path filtering/results, while keeping existing normalized path compatibility.get, and CLI/SDK multi-get as well, so a path returned by search (for exampleqmd://collection/+Projects/Some Folder/file.md) can be passed back toqmd get, MCP/SDK lookup, and glob multi-get without manually converting to the normalized slug form.pathPrefixfolder-only, case-sensitive, boundary-safe, and slash-normalized:stackmatchesstack/...stackdoes not matchstack0/...orstack-monitor/...Stackandstackremain distinct/behave as no filterexplain.scoreTypeand per-resultexplain.backendSourcesso callers can distinguish RRF-position scores from rerank-blend scores and see whether a result came from BM25 and/or vector evidence./queryJSON handling for malformed JSON and invalidpathPrefix/explaintypes.Semantics
pathPrefixis intentionally folder-scoped, not file-prefix matching. File-like prefixes such asREADME.mdnormalize to a folder prefix and therefore do not match the file itself.Tests
Latest targeted verification after the original-path roundtrip fix:
bun test test/path-filter.test.ts test/score-breakdown.test.ts test/cli.test.ts --timeout 60000 --preload ./src/test-preload.ts— 137 passednpm run test:node -- test/path-filter.test.ts test/score-breakdown.test.ts test/cli.test.ts— 137 passedbun run buildnpm run test:typesEarlier full-suite verification on this PR branch:
npm run test:node -- test/path-filter.test.ts test/score-breakdown.test.ts test/mcp.test.ts— 70 passednpm run test:node— 904 passednpm run test:bun— 904 passed