Merge pull request #643 from woodenriver05/fix-candidate-limit-forwarding

Forward candidateLimit through search APIs
This commit is contained in:
Tobias Lütke 2026-05-16 13:10:44 -04:00 committed by GitHub
commit 7a7c6ed9e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 0 deletions

View File

@ -159,6 +159,8 @@ export interface SearchOptions {
collections?: string[];
/** Max results (default: 10) */
limit?: number;
/** Max candidates to rerank (default: 40) */
candidateLimit?: number;
/** Minimum score threshold */
minScore?: number;
/** Include explain traces */
@ -402,6 +404,7 @@ export async function createStore(options: StoreOptions): Promise<QMDStore> {
minScore: opts.minScore,
explain: opts.explain,
intent: opts.intent,
candidateLimit: opts.candidateLimit,
skipRerank,
chunkStrategy: opts.chunkStrategy,
});
@ -414,6 +417,7 @@ export async function createStore(options: StoreOptions): Promise<QMDStore> {
minScore: opts.minScore,
explain: opts.explain,
intent: opts.intent,
candidateLimit: opts.candidateLimit,
skipRerank,
chunkStrategy: opts.chunkStrategy,
});

View File

@ -328,6 +328,7 @@ Intent-aware lex (C++ performance, not sports):
collections: effectiveCollections.length > 0 ? effectiveCollections : undefined,
limit,
minScore,
candidateLimit,
rerank,
intent,
});
@ -689,6 +690,7 @@ export async function startMcpHttpServer(
collections: effectiveCollections.length > 0 ? effectiveCollections : undefined,
limit: params.limit ?? 10,
minScore: params.minScore ?? 0,
candidateLimit: params.candidateLimit,
intent: params.intent,
rerank: params.rerank,
});

View File

@ -614,6 +614,20 @@ describe("search (unified API)", () => {
expect(results.length).toBeGreaterThan(0);
});
test("search() forwards candidateLimit to structured search", async () => {
const results = await store.search({
queries: [
{ type: "lex", query: "authentication" },
{ type: "lex", query: "meeting" },
],
limit: 5,
candidateLimit: 1,
rerank: false,
});
expect(results).toHaveLength(1);
});
// Tests below use search({ query: ... }) which triggers LLM query expansion
describe.skipIf(!!process.env.CI)("with LLM query expansion", () => {
test("search() with query and rerank:false returns results", async () => {