fix: forward candidateLimit through search APIs

This commit is contained in:
woodenriver05 2026-05-11 20:25:34 -10:00
parent 746beedb48
commit 3b7e065024
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

@ -331,6 +331,7 @@ Intent-aware lex (C++ performance, not sports):
collections: effectiveCollections.length > 0 ? effectiveCollections : undefined,
limit,
minScore,
candidateLimit,
rerank,
intent,
});
@ -692,6 +693,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 () => {