@omendb/omendb 0.0.11 → 0.0.12

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 (2) hide show
  1. package/index.d.ts +215 -238
  2. package/package.json +5 -5
package/index.d.ts CHANGED
@@ -1,200 +1,180 @@
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
- * @returns Array of {id, distance, metadata}
18
- */
19
- search(
20
- query: Array<number> | Float32Array,
21
- k: number,
22
- ef?: number | undefined | null,
23
- filter?: Record<string, unknown> | undefined,
24
- ): Array<SearchResult>;
25
- /**
26
- * Batch search with parallel execution (async).
27
- *
28
- * Runs searches in parallel using rayon, returns Promise.
29
- */
30
- searchBatch(
31
- queries: Array<Array<number> | Float32Array>,
32
- k: number,
33
- ef?: number | undefined | null,
34
- ): Promise<Array<Array<SearchResult>>>;
35
- /** Get a vector by ID. */
36
- get(id: string): GetResult | null;
37
- /**
38
- * Delete vectors by ID.
39
- *
40
- * @returns Number of vectors deleted
41
- */
42
- delete(ids: Array<string>): number;
43
- /**
44
- * Delete vectors matching a metadata filter.
45
- *
46
- * Evaluates the filter against all vectors and deletes those that match.
47
- * Uses the same MongoDB-style filter syntax as search().
48
- *
49
- * @param filter - MongoDB-style metadata filter
50
- * @returns Number of vectors deleted
51
- *
52
- * @example
53
- * ```javascript
54
- * // Delete by equality
55
- * db.deleteWhere({ status: "archived" });
56
- *
57
- * // Delete with comparison
58
- * db.deleteWhere({ score: { $lt: 0.5 } });
59
- *
60
- * // Complex filter
61
- * db.deleteWhere({ $and: [{ type: "draft" }, { age: { $gt: 30 } }] });
62
- * ```
63
- */
64
- deleteWhere(filter: Record<string, unknown>): number;
65
- /**
66
- * Count vectors, optionally filtered by metadata.
67
- *
68
- * Without a filter, returns total count (same as db.length).
69
- * With a filter, returns count of vectors matching the filter.
70
- *
71
- * @param filter - Optional MongoDB-style metadata filter
72
- * @returns Number of vectors (matching filter if provided)
73
- *
74
- * @example
75
- * ```javascript
76
- * // Total count
77
- * const total = db.count();
78
- *
79
- * // Filtered count
80
- * const active = db.count({ status: "active" });
81
- *
82
- * // With comparison operators
83
- * const highScore = db.count({ score: { $gte: 0.8 } });
84
- * ```
85
- */
86
- count(filter?: Record<string, unknown> | undefined): number;
87
- /** Update a vector's data and/or metadata. */
88
- update(
89
- id: string,
90
- vector: Array<number> | Float32Array,
91
- metadata?: Record<string, unknown> | undefined,
92
- ): void;
93
- /** Get number of vectors in database. */
94
- get length(): number;
95
- /** Get current ef_search value. */
96
- get efSearch(): number;
97
- /** Set ef_search value. */
98
- set efSearch(efSearch: number);
99
- /**
100
- * Get or create a named collection.
101
- *
102
- * Collection handles share state - changes made through one handle
103
- * are immediately visible through another (no flush required).
104
- */
105
- collection(name: string): VectorDatabase;
106
- /** List all collections. */
107
- collections(): Array<string>;
108
- /** Delete a collection. */
109
- deleteCollection(name: string): void;
110
- /**
111
- * Enable text search for hybrid (vector + text) search.
112
- *
113
- * Must be called before using setWithText() or hybridSearch().
114
- */
115
- enableTextSearch(): void;
116
- /** Check if text search is enabled. */
117
- get hasTextSearch(): boolean;
118
- /**
119
- * Set vectors with associated text for hybrid search.
120
- *
121
- * @param items - Array of {id, vector, text, metadata?}
122
- * @returns Array of internal indices
123
- */
124
- setWithText(items: Array<VectorItemWithText>): Array<number>;
125
- /**
126
- * Search using text only (BM25 scoring).
127
- *
128
- * @param query - Text query
129
- * @param k - Number of results
130
- * @returns Array of {id, score, metadata}
131
- */
132
- textSearch(query: string, k: number): Array<TextSearchResult>;
133
- /**
134
- * Hybrid search combining vector similarity and text relevance.
135
- *
136
- * Uses Reciprocal Rank Fusion (RRF) to combine HNSW and BM25 results.
137
- *
138
- * @param queryVector - Query embedding
139
- * @param queryText - Text query for BM25
140
- * @param k - Number of results
141
- * @param filter - Optional metadata filter
142
- * @param alpha - Weight for vector vs text (0.0=text only, 1.0=vector only, default=0.5)
143
- * @param rrfK - RRF constant (default=60, higher reduces rank influence)
144
- * @returns Array of {id, score, metadata}
145
- */
146
- hybridSearch(
147
- queryVector: Array<number> | Float32Array,
148
- queryText: string,
149
- k: number,
150
- filter?: Record<string, unknown> | undefined,
151
- alpha?: number | undefined | null,
152
- rrfK?: number | undefined | null,
153
- ): Array<TextSearchResult>;
154
- /**
155
- * Flush pending changes to disk.
156
- *
157
- * For hybrid search, this commits text index changes.
158
- */
159
- flush(): void;
160
- /** Merge another database into this one. */
161
- mergeFrom(other: VectorDatabase): number;
162
- /**
163
- * List all vector IDs (without loading vector data).
164
- *
165
- * Efficient way to get all IDs for iteration, export, or debugging.
166
- * @returns Array of all vector IDs in the database
167
- */
168
- ids(): Array<string>;
169
- /**
170
- * Get all items as array of {id, vector, metadata}.
171
- *
172
- * Returns all vectors with their IDs and metadata.
173
- * For large datasets, consider using ids() and get() in batches.
174
- */
175
- items(): Array<GetResult>;
176
- /**
177
- * Check if an ID exists in the database.
178
- *
179
- * @param id - Vector ID to check
180
- * @returns true if ID exists and is not deleted
181
- */
182
- exists(id: string): boolean;
183
- /**
184
- * Get multiple vectors by ID.
185
- *
186
- * Batch version of get(). More efficient than calling get() in a loop.
187
- *
188
- * @param ids - Array of vector IDs to retrieve
189
- * @returns Array of results in same order as input, null for missing IDs
190
- */
191
- 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
+ * @returns Array of {id, distance, metadata}
18
+ */
19
+ search(query: Array<number> | Float32Array, k: number, ef?: number | undefined | null, filter?: Record<string, unknown> | undefined): Array<SearchResult>
20
+ /**
21
+ * Batch search with parallel execution (async).
22
+ *
23
+ * Runs searches in parallel using rayon, returns Promise.
24
+ */
25
+ searchBatch(queries: Array<Array<number> | Float32Array>, k: number, ef?: number | undefined | null): Promise<Array<Array<SearchResult>>>
26
+ /** Get a vector by ID. */
27
+ get(id: string): GetResult | null
28
+ /**
29
+ * Delete vectors by ID.
30
+ *
31
+ * @returns Number of vectors deleted
32
+ */
33
+ delete(ids: Array<string>): number
34
+ /**
35
+ * Delete vectors matching a metadata filter.
36
+ *
37
+ * Evaluates the filter against all vectors and deletes those that match.
38
+ * Uses the same MongoDB-style filter syntax as search().
39
+ *
40
+ * @param filter - MongoDB-style metadata filter
41
+ * @returns Number of vectors deleted
42
+ *
43
+ * @example
44
+ * ```javascript
45
+ * // Delete by equality
46
+ * db.deleteWhere({ status: "archived" });
47
+ *
48
+ * // Delete with comparison
49
+ * db.deleteWhere({ score: { $lt: 0.5 } });
50
+ *
51
+ * // Complex filter
52
+ * db.deleteWhere({ $and: [{ type: "draft" }, { age: { $gt: 30 } }] });
53
+ * ```
54
+ */
55
+ deleteWhere(filter: Record<string, unknown>): number
56
+ /**
57
+ * Count vectors, optionally filtered by metadata.
58
+ *
59
+ * Without a filter, returns total count (same as db.length).
60
+ * With a filter, returns count of vectors matching the filter.
61
+ *
62
+ * @param filter - Optional MongoDB-style metadata filter
63
+ * @returns Number of vectors (matching filter if provided)
64
+ *
65
+ * @example
66
+ * ```javascript
67
+ * // Total count
68
+ * const total = db.count();
69
+ *
70
+ * // Filtered count
71
+ * const active = db.count({ status: "active" });
72
+ *
73
+ * // With comparison operators
74
+ * const highScore = db.count({ score: { $gte: 0.8 } });
75
+ * ```
76
+ */
77
+ count(filter?: Record<string, unknown> | undefined): number
78
+ /** Update a vector's data and/or metadata. */
79
+ update(id: string, vector: Array<number> | Float32Array, metadata?: Record<string, unknown> | undefined): void
80
+ /** Get number of vectors in database. */
81
+ get length(): number
82
+ /** Get current ef_search value. */
83
+ get efSearch(): number
84
+ /** Set ef_search value. */
85
+ set efSearch(efSearch: number)
86
+ /**
87
+ * Get or create a named collection.
88
+ *
89
+ * Collection handles share state - changes made through one handle
90
+ * are immediately visible through another (no flush required).
91
+ */
92
+ collection(name: string): VectorDatabase
93
+ /** List all collections. */
94
+ collections(): Array<string>
95
+ /** Delete a collection. */
96
+ deleteCollection(name: string): void
97
+ /**
98
+ * Enable text search for hybrid (vector + text) search.
99
+ *
100
+ * Must be called before using setWithText() or hybridSearch().
101
+ */
102
+ enableTextSearch(): void
103
+ /** Check if text search is enabled. */
104
+ get hasTextSearch(): boolean
105
+ /**
106
+ * Set vectors with associated text for hybrid search.
107
+ *
108
+ * @param items - Array of {id, vector, text, metadata?}
109
+ * @returns Array of internal indices
110
+ */
111
+ setWithText(items: Array<VectorItemWithText>): Array<number>
112
+ /**
113
+ * Search using text only (BM25 scoring).
114
+ *
115
+ * @param query - Text query
116
+ * @param k - Number of results
117
+ * @returns Array of {id, score, metadata}
118
+ */
119
+ textSearch(query: string, k: number): Array<TextSearchResult>
120
+ /**
121
+ * Hybrid search combining vector similarity and text relevance.
122
+ *
123
+ * Uses Reciprocal Rank Fusion (RRF) to combine HNSW and BM25 results.
124
+ *
125
+ * @param queryVector - Query embedding
126
+ * @param queryText - Text query for BM25
127
+ * @param k - Number of results
128
+ * @param filter - Optional metadata filter
129
+ * @param alpha - Weight for vector vs text (0.0=text only, 1.0=vector only, default=0.5)
130
+ * @param rrfK - RRF constant (default=60, higher reduces rank influence)
131
+ * @returns Array of {id, score, metadata}
132
+ */
133
+ hybridSearch(queryVector: Array<number> | Float32Array, queryText: string, k: number, filter?: Record<string, unknown> | undefined, alpha?: number | undefined | null, rrfK?: number | undefined | null): Array<TextSearchResult>
134
+ /**
135
+ * Flush pending changes to disk.
136
+ *
137
+ * For hybrid search, this commits text index changes.
138
+ */
139
+ flush(): void
140
+ /** Merge another database into this one. */
141
+ mergeFrom(other: VectorDatabase): number
142
+ /**
143
+ * List all vector IDs (without loading vector data).
144
+ *
145
+ * Efficient way to get all IDs for iteration, export, or debugging.
146
+ * @returns Array of all vector IDs in the database
147
+ */
148
+ ids(): Array<string>
149
+ /**
150
+ * Get all items as array of {id, vector, metadata}.
151
+ *
152
+ * Returns all vectors with their IDs and metadata.
153
+ * For large datasets, consider using ids() and get() in batches.
154
+ */
155
+ items(): Array<GetResult>
156
+ /**
157
+ * Check if an ID exists in the database.
158
+ *
159
+ * @param id - Vector ID to check
160
+ * @returns true if ID exists and is not deleted
161
+ */
162
+ exists(id: string): boolean
163
+ /**
164
+ * Get multiple vectors by ID.
165
+ *
166
+ * Batch version of get(). More efficient than calling get() in a loop.
167
+ *
168
+ * @param ids - Array of vector IDs to retrieve
169
+ * @returns Array of results in same order as input, null for missing IDs
170
+ */
171
+ getMany(ids: Array<string>): Array<GetResult | undefined | null>
192
172
  }
193
173
 
194
174
  export interface GetResult {
195
- id: string;
196
- vector: Array<number>;
197
- metadata: Record<string, unknown>;
175
+ id: string
176
+ vector: Array<number>
177
+ metadata: Record<string, unknown>
198
178
  }
199
179
 
200
180
  /**
@@ -232,10 +212,7 @@ export interface GetResult {
232
212
  * });
233
213
  * ```
234
214
  */
235
- export declare function open(
236
- path: string,
237
- options?: OpenOptions | undefined | null,
238
- ): VectorDatabase;
215
+ export declare function open(path: string, options?: OpenOptions | undefined | null): VectorDatabase
239
216
 
240
217
  /**
241
218
  * Configuration options for opening a vector database.
@@ -251,59 +228,59 @@ export declare function open(
251
228
  * - metric: "l2" (distance metric: "l2", "euclidean", "cosine", "dot", "ip")
252
229
  */
253
230
  export interface OpenOptions {
254
- /** Vector dimensions (default: 128, auto-detected on first insert) */
255
- dimensions?: number;
256
- /** HNSW M parameter: neighbors per node (default: 16, range: 4-64) */
257
- m?: number;
258
- /** HNSW ef_construction: build quality (default: 100, must be >= m) */
259
- efConstruction?: number;
260
- /** HNSW ef_search: search quality/speed tradeoff (default: 100) */
261
- efSearch?: number;
262
- /**
263
- * RaBitQ quantization bits: 2, 4, or 8 (default: null = no quantization)
264
- * Enables 4-16x memory compression with ~1-2% recall loss
265
- */
266
- quantization?: number;
267
- /**
268
- * Rescore candidates with exact distance (default: true when quantization enabled)
269
- * Set to false for maximum speed at the cost of ~20% recall
270
- */
271
- rescore?: boolean;
272
- /**
273
- * Oversampling factor for rescoring (default: 3.0)
274
- * Fetches k*oversample candidates then reranks to return top k
275
- */
276
- oversample?: number;
277
- /** Distance metric: "l2"/"euclidean" (default), "cosine", "dot"/"ip" */
278
- metric?: string;
231
+ /** Vector dimensions (default: 128, auto-detected on first insert) */
232
+ dimensions?: number
233
+ /** HNSW M parameter: neighbors per node (default: 16, range: 4-64) */
234
+ m?: number
235
+ /** HNSW ef_construction: build quality (default: 100, must be >= m) */
236
+ efConstruction?: number
237
+ /** HNSW ef_search: search quality/speed tradeoff (default: 100) */
238
+ efSearch?: number
239
+ /**
240
+ * RaBitQ quantization bits: 2, 4, or 8 (default: null = no quantization)
241
+ * Enables 4-16x memory compression with ~1-2% recall loss
242
+ */
243
+ quantization?: number
244
+ /**
245
+ * Rescore candidates with exact distance (default: true when quantization enabled)
246
+ * Set to false for maximum speed at the cost of ~20% recall
247
+ */
248
+ rescore?: boolean
249
+ /**
250
+ * Oversampling factor for rescoring (default: 3.0)
251
+ * Fetches k*oversample candidates then reranks to return top k
252
+ */
253
+ oversample?: number
254
+ /** Distance metric: "l2"/"euclidean" (default), "cosine", "dot"/"ip" */
255
+ metric?: string
279
256
  }
280
257
 
281
258
  export interface SearchResult {
282
- id: string;
283
- distance: number;
284
- /** Metadata as JSON (using serde-json feature) */
285
- metadata: Record<string, unknown>;
259
+ id: string
260
+ distance: number
261
+ /** Metadata as JSON (using serde-json feature) */
262
+ metadata: Record<string, unknown>
286
263
  }
287
264
 
288
265
  export interface TextSearchResult {
289
- id: string;
290
- score: number;
291
- metadata: Record<string, unknown>;
266
+ id: string
267
+ score: number
268
+ metadata: Record<string, unknown>
292
269
  }
293
270
 
294
271
  export interface VectorItem {
295
- id: string;
296
- /** Vector data as array of numbers */
297
- vector: Array<number>;
298
- /** Optional metadata */
299
- metadata?: Record<string, unknown> | undefined;
300
- /** Optional document text (stored in metadata.document) */
301
- document?: string;
272
+ id: string
273
+ /** Vector data as array of numbers */
274
+ vector: Array<number>
275
+ /** Optional metadata */
276
+ metadata?: Record<string, unknown> | undefined
277
+ /** Optional document text (stored in metadata.document) */
278
+ document?: string
302
279
  }
303
280
 
304
281
  export interface VectorItemWithText {
305
- id: string;
306
- vector: Array<number>;
307
- text: string;
308
- metadata?: Record<string, unknown> | undefined;
282
+ id: string
283
+ vector: Array<number>
284
+ text: string
285
+ metadata?: Record<string, unknown> | undefined
309
286
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omendb/omendb",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "Fast embedded vector database with HNSW indexing",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -49,9 +49,9 @@
49
49
  "omendb.node"
50
50
  ],
51
51
  "optionalDependencies": {
52
- "@omendb/omendb-darwin-x64": "0.0.11",
53
- "@omendb/omendb-darwin-arm64": "0.0.11",
54
- "@omendb/omendb-linux-x64-gnu": "0.0.11",
55
- "@omendb/omendb-linux-arm64-gnu": "0.0.11"
52
+ "@omendb/omendb-darwin-x64": "0.0.12",
53
+ "@omendb/omendb-darwin-arm64": "0.0.12",
54
+ "@omendb/omendb-linux-x64-gnu": "0.0.12",
55
+ "@omendb/omendb-linux-arm64-gnu": "0.0.12"
56
56
  }
57
57
  }