@kernl-sdk/turbopuffer 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
1
 
2
- > @kernl-sdk/turbopuffer@0.1.5 build /home/runner/work/kernl/kernl/packages/storage/turbopuffer
2
+ > @kernl-sdk/turbopuffer@0.1.7 build /home/runner/work/kernl/kernl/packages/storage/turbopuffer
3
3
  > tsc && tsc-alias --resolve-full-paths
4
4
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @kernl-sdk/turbopuffer
2
2
 
3
+ ## 0.1.7
4
+
5
+ ### Patch Changes
6
+
7
+ - @kernl-sdk/retrieval@0.1.6
8
+
9
+ ## 0.1.6
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [25e46e7]
14
+ - @kernl-sdk/shared@0.3.1
15
+ - @kernl-sdk/retrieval@0.1.5
16
+
3
17
  ## 0.1.5
4
18
 
5
19
  ### Patch Changes
package/README.md CHANGED
@@ -44,7 +44,7 @@ await docs.upsert({
44
44
  // query with vector search
45
45
  const hits = await docs.query({
46
46
  query: [{ vector: [0.1, 0.2, ...] }],
47
- topK: 10,
47
+ limit: 10,
48
48
  filter: { category: "greeting" },
49
49
  include: ["content", "category"], // fields to include in the response
50
50
  });
@@ -248,7 +248,7 @@ describe("convert", () => {
248
248
  it("encodes vector search query", () => {
249
249
  const result = QUERY.encode({
250
250
  query: [{ vector: [0.1, 0.2, 0.3] }],
251
- topK: 10,
251
+ limit: 10,
252
252
  });
253
253
  expect(result.rank_by).toEqual(["vector", "ANN", [0.1, 0.2, 0.3]]);
254
254
  expect(result.top_k).toBe(10);
@@ -256,7 +256,7 @@ describe("convert", () => {
256
256
  it("encodes text search query", () => {
257
257
  const result = QUERY.encode({
258
258
  query: [{ content: "hello world" }],
259
- topK: 5,
259
+ limit: 5,
260
260
  });
261
261
  expect(result.rank_by).toEqual(["content", "BM25", "hello world"]);
262
262
  expect(result.top_k).toBe(5);
@@ -264,7 +264,7 @@ describe("convert", () => {
264
264
  it("encodes multi-field text search as Sum", () => {
265
265
  const result = QUERY.encode({
266
266
  query: [{ title: "search term" }, { body: "search term" }],
267
- topK: 10,
267
+ limit: 10,
268
268
  });
269
269
  expect(result.rank_by).toEqual([
270
270
  "Sum",
@@ -277,7 +277,7 @@ describe("convert", () => {
277
277
  it("encodes filter", () => {
278
278
  const result = QUERY.encode({
279
279
  query: [{ vector: [0.1] }],
280
- topK: 5,
280
+ limit: 5,
281
281
  filter: { category: { $eq: "news" } },
282
282
  });
283
283
  expect(result.filters).toEqual(["category", "Eq", "news"]);
@@ -285,7 +285,7 @@ describe("convert", () => {
285
285
  it("encodes include fields array", () => {
286
286
  const result = QUERY.encode({
287
287
  query: [{ vector: [0.1] }],
288
- topK: 5,
288
+ limit: 5,
289
289
  include: ["title", "content"],
290
290
  });
291
291
  expect(result.include_attributes).toEqual(["title", "content"]);
@@ -293,7 +293,7 @@ describe("convert", () => {
293
293
  it("encodes include as boolean", () => {
294
294
  const result = QUERY.encode({
295
295
  query: [{ vector: [0.1] }],
296
- topK: 5,
296
+ limit: 5,
297
297
  include: true,
298
298
  });
299
299
  expect(result.include_attributes).toBe(true);
@@ -162,7 +162,7 @@ describe("Filter integration tests", () => {
162
162
  async function queryIds(filter) {
163
163
  const hits = await ns.query({
164
164
  query: [{ vector: QUERY_VECTOR }],
165
- topK: 100,
165
+ limit: 100,
166
166
  filter,
167
167
  });
168
168
  return hits.map((h) => h.id).sort();
@@ -440,7 +440,7 @@ describe("Filter integration tests", () => {
440
440
  it("filtered results have correct field values", async () => {
441
441
  const hits = await ns.query({
442
442
  query: [{ vector: QUERY_VECTOR }],
443
- topK: 100,
443
+ limit: 100,
444
444
  filter: { status: "pending" },
445
445
  include: ["status", "flag", "num"],
446
446
  });
@@ -456,7 +456,7 @@ describe("Filter integration tests", () => {
456
456
  it("complex filter returns expected documents with correct data", async () => {
457
457
  const hits = await ns.query({
458
458
  query: [{ vector: QUERY_VECTOR }],
459
- topK: 100,
459
+ limit: 100,
460
460
  filter: {
461
461
  $and: [{ num: { $gte: 20, $lte: 50 } }, { flag: true }],
462
462
  },
@@ -139,7 +139,7 @@ describe("TurbopufferSearchIndex integration", () => {
139
139
  // Verify via query
140
140
  const hits = await index.query({
141
141
  query: [{ vector: vec }],
142
- topK: 10,
142
+ limit: 10,
143
143
  include: ["category"],
144
144
  });
145
145
  expect(hits.length).toBeGreaterThanOrEqual(1);
@@ -160,7 +160,7 @@ describe("TurbopufferSearchIndex integration", () => {
160
160
  // Verify via query
161
161
  const hits = await index.query({
162
162
  query: [{ vector: vec }],
163
- topK: 10,
163
+ limit: 10,
164
164
  include: ["category"],
165
165
  });
166
166
  const doc = hits.find((h) => h.id === "doc-1");
@@ -188,7 +188,7 @@ describe("TurbopufferSearchIndex integration", () => {
188
188
  // Verify via query with filter
189
189
  const hits = await index.query({
190
190
  query: [{ vector: new Array(384).fill(0.3) }],
191
- topK: 10,
191
+ limit: 10,
192
192
  filter: { category: "test" },
193
193
  include: true,
194
194
  });
@@ -208,7 +208,7 @@ describe("TurbopufferSearchIndex integration", () => {
208
208
  const index = tpuf.index(testIndexId);
209
209
  const hits = await index.query({
210
210
  query: [{ vector: new Array(384).fill(0.1) }],
211
- topK: 5,
211
+ limit: 5,
212
212
  });
213
213
  expect(hits.length).toBeGreaterThan(0);
214
214
  expect(hits[0]).toHaveProperty("id");
@@ -219,7 +219,7 @@ describe("TurbopufferSearchIndex integration", () => {
219
219
  const index = tpuf.index(testIndexId);
220
220
  const hits = await index.query({
221
221
  query: [{ vector: new Array(384).fill(0.1) }],
222
- topK: 5,
222
+ limit: 5,
223
223
  include: ["content", "category"],
224
224
  });
225
225
  expect(hits.length).toBeGreaterThan(0);
@@ -231,7 +231,7 @@ describe("TurbopufferSearchIndex integration", () => {
231
231
  const index = tpuf.index(testIndexId);
232
232
  const hits = await index.query({
233
233
  query: [{ vector: new Array(384).fill(0.3) }],
234
- topK: 10,
234
+ limit: 10,
235
235
  filter: { category: "test" },
236
236
  include: ["category"],
237
237
  });
@@ -244,7 +244,7 @@ describe("TurbopufferSearchIndex integration", () => {
244
244
  const index = tpuf.index(testIndexId);
245
245
  const hits = await index.query({
246
246
  query: [{ vector: new Array(384).fill(0.3) }],
247
- topK: 10,
247
+ limit: 10,
248
248
  filter: {
249
249
  $and: [
250
250
  { category: "test" },
@@ -273,7 +273,7 @@ describe("TurbopufferSearchIndex integration", () => {
273
273
  // Verify it exists
274
274
  let hits = await index.query({
275
275
  query: [{ vector: vec }],
276
- topK: 10,
276
+ limit: 10,
277
277
  filter: { id: "doc-to-delete" },
278
278
  });
279
279
  expect(hits.some((h) => h.id === "doc-to-delete")).toBe(true);
@@ -282,7 +282,7 @@ describe("TurbopufferSearchIndex integration", () => {
282
282
  // Verify it's gone
283
283
  hits = await index.query({
284
284
  query: [{ vector: vec }],
285
- topK: 10,
285
+ limit: 10,
286
286
  filter: { id: "doc-to-delete" },
287
287
  });
288
288
  expect(hits.some((h) => h.id === "doc-to-delete")).toBe(false);
@@ -310,7 +310,7 @@ describe("TurbopufferSearchIndex integration", () => {
310
310
  // Verify they exist
311
311
  let hits = await index.query({
312
312
  query: [{ vector: vec }],
313
- topK: 10,
313
+ limit: 10,
314
314
  filter: { category: "bulk-delete" },
315
315
  });
316
316
  expect(hits.length).toBeGreaterThanOrEqual(2);
@@ -319,7 +319,7 @@ describe("TurbopufferSearchIndex integration", () => {
319
319
  // Verify they're gone
320
320
  hits = await index.query({
321
321
  query: [{ vector: vec }],
322
- topK: 10,
322
+ limit: 10,
323
323
  filter: { category: "bulk-delete" },
324
324
  });
325
325
  expect(hits.some((h) => h.id === "bulk-del-1")).toBe(false);
@@ -149,7 +149,7 @@ describe("Lifecycle edge cases integration tests", () => {
149
149
  // Query and verify final state
150
150
  const hits = await index.query({
151
151
  query: [{ vector: [0.3, 0.3, 0.3, 0.3] }],
152
- topK: 10,
152
+ limit: 10,
153
153
  filter: { id: "overwrite-test" },
154
154
  include: ["content", "count"],
155
155
  });
@@ -167,7 +167,7 @@ describe("Lifecycle edge cases integration tests", () => {
167
167
  await new Promise((r) => setTimeout(r, 500));
168
168
  const hits = await index.query({
169
169
  query: [{ vector: [0.1, 0.1, 0.1, 0.1] }],
170
- topK: 10,
170
+ limit: 10,
171
171
  filter: { id: "minimal-doc" },
172
172
  });
173
173
  expect(hits.some((h) => h.id === "minimal-doc")).toBe(true);
@@ -252,7 +252,7 @@ describe("Lifecycle edge cases integration tests", () => {
252
252
  // Verify exists
253
253
  let hits = await index.query({
254
254
  query: [{ vector: [0.9, 0.9, 0.9, 0.9] }],
255
- topK: 10,
255
+ limit: 10,
256
256
  filter: { id: "to-delete" },
257
257
  });
258
258
  expect(hits.length).toBe(1);
@@ -262,7 +262,7 @@ describe("Lifecycle edge cases integration tests", () => {
262
262
  // Verify gone
263
263
  hits = await index.query({
264
264
  query: [{ vector: [0.9, 0.9, 0.9, 0.9] }],
265
- topK: 10,
265
+ limit: 10,
266
266
  filter: { id: "to-delete" },
267
267
  });
268
268
  expect(hits.length).toBe(0);
@@ -294,7 +294,7 @@ describe("Lifecycle edge cases integration tests", () => {
294
294
  const index = tpuf.index(indexId);
295
295
  const hits = await index.query({
296
296
  query: [{ vector: [0.1, 0.2, 0.3, 0.4] }],
297
- topK: 10,
297
+ limit: 10,
298
298
  });
299
299
  expect(hits).toEqual([]);
300
300
  });
@@ -310,16 +310,16 @@ describe("Lifecycle edge cases integration tests", () => {
310
310
  // Query with filter that matches nothing
311
311
  const hits = await index.query({
312
312
  query: [{ vector: [0.1, 0.1, 0.1, 0.1] }],
313
- topK: 10,
313
+ limit: 10,
314
314
  filter: { id: "nonexistent-id" },
315
315
  });
316
316
  expect(hits).toEqual([]);
317
317
  });
318
- it("topK of 0 throws", async () => {
318
+ it("limit of 0 throws", async () => {
319
319
  const index = tpuf.index(indexId);
320
320
  await expect(index.query({
321
321
  query: [{ vector: [0.1, 0.1, 0.1, 0.1] }],
322
- topK: 0,
322
+ limit: 0,
323
323
  })).rejects.toThrow();
324
324
  });
325
325
  });
@@ -361,7 +361,7 @@ describe("Lifecycle edge cases integration tests", () => {
361
361
  // Query with wrong dimension
362
362
  await expect(index.query({
363
363
  query: [{ vector: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8] }], // 8 dims
364
- topK: 10,
364
+ limit: 10,
365
365
  })).rejects.toThrow();
366
366
  await tpuf.deleteIndex(indexId);
367
367
  });
@@ -183,7 +183,7 @@ describe.sequential("Memory Integration with Turbopuffer", { timeout: 60000 }, (
183
183
  expect(results.length).toBe(1);
184
184
  expect(results[0].document?.id).toBe(id1);
185
185
  });
186
- it("respects topK limit", async () => {
186
+ it("respects limit", async () => {
187
187
  const ns = uid("ns");
188
188
  await agent.memories.create({
189
189
  namespace: ns,
@@ -2,7 +2,7 @@
2
2
  * Comprehensive query modes integration tests.
3
3
  *
4
4
  * Tests vector search, BM25 text search, hybrid queries, fusion modes,
5
- * topK behavior, include semantics, and rank ordering against real Turbopuffer API.
5
+ * limit behavior, include semantics, and rank ordering against real Turbopuffer API.
6
6
  */
7
7
  export {};
8
8
  //# sourceMappingURL=query.integration.test.d.ts.map
@@ -2,7 +2,7 @@
2
2
  * Comprehensive query modes integration tests.
3
3
  *
4
4
  * Tests vector search, BM25 text search, hybrid queries, fusion modes,
5
- * topK behavior, include semantics, and rank ordering against real Turbopuffer API.
5
+ * limit behavior, include semantics, and rank ordering against real Turbopuffer API.
6
6
  */
7
7
  import { describe, it, expect, beforeAll, afterAll } from "vitest";
8
8
  import { TurbopufferSearchIndex } from "../../search.js";
@@ -111,7 +111,7 @@ describe("Query modes integration tests", () => {
111
111
  // Query with basis vector 1 - should match vec-1 best
112
112
  const hits = await index.query({
113
113
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }],
114
- topK: 10,
114
+ limit: 10,
115
115
  });
116
116
  expect(hits.length).toBeGreaterThan(0);
117
117
  expect(hits[0].id).toBe("vec-1");
@@ -120,7 +120,7 @@ describe("Query modes integration tests", () => {
120
120
  // Query with basis vector 2
121
121
  const hits = await index.query({
122
122
  query: [{ vector: [0.0, 1.0, 0.0, 0.0] }],
123
- topK: 10,
123
+ limit: 10,
124
124
  });
125
125
  expect(hits.length).toBeGreaterThan(0);
126
126
  expect(hits[0].id).toBe("vec-2");
@@ -133,35 +133,35 @@ describe("Query modes integration tests", () => {
133
133
  // Query with mix of basis 1 and 2 - should prefer vec-5 which has [0.5, 0.5, 0, 0]
134
134
  const hits = await index.query({
135
135
  query: [{ vector: [0.5, 0.5, 0.0, 0.0] }],
136
- topK: 10,
136
+ limit: 10,
137
137
  });
138
138
  expect(hits.length).toBeGreaterThan(0);
139
139
  expect(hits[0].id).toBe("vec-5");
140
140
  });
141
141
  });
142
142
  // ============================================================
143
- // TOPK BEHAVIOR
143
+ // LIMIT BEHAVIOR
144
144
  // ============================================================
145
- describe("topK behavior", () => {
146
- it("topK smaller than doc count returns exactly topK", async () => {
145
+ describe("limit behavior", () => {
146
+ it("limit smaller than doc count returns exactly limit", async () => {
147
147
  const hits = await index.query({
148
148
  query: [{ vector: [0.5, 0.5, 0.5, 0.5] }],
149
- topK: 3,
149
+ limit: 3,
150
150
  });
151
151
  expect(hits.length).toBe(3);
152
152
  });
153
- it("topK larger than doc count returns all docs", async () => {
153
+ it("limit larger than doc count returns all docs", async () => {
154
154
  const hits = await index.query({
155
155
  query: [{ vector: [0.5, 0.5, 0.5, 0.5] }],
156
- topK: 100,
156
+ limit: 100,
157
157
  });
158
158
  // We have 6 docs
159
159
  expect(hits.length).toBe(6);
160
160
  });
161
- it("topK of 1 returns single best match", async () => {
161
+ it("limit of 1 returns single best match", async () => {
162
162
  const hits = await index.query({
163
163
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }],
164
- topK: 1,
164
+ limit: 1,
165
165
  });
166
166
  expect(hits.length).toBe(1);
167
167
  expect(hits[0].id).toBe("vec-1");
@@ -174,7 +174,7 @@ describe("Query modes integration tests", () => {
174
174
  it("single field text query finds matching docs", async () => {
175
175
  const hits = await index.query({
176
176
  query: [{ title: "neural" }],
177
- topK: 10,
177
+ limit: 10,
178
178
  include: ["title"],
179
179
  });
180
180
  expect(hits.length).toBeGreaterThan(0);
@@ -185,7 +185,7 @@ describe("Query modes integration tests", () => {
185
185
  it("content field text query finds matching docs", async () => {
186
186
  const hits = await index.query({
187
187
  query: [{ content: "transformer" }],
188
- topK: 10,
188
+ limit: 10,
189
189
  include: ["content"],
190
190
  });
191
191
  expect(hits.length).toBeGreaterThan(0);
@@ -195,7 +195,7 @@ describe("Query modes integration tests", () => {
195
195
  it("multi-field text query searches both fields", async () => {
196
196
  const hits = await index.query({
197
197
  query: [{ title: "database" }, { content: "database" }],
198
- topK: 10,
198
+ limit: 10,
199
199
  include: ["title", "content"],
200
200
  });
201
201
  expect(hits.length).toBeGreaterThan(0);
@@ -206,7 +206,7 @@ describe("Query modes integration tests", () => {
206
206
  it("text query with no matches returns empty", async () => {
207
207
  const hits = await index.query({
208
208
  query: [{ content: "xyznonexistentkeyword123" }],
209
- topK: 10,
209
+ limit: 10,
210
210
  });
211
211
  expect(hits.length).toBe(0);
212
212
  });
@@ -218,7 +218,7 @@ describe("Query modes integration tests", () => {
218
218
  it("throws error for vector + text hybrid fusion", async () => {
219
219
  await expect(index.query({
220
220
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }, { content: "search" }],
221
- topK: 10,
221
+ limit: 10,
222
222
  })).rejects.toThrow(/does not support hybrid/);
223
223
  });
224
224
  it("throws error for multi-vector fusion", async () => {
@@ -227,7 +227,7 @@ describe("Query modes integration tests", () => {
227
227
  { vector: [1.0, 0.0, 0.0, 0.0] },
228
228
  { vector: [0.0, 1.0, 0.0, 0.0] },
229
229
  ],
230
- topK: 10,
230
+ limit: 10,
231
231
  })).rejects.toThrow(/does not support multi-vector/);
232
232
  });
233
233
  });
@@ -238,7 +238,7 @@ describe("Query modes integration tests", () => {
238
238
  it("Sum fusion combines multiple BM25 signals", async () => {
239
239
  const hits = await index.query({
240
240
  query: [{ title: "database" }, { content: "database" }],
241
- topK: 10,
241
+ limit: 10,
242
242
  include: ["title", "content"],
243
243
  });
244
244
  expect(hits.length).toBeGreaterThan(0);
@@ -249,7 +249,7 @@ describe("Query modes integration tests", () => {
249
249
  it("Max fusion takes best BM25 signal per doc", async () => {
250
250
  const hits = await index.query({
251
251
  max: [{ title: "neural" }, { content: "neural" }],
252
- topK: 10,
252
+ limit: 10,
253
253
  include: ["title", "content"],
254
254
  });
255
255
  expect(hits.length).toBeGreaterThan(0);
@@ -265,7 +265,7 @@ describe("Query modes integration tests", () => {
265
265
  it("include: true returns all attributes", async () => {
266
266
  const hits = await index.query({
267
267
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }],
268
- topK: 1,
268
+ limit: 1,
269
269
  include: true,
270
270
  });
271
271
  expect(hits.length).toBe(1);
@@ -278,7 +278,7 @@ describe("Query modes integration tests", () => {
278
278
  it("include: false returns only id", async () => {
279
279
  const hits = await index.query({
280
280
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }],
281
- topK: 1,
281
+ limit: 1,
282
282
  include: false,
283
283
  });
284
284
  expect(hits.length).toBe(1);
@@ -289,7 +289,7 @@ describe("Query modes integration tests", () => {
289
289
  it("include: [fields] returns only specified fields", async () => {
290
290
  const hits = await index.query({
291
291
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }],
292
- topK: 1,
292
+ limit: 1,
293
293
  include: ["title", "category"],
294
294
  });
295
295
  expect(hits.length).toBe(1);
@@ -303,7 +303,7 @@ describe("Query modes integration tests", () => {
303
303
  it("include: [] returns only id", async () => {
304
304
  const hits = await index.query({
305
305
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }],
306
- topK: 1,
306
+ limit: 1,
307
307
  include: [],
308
308
  });
309
309
  expect(hits.length).toBe(1);
@@ -319,7 +319,7 @@ describe("Query modes integration tests", () => {
319
319
  it("filter by category", async () => {
320
320
  const hits = await index.query({
321
321
  query: [{ vector: [0.5, 0.5, 0.5, 0.5] }],
322
- topK: 10,
322
+ limit: 10,
323
323
  filter: { category: "ml" },
324
324
  include: ["category"],
325
325
  });
@@ -331,7 +331,7 @@ describe("Query modes integration tests", () => {
331
331
  it("filter by priority range", async () => {
332
332
  const hits = await index.query({
333
333
  query: [{ vector: [0.5, 0.5, 0.5, 0.5] }],
334
- topK: 10,
334
+ limit: 10,
335
335
  filter: { priority: { $gte: 3, $lte: 5 } },
336
336
  include: ["priority"],
337
337
  });
@@ -344,7 +344,7 @@ describe("Query modes integration tests", () => {
344
344
  it("filter with $or", async () => {
345
345
  const hits = await index.query({
346
346
  query: [{ vector: [0.5, 0.5, 0.5, 0.5] }],
347
- topK: 10,
347
+ limit: 10,
348
348
  filter: {
349
349
  $or: [{ category: "ml" }, { category: "search" }],
350
350
  },
@@ -363,7 +363,7 @@ describe("Query modes integration tests", () => {
363
363
  it("results have required fields", async () => {
364
364
  const hits = await index.query({
365
365
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }],
366
- topK: 1,
366
+ limit: 1,
367
367
  });
368
368
  expect(hits.length).toBe(1);
369
369
  expect(hits[0]).toHaveProperty("id");
@@ -375,7 +375,7 @@ describe("Query modes integration tests", () => {
375
375
  it("score is a valid number", async () => {
376
376
  const hits = await index.query({
377
377
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }],
378
- topK: 5,
378
+ limit: 5,
379
379
  });
380
380
  for (const hit of hits) {
381
381
  expect(typeof hit.score).toBe("number");
@@ -161,25 +161,25 @@ describe("QUERY", () => {
161
161
  // QUERY OPTIONS
162
162
  // ============================================================
163
163
  describe("query options", () => {
164
- describe("topK", () => {
165
- it("encodes topK as top_k", () => {
164
+ describe("limit", () => {
165
+ it("encodes limit as top_k", () => {
166
166
  const result = QUERY.encode({
167
167
  query: [{ vector: [0.1] }],
168
- topK: 10,
168
+ limit: 10,
169
169
  });
170
170
  expect(result.top_k).toBe(10);
171
171
  });
172
- it("encodes topK of 1", () => {
172
+ it("encodes limit of 1", () => {
173
173
  const result = QUERY.encode({
174
174
  query: [{ vector: [0.1] }],
175
- topK: 1,
175
+ limit: 1,
176
176
  });
177
177
  expect(result.top_k).toBe(1);
178
178
  });
179
- it("encodes large topK", () => {
179
+ it("encodes large limit", () => {
180
180
  const result = QUERY.encode({
181
181
  query: [{ vector: [0.1] }],
182
- topK: 10000,
182
+ limit: 10000,
183
183
  });
184
184
  expect(result.top_k).toBe(10000);
185
185
  });
@@ -267,7 +267,7 @@ describe("QUERY", () => {
267
267
  it("encodes all options together", () => {
268
268
  const result = QUERY.encode({
269
269
  query: [{ vector: [0.1, 0.2] }],
270
- topK: 20,
270
+ limit: 20,
271
271
  filter: { category: "news" },
272
272
  include: ["title", "summary"],
273
273
  });
@@ -315,14 +315,14 @@ describe("QUERY", () => {
315
315
  // Direct codec call with empty array returns params without rank_by.
316
316
  const result = QUERY.encode({
317
317
  query: [],
318
- topK: 10,
318
+ limit: 10,
319
319
  });
320
320
  expect(result.rank_by).toBeUndefined();
321
321
  expect(result.top_k).toBe(10);
322
322
  });
323
323
  it("returns params without rank_by when no query or max", () => {
324
324
  const result = QUERY.encode({
325
- topK: 10,
325
+ limit: 10,
326
326
  filter: { status: "active" },
327
327
  });
328
328
  expect(result.rank_by).toBeUndefined();
@@ -15,9 +15,9 @@ export const QUERY = {
15
15
  if (signals && signals.length > 0) {
16
16
  params.rank_by = buildRankBy(signals, query.max !== undefined);
17
17
  }
18
- // top K
19
- if (query.topK !== undefined) {
20
- params.top_k = query.topK;
18
+ // limit
19
+ if (query.limit !== undefined) {
20
+ params.top_k = query.limit;
21
21
  }
22
22
  // filters
23
23
  if (query.filter) {
package/dist/search.d.ts CHANGED
@@ -33,7 +33,7 @@ import { TurbopufferConfig } from "./types.js";
33
33
  *
34
34
  * const hits = await docs.query({
35
35
  * query: [{ vector: [0.1, 0.2, ...] }],
36
- * topK: 10,
36
+ * limit: 10,
37
37
  * });
38
38
  * ```
39
39
  */
package/dist/search.js CHANGED
@@ -34,7 +34,7 @@ import { INDEX_SCHEMA, SIMILARITY } from "./convert/index.js";
34
34
  *
35
35
  * const hits = await docs.query({
36
36
  * query: [{ vector: [0.1, 0.2, ...] }],
37
- * topK: 10,
37
+ * limit: 10,
38
38
  * });
39
39
  * ```
40
40
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kernl-sdk/turbopuffer",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Turbopuffer search index adapter for kernl",
5
5
  "keywords": [
6
6
  "kernl",
@@ -31,8 +31,8 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@turbopuffer/turbopuffer": "^0.10.0",
34
- "@kernl-sdk/retrieval": "0.1.4",
35
- "@kernl-sdk/shared": "0.3.0"
34
+ "@kernl-sdk/retrieval": "0.1.6",
35
+ "@kernl-sdk/shared": "0.3.1"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": "^24.10.0",
@@ -41,10 +41,10 @@
41
41
  "tsc-alias": "^1.8.10",
42
42
  "typescript": "5.9.2",
43
43
  "vitest": "^4.0.8",
44
- "@kernl-sdk/ai": "0.3.1",
45
- "@kernl-sdk/pg": "0.1.24",
46
- "@kernl-sdk/protocol": "0.3.0",
47
- "kernl": "0.9.0"
44
+ "@kernl-sdk/ai": "0.3.3",
45
+ "@kernl-sdk/protocol": "0.4.0",
46
+ "@kernl-sdk/pg": "0.1.26",
47
+ "kernl": "0.10.0"
48
48
  },
49
49
  "scripts": {
50
50
  "build": "tsc && tsc-alias --resolve-full-paths",
@@ -296,7 +296,7 @@ describe("convert", () => {
296
296
  it("encodes vector search query", () => {
297
297
  const result = QUERY.encode({
298
298
  query: [{ vector: [0.1, 0.2, 0.3] }],
299
- topK: 10,
299
+ limit: 10,
300
300
  });
301
301
 
302
302
  expect(result.rank_by).toEqual(["vector", "ANN", [0.1, 0.2, 0.3]]);
@@ -306,7 +306,7 @@ describe("convert", () => {
306
306
  it("encodes text search query", () => {
307
307
  const result = QUERY.encode({
308
308
  query: [{ content: "hello world" }],
309
- topK: 5,
309
+ limit: 5,
310
310
  });
311
311
 
312
312
  expect(result.rank_by).toEqual(["content", "BM25", "hello world"]);
@@ -316,7 +316,7 @@ describe("convert", () => {
316
316
  it("encodes multi-field text search as Sum", () => {
317
317
  const result = QUERY.encode({
318
318
  query: [{ title: "search term" }, { body: "search term" }],
319
- topK: 10,
319
+ limit: 10,
320
320
  });
321
321
 
322
322
  expect(result.rank_by).toEqual([
@@ -331,7 +331,7 @@ describe("convert", () => {
331
331
  it("encodes filter", () => {
332
332
  const result = QUERY.encode({
333
333
  query: [{ vector: [0.1] }],
334
- topK: 5,
334
+ limit: 5,
335
335
  filter: { category: { $eq: "news" } },
336
336
  });
337
337
 
@@ -341,7 +341,7 @@ describe("convert", () => {
341
341
  it("encodes include fields array", () => {
342
342
  const result = QUERY.encode({
343
343
  query: [{ vector: [0.1] }],
344
- topK: 5,
344
+ limit: 5,
345
345
  include: ["title", "content"],
346
346
  });
347
347
 
@@ -351,7 +351,7 @@ describe("convert", () => {
351
351
  it("encodes include as boolean", () => {
352
352
  const result = QUERY.encode({
353
353
  query: [{ vector: [0.1] }],
354
- topK: 5,
354
+ limit: 5,
355
355
  include: true,
356
356
  });
357
357
 
@@ -191,7 +191,7 @@ describe("Filter integration tests", () => {
191
191
  async function queryIds(filter: Filter): Promise<string[]> {
192
192
  const hits = await ns.query({
193
193
  query: [{ vector: QUERY_VECTOR }],
194
- topK: 100,
194
+ limit: 100,
195
195
  filter,
196
196
  });
197
197
  return hits.map((h) => h.id).sort();
@@ -518,7 +518,7 @@ describe("Filter integration tests", () => {
518
518
  it("filtered results have correct field values", async () => {
519
519
  const hits = await ns.query({
520
520
  query: [{ vector: QUERY_VECTOR }],
521
- topK: 100,
521
+ limit: 100,
522
522
  filter: { status: "pending" },
523
523
  include: ["status", "flag", "num"],
524
524
  });
@@ -537,7 +537,7 @@ describe("Filter integration tests", () => {
537
537
  it("complex filter returns expected documents with correct data", async () => {
538
538
  const hits = await ns.query({
539
539
  query: [{ vector: QUERY_VECTOR }],
540
- topK: 100,
540
+ limit: 100,
541
541
  filter: {
542
542
  $and: [{ num: { $gte: 20, $lte: 50 } }, { flag: true }],
543
543
  },
@@ -176,7 +176,7 @@ describe("TurbopufferSearchIndex integration", () => {
176
176
  // Verify via query
177
177
  const hits = await index.query({
178
178
  query: [{ vector: vec }],
179
- topK: 10,
179
+ limit: 10,
180
180
  include: ["category"],
181
181
  });
182
182
 
@@ -201,7 +201,7 @@ describe("TurbopufferSearchIndex integration", () => {
201
201
  // Verify via query
202
202
  const hits = await index.query({
203
203
  query: [{ vector: vec }],
204
- topK: 10,
204
+ limit: 10,
205
205
  include: ["category"],
206
206
  });
207
207
 
@@ -233,7 +233,7 @@ describe("TurbopufferSearchIndex integration", () => {
233
233
  // Verify via query with filter
234
234
  const hits = await index.query({
235
235
  query: [{ vector: new Array(384).fill(0.3) }],
236
- topK: 10,
236
+ limit: 10,
237
237
  filter: { category: "test" },
238
238
  include: true,
239
239
  });
@@ -257,7 +257,7 @@ describe("TurbopufferSearchIndex integration", () => {
257
257
 
258
258
  const hits = await index.query({
259
259
  query: [{ vector: new Array(384).fill(0.1) }],
260
- topK: 5,
260
+ limit: 5,
261
261
  });
262
262
 
263
263
  expect(hits.length).toBeGreaterThan(0);
@@ -271,7 +271,7 @@ describe("TurbopufferSearchIndex integration", () => {
271
271
 
272
272
  const hits = await index.query({
273
273
  query: [{ vector: new Array(384).fill(0.1) }],
274
- topK: 5,
274
+ limit: 5,
275
275
  include: ["content", "category"],
276
276
  });
277
277
 
@@ -286,7 +286,7 @@ describe("TurbopufferSearchIndex integration", () => {
286
286
 
287
287
  const hits = await index.query({
288
288
  query: [{ vector: new Array(384).fill(0.3) }],
289
- topK: 10,
289
+ limit: 10,
290
290
  filter: { category: "test" },
291
291
  include: ["category"],
292
292
  });
@@ -302,7 +302,7 @@ describe("TurbopufferSearchIndex integration", () => {
302
302
 
303
303
  const hits = await index.query({
304
304
  query: [{ vector: new Array(384).fill(0.3) }],
305
- topK: 10,
305
+ limit: 10,
306
306
  filter: {
307
307
  $and: [
308
308
  { category: "test" },
@@ -335,7 +335,7 @@ describe("TurbopufferSearchIndex integration", () => {
335
335
  // Verify it exists
336
336
  let hits = await index.query({
337
337
  query: [{ vector: vec }],
338
- topK: 10,
338
+ limit: 10,
339
339
  filter: { id: "doc-to-delete" },
340
340
  });
341
341
  expect(hits.some((h) => h.id === "doc-to-delete")).toBe(true);
@@ -346,7 +346,7 @@ describe("TurbopufferSearchIndex integration", () => {
346
346
  // Verify it's gone
347
347
  hits = await index.query({
348
348
  query: [{ vector: vec }],
349
- topK: 10,
349
+ limit: 10,
350
350
  filter: { id: "doc-to-delete" },
351
351
  });
352
352
  expect(hits.some((h) => h.id === "doc-to-delete")).toBe(false);
@@ -377,7 +377,7 @@ describe("TurbopufferSearchIndex integration", () => {
377
377
  // Verify they exist
378
378
  let hits = await index.query({
379
379
  query: [{ vector: vec }],
380
- topK: 10,
380
+ limit: 10,
381
381
  filter: { category: "bulk-delete" },
382
382
  });
383
383
  expect(hits.length).toBeGreaterThanOrEqual(2);
@@ -388,7 +388,7 @@ describe("TurbopufferSearchIndex integration", () => {
388
388
  // Verify they're gone
389
389
  hits = await index.query({
390
390
  query: [{ vector: vec }],
391
- topK: 10,
391
+ limit: 10,
392
392
  filter: { category: "bulk-delete" },
393
393
  });
394
394
  expect(hits.some((h) => h.id === "bulk-del-1")).toBe(false);
@@ -182,7 +182,7 @@ describe("Lifecycle edge cases integration tests", () => {
182
182
  // Query and verify final state
183
183
  const hits = await index.query({
184
184
  query: [{ vector: [0.3, 0.3, 0.3, 0.3] }],
185
- topK: 10,
185
+ limit: 10,
186
186
  filter: { id: "overwrite-test" },
187
187
  include: ["content", "count"],
188
188
  });
@@ -205,7 +205,7 @@ describe("Lifecycle edge cases integration tests", () => {
205
205
 
206
206
  const hits = await index.query({
207
207
  query: [{ vector: [0.1, 0.1, 0.1, 0.1] }],
208
- topK: 10,
208
+ limit: 10,
209
209
  filter: { id: "minimal-doc" },
210
210
  });
211
211
 
@@ -311,7 +311,7 @@ describe("Lifecycle edge cases integration tests", () => {
311
311
  // Verify exists
312
312
  let hits = await index.query({
313
313
  query: [{ vector: [0.9, 0.9, 0.9, 0.9] }],
314
- topK: 10,
314
+ limit: 10,
315
315
  filter: { id: "to-delete" },
316
316
  });
317
317
  expect(hits.length).toBe(1);
@@ -324,7 +324,7 @@ describe("Lifecycle edge cases integration tests", () => {
324
324
  // Verify gone
325
325
  hits = await index.query({
326
326
  query: [{ vector: [0.9, 0.9, 0.9, 0.9] }],
327
- topK: 10,
327
+ limit: 10,
328
328
  filter: { id: "to-delete" },
329
329
  });
330
330
  expect(hits.length).toBe(0);
@@ -361,7 +361,7 @@ describe("Lifecycle edge cases integration tests", () => {
361
361
 
362
362
  const hits = await index.query({
363
363
  query: [{ vector: [0.1, 0.2, 0.3, 0.4] }],
364
- topK: 10,
364
+ limit: 10,
365
365
  });
366
366
 
367
367
  expect(hits).toEqual([]);
@@ -382,20 +382,20 @@ describe("Lifecycle edge cases integration tests", () => {
382
382
  // Query with filter that matches nothing
383
383
  const hits = await index.query({
384
384
  query: [{ vector: [0.1, 0.1, 0.1, 0.1] }],
385
- topK: 10,
385
+ limit: 10,
386
386
  filter: { id: "nonexistent-id" },
387
387
  });
388
388
 
389
389
  expect(hits).toEqual([]);
390
390
  });
391
391
 
392
- it("topK of 0 throws", async () => {
392
+ it("limit of 0 throws", async () => {
393
393
  const index = tpuf.index(indexId);
394
394
 
395
395
  await expect(
396
396
  index.query({
397
397
  query: [{ vector: [0.1, 0.1, 0.1, 0.1] }],
398
- topK: 0,
398
+ limit: 0,
399
399
  }),
400
400
  ).rejects.toThrow();
401
401
  });
@@ -453,7 +453,7 @@ describe("Lifecycle edge cases integration tests", () => {
453
453
  await expect(
454
454
  index.query({
455
455
  query: [{ vector: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8] }], // 8 dims
456
- topK: 10,
456
+ limit: 10,
457
457
  }),
458
458
  ).rejects.toThrow();
459
459
 
@@ -229,7 +229,7 @@ describe.sequential(
229
229
  expect(results[0].document?.id).toBe(id1);
230
230
  });
231
231
 
232
- it("respects topK limit", async () => {
232
+ it("respects limit", async () => {
233
233
  const ns = uid("ns");
234
234
 
235
235
  await agent.memories.create({
@@ -2,7 +2,7 @@
2
2
  * Comprehensive query modes integration tests.
3
3
  *
4
4
  * Tests vector search, BM25 text search, hybrid queries, fusion modes,
5
- * topK behavior, include semantics, and rank ordering against real Turbopuffer API.
5
+ * limit behavior, include semantics, and rank ordering against real Turbopuffer API.
6
6
  */
7
7
 
8
8
  import { describe, it, expect, beforeAll, afterAll } from "vitest";
@@ -138,7 +138,7 @@ describe("Query modes integration tests", () => {
138
138
  // Query with basis vector 1 - should match vec-1 best
139
139
  const hits = await index.query({
140
140
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }],
141
- topK: 10,
141
+ limit: 10,
142
142
  });
143
143
 
144
144
  expect(hits.length).toBeGreaterThan(0);
@@ -149,7 +149,7 @@ describe("Query modes integration tests", () => {
149
149
  // Query with basis vector 2
150
150
  const hits = await index.query({
151
151
  query: [{ vector: [0.0, 1.0, 0.0, 0.0] }],
152
- topK: 10,
152
+ limit: 10,
153
153
  });
154
154
 
155
155
  expect(hits.length).toBeGreaterThan(0);
@@ -165,7 +165,7 @@ describe("Query modes integration tests", () => {
165
165
  // Query with mix of basis 1 and 2 - should prefer vec-5 which has [0.5, 0.5, 0, 0]
166
166
  const hits = await index.query({
167
167
  query: [{ vector: [0.5, 0.5, 0.0, 0.0] }],
168
- topK: 10,
168
+ limit: 10,
169
169
  });
170
170
 
171
171
  expect(hits.length).toBeGreaterThan(0);
@@ -174,33 +174,33 @@ describe("Query modes integration tests", () => {
174
174
  });
175
175
 
176
176
  // ============================================================
177
- // TOPK BEHAVIOR
177
+ // LIMIT BEHAVIOR
178
178
  // ============================================================
179
179
 
180
- describe("topK behavior", () => {
181
- it("topK smaller than doc count returns exactly topK", async () => {
180
+ describe("limit behavior", () => {
181
+ it("limit smaller than doc count returns exactly limit", async () => {
182
182
  const hits = await index.query({
183
183
  query: [{ vector: [0.5, 0.5, 0.5, 0.5] }],
184
- topK: 3,
184
+ limit: 3,
185
185
  });
186
186
 
187
187
  expect(hits.length).toBe(3);
188
188
  });
189
189
 
190
- it("topK larger than doc count returns all docs", async () => {
190
+ it("limit larger than doc count returns all docs", async () => {
191
191
  const hits = await index.query({
192
192
  query: [{ vector: [0.5, 0.5, 0.5, 0.5] }],
193
- topK: 100,
193
+ limit: 100,
194
194
  });
195
195
 
196
196
  // We have 6 docs
197
197
  expect(hits.length).toBe(6);
198
198
  });
199
199
 
200
- it("topK of 1 returns single best match", async () => {
200
+ it("limit of 1 returns single best match", async () => {
201
201
  const hits = await index.query({
202
202
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }],
203
- topK: 1,
203
+ limit: 1,
204
204
  });
205
205
 
206
206
  expect(hits.length).toBe(1);
@@ -216,7 +216,7 @@ describe("Query modes integration tests", () => {
216
216
  it("single field text query finds matching docs", async () => {
217
217
  const hits = await index.query({
218
218
  query: [{ title: "neural" }],
219
- topK: 10,
219
+ limit: 10,
220
220
  include: ["title"],
221
221
  });
222
222
 
@@ -231,7 +231,7 @@ describe("Query modes integration tests", () => {
231
231
  it("content field text query finds matching docs", async () => {
232
232
  const hits = await index.query({
233
233
  query: [{ content: "transformer" }],
234
- topK: 10,
234
+ limit: 10,
235
235
  include: ["content"],
236
236
  });
237
237
 
@@ -243,7 +243,7 @@ describe("Query modes integration tests", () => {
243
243
  it("multi-field text query searches both fields", async () => {
244
244
  const hits = await index.query({
245
245
  query: [{ title: "database" }, { content: "database" }],
246
- topK: 10,
246
+ limit: 10,
247
247
  include: ["title", "content"],
248
248
  });
249
249
 
@@ -256,7 +256,7 @@ describe("Query modes integration tests", () => {
256
256
  it("text query with no matches returns empty", async () => {
257
257
  const hits = await index.query({
258
258
  query: [{ content: "xyznonexistentkeyword123" }],
259
- topK: 10,
259
+ limit: 10,
260
260
  });
261
261
 
262
262
  expect(hits.length).toBe(0);
@@ -272,7 +272,7 @@ describe("Query modes integration tests", () => {
272
272
  await expect(
273
273
  index.query({
274
274
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }, { content: "search" }],
275
- topK: 10,
275
+ limit: 10,
276
276
  }),
277
277
  ).rejects.toThrow(/does not support hybrid/);
278
278
  });
@@ -284,7 +284,7 @@ describe("Query modes integration tests", () => {
284
284
  { vector: [1.0, 0.0, 0.0, 0.0] },
285
285
  { vector: [0.0, 1.0, 0.0, 0.0] },
286
286
  ],
287
- topK: 10,
287
+ limit: 10,
288
288
  }),
289
289
  ).rejects.toThrow(/does not support multi-vector/);
290
290
  });
@@ -298,7 +298,7 @@ describe("Query modes integration tests", () => {
298
298
  it("Sum fusion combines multiple BM25 signals", async () => {
299
299
  const hits = await index.query({
300
300
  query: [{ title: "database" }, { content: "database" }],
301
- topK: 10,
301
+ limit: 10,
302
302
  include: ["title", "content"],
303
303
  });
304
304
 
@@ -311,7 +311,7 @@ describe("Query modes integration tests", () => {
311
311
  it("Max fusion takes best BM25 signal per doc", async () => {
312
312
  const hits = await index.query({
313
313
  max: [{ title: "neural" }, { content: "neural" }],
314
- topK: 10,
314
+ limit: 10,
315
315
  include: ["title", "content"],
316
316
  });
317
317
 
@@ -330,7 +330,7 @@ describe("Query modes integration tests", () => {
330
330
  it("include: true returns all attributes", async () => {
331
331
  const hits = await index.query({
332
332
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }],
333
- topK: 1,
333
+ limit: 1,
334
334
  include: true,
335
335
  });
336
336
 
@@ -345,7 +345,7 @@ describe("Query modes integration tests", () => {
345
345
  it("include: false returns only id", async () => {
346
346
  const hits = await index.query({
347
347
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }],
348
- topK: 1,
348
+ limit: 1,
349
349
  include: false,
350
350
  });
351
351
 
@@ -358,7 +358,7 @@ describe("Query modes integration tests", () => {
358
358
  it("include: [fields] returns only specified fields", async () => {
359
359
  const hits = await index.query({
360
360
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }],
361
- topK: 1,
361
+ limit: 1,
362
362
  include: ["title", "category"],
363
363
  });
364
364
 
@@ -374,7 +374,7 @@ describe("Query modes integration tests", () => {
374
374
  it("include: [] returns only id", async () => {
375
375
  const hits = await index.query({
376
376
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }],
377
- topK: 1,
377
+ limit: 1,
378
378
  include: [],
379
379
  });
380
380
 
@@ -393,7 +393,7 @@ describe("Query modes integration tests", () => {
393
393
  it("filter by category", async () => {
394
394
  const hits = await index.query({
395
395
  query: [{ vector: [0.5, 0.5, 0.5, 0.5] }],
396
- topK: 10,
396
+ limit: 10,
397
397
  filter: { category: "ml" },
398
398
  include: ["category"],
399
399
  });
@@ -407,7 +407,7 @@ describe("Query modes integration tests", () => {
407
407
  it("filter by priority range", async () => {
408
408
  const hits = await index.query({
409
409
  query: [{ vector: [0.5, 0.5, 0.5, 0.5] }],
410
- topK: 10,
410
+ limit: 10,
411
411
  filter: { priority: { $gte: 3, $lte: 5 } },
412
412
  include: ["priority"],
413
413
  });
@@ -422,7 +422,7 @@ describe("Query modes integration tests", () => {
422
422
  it("filter with $or", async () => {
423
423
  const hits = await index.query({
424
424
  query: [{ vector: [0.5, 0.5, 0.5, 0.5] }],
425
- topK: 10,
425
+ limit: 10,
426
426
  filter: {
427
427
  $or: [{ category: "ml" }, { category: "search" }],
428
428
  },
@@ -444,7 +444,7 @@ describe("Query modes integration tests", () => {
444
444
  it("results have required fields", async () => {
445
445
  const hits = await index.query({
446
446
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }],
447
- topK: 1,
447
+ limit: 1,
448
448
  });
449
449
 
450
450
  expect(hits.length).toBe(1);
@@ -458,7 +458,7 @@ describe("Query modes integration tests", () => {
458
458
  it("score is a valid number", async () => {
459
459
  const hits = await index.query({
460
460
  query: [{ vector: [1.0, 0.0, 0.0, 0.0] }],
461
- topK: 5,
461
+ limit: 5,
462
462
  });
463
463
 
464
464
  for (const hit of hits) {
@@ -210,29 +210,29 @@ describe("QUERY", () => {
210
210
  // ============================================================
211
211
 
212
212
  describe("query options", () => {
213
- describe("topK", () => {
214
- it("encodes topK as top_k", () => {
213
+ describe("limit", () => {
214
+ it("encodes limit as top_k", () => {
215
215
  const result = QUERY.encode({
216
216
  query: [{ vector: [0.1] }],
217
- topK: 10,
217
+ limit: 10,
218
218
  });
219
219
 
220
220
  expect(result.top_k).toBe(10);
221
221
  });
222
222
 
223
- it("encodes topK of 1", () => {
223
+ it("encodes limit of 1", () => {
224
224
  const result = QUERY.encode({
225
225
  query: [{ vector: [0.1] }],
226
- topK: 1,
226
+ limit: 1,
227
227
  });
228
228
 
229
229
  expect(result.top_k).toBe(1);
230
230
  });
231
231
 
232
- it("encodes large topK", () => {
232
+ it("encodes large limit", () => {
233
233
  const result = QUERY.encode({
234
234
  query: [{ vector: [0.1] }],
235
- topK: 10000,
235
+ limit: 10000,
236
236
  });
237
237
 
238
238
  expect(result.top_k).toBe(10000);
@@ -342,7 +342,7 @@ describe("QUERY", () => {
342
342
  it("encodes all options together", () => {
343
343
  const result = QUERY.encode({
344
344
  query: [{ vector: [0.1, 0.2] }],
345
- topK: 20,
345
+ limit: 20,
346
346
  filter: { category: "news" },
347
347
  include: ["title", "summary"],
348
348
  });
@@ -405,7 +405,7 @@ describe("QUERY", () => {
405
405
  // Direct codec call with empty array returns params without rank_by.
406
406
  const result = QUERY.encode({
407
407
  query: [],
408
- topK: 10,
408
+ limit: 10,
409
409
  });
410
410
 
411
411
  expect(result.rank_by).toBeUndefined();
@@ -414,7 +414,7 @@ describe("QUERY", () => {
414
414
 
415
415
  it("returns params without rank_by when no query or max", () => {
416
416
  const result = QUERY.encode({
417
- topK: 10,
417
+ limit: 10,
418
418
  filter: { status: "active" },
419
419
  });
420
420
 
@@ -31,9 +31,9 @@ export const QUERY = {
31
31
  params.rank_by = buildRankBy(signals, query.max !== undefined);
32
32
  }
33
33
 
34
- // top K
35
- if (query.topK !== undefined) {
36
- params.top_k = query.topK;
34
+ // limit
35
+ if (query.limit !== undefined) {
36
+ params.top_k = query.limit;
37
37
  }
38
38
 
39
39
  // filters
package/src/search.ts CHANGED
@@ -49,7 +49,7 @@ import { INDEX_SCHEMA, SIMILARITY } from "./convert";
49
49
  *
50
50
  * const hits = await docs.query({
51
51
  * query: [{ vector: [0.1, 0.2, ...] }],
52
- * topK: 10,
52
+ * limit: 10,
53
53
  * });
54
54
  * ```
55
55
  */