diff --git a/src/index.ts b/src/index.ts index 3de13a5..e8e2a45 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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 { 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 { minScore: opts.minScore, explain: opts.explain, intent: opts.intent, + candidateLimit: opts.candidateLimit, skipRerank, chunkStrategy: opts.chunkStrategy, }); diff --git a/src/mcp/server.ts b/src/mcp/server.ts index 096fd82..c999ceb 100644 --- a/src/mcp/server.ts +++ b/src/mcp/server.ts @@ -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, }); diff --git a/test/sdk.test.ts b/test/sdk.test.ts index b60e9e7..53764c5 100644 --- a/test/sdk.test.ts +++ b/test/sdk.test.ts @@ -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 () => {