@omendb/omendb 0.0.20 → 0.0.21

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.
Files changed (3) hide show
  1. package/index.d.ts +246 -271
  2. package/index.js +4 -4
  3. package/package.json +6 -6
package/index.d.ts CHANGED
@@ -1,229 +1,208 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
3
  export declare class VectorDatabase {
4
- /**
5
- * Insert or update vectors.
6
- *
7
- * Accepts an array of items with id, vector, and optional metadata.
8
- */
9
- set(items: Array<VectorItem>): Array<number>;
10
- /**
11
- * Search for k nearest neighbors.
12
- *
13
- * @param query - Query vector (number[] or Float32Array)
14
- * @param k - Number of results to return
15
- * @param ef - Optional search width override
16
- * @param filter - Optional metadata filter (e.g., {category: "foo"} or {price: {$gt: 10}})
17
- * @param maxDistance - Optional max distance threshold (filter out distant results)
18
- * @returns Array of {id, distance, metadata}
19
- */
20
- search(
21
- query: Array<number> | Float32Array,
22
- k: number,
23
- ef?: number | undefined | null,
24
- filter?: Record<string, unknown> | undefined,
25
- maxDistance?: number | undefined | null,
26
- ): Array<SearchResult>;
27
- /**
28
- * Batch search with parallel execution (async).
29
- *
30
- * Runs searches in parallel using rayon, returns Promise.
31
- */
32
- searchBatch(
33
- queries: Array<Array<number> | Float32Array>,
34
- k: number,
35
- ef?: number | undefined | null,
36
- ): Promise<Array<Array<SearchResult>>>;
37
- /** Get a vector by ID. */
38
- get(id: string): GetResult | null;
39
- /**
40
- * Delete vectors by ID.
41
- *
42
- * @returns Number of vectors deleted
43
- */
44
- delete(ids: Array<string>): number;
45
- /**
46
- * Delete vectors matching a metadata filter.
47
- *
48
- * Evaluates the filter against all vectors and deletes those that match.
49
- * Uses the same MongoDB-style filter syntax as search().
50
- *
51
- * @param filter - MongoDB-style metadata filter
52
- * @returns Number of vectors deleted
53
- *
54
- * @example
55
- * ```javascript
56
- * // Delete by equality
57
- * db.deleteWhere({ status: "archived" });
58
- *
59
- * // Delete with comparison
60
- * db.deleteWhere({ score: { $lt: 0.5 } });
61
- *
62
- * // Complex filter
63
- * db.deleteWhere({ $and: [{ type: "draft" }, { age: { $gt: 30 } }] });
64
- * ```
65
- */
66
- deleteWhere(filter: Record<string, unknown>): number;
67
- /**
68
- * Count vectors, optionally filtered by metadata.
69
- *
70
- * Without a filter, returns total count (same as db.length).
71
- * With a filter, returns count of vectors matching the filter.
72
- *
73
- * @param filter - Optional MongoDB-style metadata filter
74
- * @returns Number of vectors (matching filter if provided)
75
- *
76
- * @example
77
- * ```javascript
78
- * // Total count
79
- * const total = db.count();
80
- *
81
- * // Filtered count
82
- * const active = db.count({ status: "active" });
83
- *
84
- * // With comparison operators
85
- * const highScore = db.count({ score: { $gte: 0.8 } });
86
- * ```
87
- */
88
- count(filter?: Record<string, unknown> | undefined): number;
89
- /** Update a vector's data and/or metadata. */
90
- update(
91
- id: string,
92
- vector: Array<number> | Float32Array,
93
- metadata?: Record<string, unknown> | undefined,
94
- ): void;
95
- /** Get number of vectors in database. */
96
- get length(): number;
97
- /** Get vector dimensions of this database. */
98
- get dimensions(): number;
99
- /** Check if database is empty. */
100
- isEmpty(): boolean;
101
- /** Get database statistics. */
102
- stats(): StatsResult;
103
- /** Get current ef_search value. */
104
- get efSearch(): number;
105
- /** Set ef_search value. */
106
- set efSearch(efSearch: number);
107
- /**
108
- * Get or create a named collection.
109
- *
110
- * Collection handles share state - changes made through one handle
111
- * are immediately visible through another (no flush required).
112
- */
113
- collection(name: string): VectorDatabase;
114
- /** List all collections. */
115
- collections(): Array<string>;
116
- /** Delete a collection. */
117
- deleteCollection(name: string): void;
118
- /**
119
- * Enable text search for hybrid (vector + text) search.
120
- *
121
- * Must be called before using setWithText() or hybridSearch().
122
- */
123
- enableTextSearch(): void;
124
- /** Check if text search is enabled. */
125
- get hasTextSearch(): boolean;
126
- /**
127
- * Set vectors with associated text for hybrid search.
128
- *
129
- * @param items - Array of {id, vector, text, metadata?}
130
- * @returns Array of internal indices
131
- */
132
- setWithText(items: Array<VectorItemWithText>): Array<number>;
133
- /**
134
- * Search using text only (BM25 scoring).
135
- *
136
- * @param query - Text query
137
- * @param k - Number of results
138
- * @returns Array of {id, score, metadata}
139
- */
140
- textSearch(query: string, k: number): Array<TextSearchResult>;
141
- /**
142
- * Hybrid search combining vector similarity and text relevance.
143
- *
144
- * Uses Reciprocal Rank Fusion (RRF) to combine HNSW and BM25 results.
145
- *
146
- * @param queryVector - Query embedding
147
- * @param queryText - Text query for BM25
148
- * @param k - Number of results
149
- * @param filter - Optional metadata filter
150
- * @param alpha - Weight for vector vs text (0.0=text only, 1.0=vector only, default=0.5)
151
- * @param rrfK - RRF constant (default=60, higher reduces rank influence)
152
- * @param subscores - Return separate keyword_score and semantic_score (default: false)
153
- * @returns Array of {id, score, metadata, keyword_score?, semantic_score?}
154
- */
155
- hybridSearch(
156
- queryVector: Array<number> | Float32Array,
157
- queryText: string,
158
- k: number,
159
- filter?: Record<string, unknown> | undefined,
160
- alpha?: number | undefined | null,
161
- rrfK?: number | undefined | null,
162
- subscores?: boolean | undefined | null,
163
- ): Array<HybridSearchResult>;
164
- /**
165
- * Flush pending changes to disk.
166
- *
167
- * For hybrid search, this commits text index changes.
168
- */
169
- flush(): void;
170
- /**
171
- * Optimize index for cache-efficient search.
172
- *
173
- * Reorders nodes for better memory locality, improving search performance by 6-40%.
174
- * Call after inserting a large batch of vectors.
175
- *
176
- * @returns Number of nodes reordered
177
- */
178
- optimize(): number;
179
- /** Merge another database into this one. */
180
- mergeFrom(other: VectorDatabase): number;
181
- /**
182
- * List all vector IDs (without loading vector data).
183
- *
184
- * Efficient way to get all IDs for iteration, export, or debugging.
185
- * @returns Array of all vector IDs in the database
186
- */
187
- ids(): Array<string>;
188
- /**
189
- * Get all items as array of {id, vector, metadata}.
190
- *
191
- * Returns all vectors with their IDs and metadata.
192
- * For large datasets, consider using ids() and get() in batches.
193
- */
194
- items(): Array<GetResult>;
195
- /**
196
- * Check if an ID exists in the database.
197
- *
198
- * @param id - Vector ID to check
199
- * @returns true if ID exists and is not deleted
200
- */
201
- exists(id: string): boolean;
202
- /**
203
- * Get multiple vectors by ID.
204
- *
205
- * Batch version of get(). More efficient than calling get() in a loop.
206
- *
207
- * @param ids - Array of vector IDs to retrieve
208
- * @returns Array of results in same order as input, null for missing IDs
209
- */
210
- getMany(ids: Array<string>): Array<GetResult | undefined | null>;
4
+ /**
5
+ * Insert or update vectors.
6
+ *
7
+ * Accepts an array of items with id, vector, and optional metadata.
8
+ */
9
+ set(items: Array<VectorItem>): Array<number>
10
+ /**
11
+ * Search for k nearest neighbors.
12
+ *
13
+ * @param query - Query vector (number[] or Float32Array)
14
+ * @param k - Number of results to return
15
+ * @param ef - Optional search width override
16
+ * @param filter - Optional metadata filter (e.g., {category: "foo"} or {price: {$gt: 10}})
17
+ * @param maxDistance - Optional max distance threshold (filter out distant results)
18
+ * @returns Array of {id, distance, metadata}
19
+ */
20
+ search(query: Array<number> | Float32Array, k: number, ef?: number | undefined | null, filter?: Record<string, unknown> | undefined, maxDistance?: number | undefined | null): Array<SearchResult>
21
+ /**
22
+ * Batch search with parallel execution (async).
23
+ *
24
+ * Runs searches in parallel using rayon on a blocking thread pool,
25
+ * keeping the Node.js event loop free.
26
+ */
27
+ searchBatch(queries: Array<Array<number> | Float32Array>, k: number, ef?: number | undefined | null): Promise<Array<Array<SearchResult>>>
28
+ /** Get a vector by ID. */
29
+ get(id: string): GetResult | null
30
+ /**
31
+ * Delete vectors by ID.
32
+ *
33
+ * @returns Number of vectors deleted
34
+ */
35
+ delete(ids: Array<string>): number
36
+ /**
37
+ * Delete vectors matching a metadata filter.
38
+ *
39
+ * Evaluates the filter against all vectors and deletes those that match.
40
+ * Uses the same MongoDB-style filter syntax as search().
41
+ *
42
+ * @param filter - MongoDB-style metadata filter
43
+ * @returns Number of vectors deleted
44
+ *
45
+ * @example
46
+ * ```javascript
47
+ * // Delete by equality
48
+ * db.deleteByFilter({ status: "archived" });
49
+ *
50
+ * // Delete with comparison
51
+ * db.deleteByFilter({ score: { $lt: 0.5 } });
52
+ *
53
+ * // Complex filter
54
+ * db.deleteByFilter({ $and: [{ type: "draft" }, { age: { $gt: 30 } }] });
55
+ * ```
56
+ */
57
+ deleteByFilter(filter: Record<string, unknown>): number
58
+ /**
59
+ * Count vectors, optionally filtered by metadata.
60
+ *
61
+ * Without a filter, returns total count (same as db.length).
62
+ * With a filter, returns count of vectors matching the filter.
63
+ *
64
+ * @param filter - Optional MongoDB-style metadata filter
65
+ * @returns Number of vectors (matching filter if provided)
66
+ *
67
+ * @example
68
+ * ```javascript
69
+ * // Total count
70
+ * const total = db.count();
71
+ *
72
+ * // Filtered count
73
+ * const active = db.count({ status: "active" });
74
+ *
75
+ * // With comparison operators
76
+ * const highScore = db.count({ score: { $gte: 0.8 } });
77
+ * ```
78
+ */
79
+ count(filter?: Record<string, unknown> | undefined): number
80
+ /** Update a vector's data and/or metadata. */
81
+ update(id: string, vector: Array<number> | Float32Array, metadata?: Record<string, unknown> | undefined): void
82
+ /** Get number of vectors in database. */
83
+ get length(): number
84
+ /** Get vector dimensions of this database. */
85
+ get dimensions(): number
86
+ /** Check if database is empty. */
87
+ isEmpty(): boolean
88
+ /** Get database statistics. */
89
+ stats(): StatsResult
90
+ /** Get current ef_search value. */
91
+ get efSearch(): number
92
+ /** Set ef_search value. */
93
+ set efSearch(efSearch: number)
94
+ /**
95
+ * Get or create a named collection.
96
+ *
97
+ * Collection handles share state - changes made through one handle
98
+ * are immediately visible through another (no flush required).
99
+ */
100
+ collection(name: string): VectorDatabase
101
+ /** List all collections. */
102
+ collections(): Array<string>
103
+ /** Delete a collection. */
104
+ deleteCollection(name: string): void
105
+ /**
106
+ * Enable text search for hybrid (vector + text) search.
107
+ *
108
+ * Must be called before using setWithText() or hybridSearch().
109
+ */
110
+ enableTextSearch(): void
111
+ /** Check if text search is enabled. */
112
+ get hasTextSearch(): boolean
113
+ /**
114
+ * Set vectors with associated text for hybrid search.
115
+ *
116
+ * @param items - Array of {id, vector, text, metadata?}
117
+ * @returns Array of internal indices
118
+ */
119
+ setWithText(items: Array<VectorItemWithText>): Array<number>
120
+ /**
121
+ * Search using text only (BM25 scoring).
122
+ *
123
+ * @param query - Text query
124
+ * @param k - Number of results
125
+ * @returns Array of {id, score, metadata}
126
+ */
127
+ textSearch(query: string, k: number): Array<TextSearchResult>
128
+ /**
129
+ * Hybrid search combining vector similarity and text relevance.
130
+ *
131
+ * Uses Reciprocal Rank Fusion (RRF) to combine HNSW and BM25 results.
132
+ *
133
+ * @param queryVector - Query embedding
134
+ * @param queryText - Text query for BM25
135
+ * @param k - Number of results
136
+ * @param filter - Optional metadata filter
137
+ * @param alpha - Weight for vector vs text (0.0=text only, 1.0=vector only, default=0.5)
138
+ * @param rrfK - RRF constant (default=60, higher reduces rank influence)
139
+ * @param subscores - Return separate keyword_score and semantic_score (default: false)
140
+ * @returns Array of {id, score, metadata, keyword_score?, semantic_score?}
141
+ */
142
+ hybridSearch(queryVector: Array<number> | Float32Array, queryText: string, k: number, filter?: Record<string, unknown> | undefined, alpha?: number | undefined | null, rrfK?: number | undefined | null, subscores?: boolean | undefined | null): Array<HybridSearchResult>
143
+ /**
144
+ * Flush pending changes to disk.
145
+ *
146
+ * For hybrid search, this commits text index changes.
147
+ */
148
+ flush(): void
149
+ /**
150
+ * Optimize index for cache-efficient search.
151
+ *
152
+ * Reorders nodes for better memory locality, improving search performance by 6-40%.
153
+ * Call after inserting a large batch of vectors.
154
+ *
155
+ * @returns Number of nodes reordered
156
+ */
157
+ optimize(): number
158
+ /** Merge another database into this one. */
159
+ mergeFrom(other: VectorDatabase): number
160
+ /**
161
+ * List all vector IDs (without loading vector data).
162
+ *
163
+ * Efficient way to get all IDs for iteration, export, or debugging.
164
+ * @returns Array of all vector IDs in the database
165
+ */
166
+ ids(): Array<string>
167
+ /**
168
+ * Get all items as array of {id, vector, metadata}.
169
+ *
170
+ * Returns all vectors with their IDs and metadata.
171
+ * For large datasets, consider using ids() and get() in batches.
172
+ */
173
+ items(): Array<GetResult>
174
+ /**
175
+ * Check if an ID exists in the database.
176
+ *
177
+ * @param id - Vector ID to check
178
+ * @returns true if ID exists and is not deleted
179
+ */
180
+ exists(id: string): boolean
181
+ /**
182
+ * Get multiple vectors by ID.
183
+ *
184
+ * Batch version of get(). More efficient than calling get() in a loop.
185
+ *
186
+ * @param ids - Array of vector IDs to retrieve
187
+ * @returns Array of results in same order as input, null for missing IDs
188
+ */
189
+ getBatch(ids: Array<string>): Array<GetResult | undefined | null>
211
190
  }
212
191
 
213
192
  export interface GetResult {
214
- id: string;
215
- vector: Float32Array;
216
- metadata: Record<string, unknown>;
193
+ id: string
194
+ vector: Float32Array
195
+ metadata: Record<string, unknown>
217
196
  }
218
197
 
219
198
  export interface HybridSearchResult {
220
- id: string;
221
- score: number;
222
- metadata: Record<string, unknown>;
223
- /** BM25 keyword matching score (null if document only matched vector search) */
224
- keywordScore?: number;
225
- /** Vector similarity score (null if document only matched text search) */
226
- semanticScore?: number;
199
+ id: string
200
+ score: number
201
+ metadata: Record<string, unknown>
202
+ /** BM25 keyword matching score (null if document only matched vector search) */
203
+ keywordScore?: number
204
+ /** Vector similarity score (null if document only matched text search) */
205
+ semanticScore?: number
227
206
  }
228
207
 
229
208
  /**
@@ -261,10 +240,7 @@ export interface HybridSearchResult {
261
240
  * });
262
241
  * ```
263
242
  */
264
- export declare function open(
265
- path: string,
266
- options?: OpenOptions | undefined | null,
267
- ): VectorDatabase;
243
+ export declare function open(path: string, options?: OpenOptions | undefined | null): VectorDatabase
268
244
 
269
245
  /**
270
246
  * Configuration options for opening a vector database.
@@ -280,69 +256,68 @@ export declare function open(
280
256
  * - metric: "l2" (distance metric: "l2", "euclidean", "cosine", "dot", "ip")
281
257
  */
282
258
  export interface OpenOptions {
283
- /** Vector dimensions (default: 128, auto-detected on first insert) */
284
- dimensions?: number;
285
- /** HNSW M parameter: neighbors per node (default: 16, range: 4-64) */
286
- m?: number;
287
- /** HNSW ef_construction: build quality (default: 100, must be >= m) */
288
- efConstruction?: number;
289
- /** HNSW ef_search: search quality/speed tradeoff (default: 100) */
290
- efSearch?: number;
291
- /**
292
- * Quantization mode (default: null = no quantization)
293
- * - true or "sq8": SQ8 4x compression, ~99% recall (RECOMMENDED)
294
- * - "rabitq": RaBitQ 8x compression, ~98% recall
295
- * - "binary": Binary 32x compression, ~95% recall
296
- * - 2, 4, 8: RaBitQ with specific bits (legacy)
297
- */
298
- quantization?: boolean | string | number | null | undefined;
299
- /**
300
- * Rescore candidates with exact distance (default: true when quantization enabled)
301
- * Set to false for maximum speed at the cost of ~20% recall
302
- */
303
- rescore?: boolean;
304
- /**
305
- * Oversampling factor for rescoring (default: 3.0)
306
- * Fetches k*oversample candidates then reranks to return top k
307
- */
308
- oversample?: number;
309
- /** Distance metric: "l2"/"euclidean" (default), "cosine", "dot"/"ip" */
310
- metric?: string;
259
+ /** Vector dimensions (default: 128, auto-detected on first insert) */
260
+ dimensions?: number
261
+ /** HNSW M parameter: neighbors per node (default: 16, range: 4-64) */
262
+ m?: number
263
+ /** HNSW ef_construction: build quality (default: 100, must be >= m) */
264
+ efConstruction?: number
265
+ /** HNSW ef_search: search quality/speed tradeoff (default: 100) */
266
+ efSearch?: number
267
+ /**
268
+ * Quantization mode (default: null = no quantization)
269
+ * - true or "sq8": SQ8 4x compression, ~99% recall (RECOMMENDED)
270
+ * - "rabitq": RaBitQ 8x compression, ~98% recall
271
+ * - "binary": Binary 32x compression, ~95% recall
272
+ * - 2, 4, 8: RaBitQ with specific bits (legacy)
273
+ */
274
+ quantization?: boolean | string | number | null | undefined
275
+ /**
276
+ * Rescore candidates with exact distance (default: true when quantization enabled)
277
+ * Set to false for maximum speed at the cost of ~20% recall
278
+ */
279
+ rescore?: boolean
280
+ /**
281
+ * Oversampling factor for rescoring (default: 3.0)
282
+ * Fetches k*oversample candidates then reranks to return top k
283
+ */
284
+ oversample?: number
285
+ /** Distance metric: "l2"/"euclidean" (default), "cosine", "dot"/"ip" */
286
+ metric?: string
311
287
  }
312
288
 
313
289
  export interface SearchResult {
314
- id: string;
315
- distance: number;
316
- /** Metadata as JSON (using serde-json feature) */
317
- metadata: Record<string, unknown>;
290
+ id: string
291
+ distance: number
292
+ /** Metadata as JSON (using serde-json feature) */
293
+ metadata: Record<string, unknown>
318
294
  }
319
295
 
320
296
  export interface StatsResult {
321
- dimensions: number;
322
- count: number;
323
- path: string;
297
+ dimensions: number
298
+ count: number
299
+ path: string
324
300
  }
325
301
 
326
302
  export interface TextSearchResult {
327
- id: string;
328
- score: number;
329
- metadata: Record<string, unknown>;
303
+ id: string
304
+ score: number
305
+ metadata: Record<string, unknown>
330
306
  }
331
307
 
332
308
  export interface VectorItem {
333
- id: string;
334
- /** Vector data as number[] or Float32Array (Float32Array is more efficient) */
335
- vector: number[] | Float32Array;
336
- /** Optional metadata */
337
- metadata?: Record<string, unknown> | undefined;
338
- /** Optional document text (stored in metadata.document) */
339
- document?: string;
309
+ id: string
310
+ /** Vector data as Float32Array */
311
+ vector: Float32Array
312
+ /** Optional metadata */
313
+ metadata?: Record<string, unknown> | undefined
314
+ /** Optional document text (stored in metadata.document) */
315
+ document?: string
340
316
  }
341
317
 
342
318
  export interface VectorItemWithText {
343
- id: string;
344
- /** Vector data as number[] or Float32Array (Float32Array is more efficient) */
345
- vector: number[] | Float32Array;
346
- text: string;
347
- metadata?: Record<string, unknown> | undefined;
319
+ id: string
320
+ vector: Float32Array
321
+ text: string
322
+ metadata?: Record<string, unknown> | undefined
348
323
  }
package/index.js CHANGED
@@ -145,8 +145,8 @@ class VectorDatabase {
145
145
  return this._native.delete(ids);
146
146
  }
147
147
 
148
- deleteWhere(filter) {
149
- return this._native.deleteWhere(filter);
148
+ deleteByFilter(filter) {
149
+ return this._native.deleteByFilter(filter);
150
150
  }
151
151
 
152
152
  count(filter) {
@@ -245,8 +245,8 @@ class VectorDatabase {
245
245
  return this._native.exists(id);
246
246
  }
247
247
 
248
- getMany(ids) {
249
- return this._native.getMany(ids);
248
+ getBatch(ids) {
249
+ return this._native.getBatch(ids);
250
250
  }
251
251
  }
252
252
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omendb/omendb",
3
- "version": "0.0.20",
3
+ "version": "0.0.21",
4
4
  "description": "Fast embedded vector database with HNSW + ACORN-1 filtered search",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -50,10 +50,10 @@
50
50
  "omendb.node"
51
51
  ],
52
52
  "optionalDependencies": {
53
- "@omendb/omendb-darwin-x64": "0.0.20",
54
- "@omendb/omendb-darwin-arm64": "0.0.20",
55
- "@omendb/omendb-linux-x64-gnu": "0.0.20",
56
- "@omendb/omendb-linux-arm64-gnu": "0.0.20",
57
- "@omendb/omendb-win32-x64-msvc": "0.0.20"
53
+ "@omendb/omendb-darwin-x64": "0.0.21",
54
+ "@omendb/omendb-darwin-arm64": "0.0.21",
55
+ "@omendb/omendb-linux-x64-gnu": "0.0.21",
56
+ "@omendb/omendb-linux-arm64-gnu": "0.0.21",
57
+ "@omendb/omendb-win32-x64-msvc": "0.0.21"
58
58
  }
59
59
  }