@omendb/omendb 0.0.10 → 0.0.11

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 +239 -139
  2. package/package.json +5 -5
package/index.d.ts CHANGED
@@ -1,106 +1,200 @@
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(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
- /** Update a vector's data and/or metadata. */
35
- update(id: string, vector: Array<number> | Float32Array, metadata?: Record<string, unknown> | undefined): void
36
- /** Get number of vectors in database. */
37
- get count(): number
38
- /** Get current ef_search value. */
39
- get efSearch(): number
40
- /** Set ef_search value. */
41
- set efSearch(efSearch: number)
42
- /**
43
- * Get or create a named collection.
44
- *
45
- * Collection handles share state - changes made through one handle
46
- * are immediately visible through another (no flush required).
47
- */
48
- collection(name: string): VectorDatabase
49
- /** List all collections. */
50
- collections(): Array<string>
51
- /** Delete a collection. */
52
- deleteCollection(name: string): void
53
- /**
54
- * Enable text search for hybrid (vector + text) search.
55
- *
56
- * Must be called before using setWithText() or hybridSearch().
57
- */
58
- enableTextSearch(): void
59
- /** Check if text search is enabled. */
60
- get hasTextSearch(): boolean
61
- /**
62
- * Set vectors with associated text for hybrid search.
63
- *
64
- * @param items - Array of {id, vector, text, metadata?}
65
- * @returns Array of internal indices
66
- */
67
- setWithText(items: Array<VectorItemWithText>): Array<number>
68
- /**
69
- * Search using text only (BM25 scoring).
70
- *
71
- * @param query - Text query
72
- * @param k - Number of results
73
- * @returns Array of {id, score, metadata}
74
- */
75
- textSearch(query: string, k: number): Array<TextSearchResult>
76
- /**
77
- * Hybrid search combining vector similarity and text relevance.
78
- *
79
- * Uses Reciprocal Rank Fusion (RRF) to combine HNSW and BM25 results.
80
- *
81
- * @param queryVector - Query embedding
82
- * @param queryText - Text query for BM25
83
- * @param k - Number of results
84
- * @param filter - Optional metadata filter
85
- * @param alpha - Weight for vector vs text (0.0=text only, 1.0=vector only, default=0.5)
86
- * @param rrfK - RRF constant (default=60, higher reduces rank influence)
87
- * @returns Array of {id, score, metadata}
88
- */
89
- hybridSearch(queryVector: Array<number> | Float32Array, queryText: string, k: number, filter?: Record<string, unknown> | undefined, alpha?: number | undefined | null, rrfK?: number | undefined | null): Array<TextSearchResult>
90
- /**
91
- * Flush pending changes to disk.
92
- *
93
- * For hybrid search, this commits text index changes.
94
- */
95
- flush(): void
96
- /** Merge another database into this one. */
97
- mergeFrom(other: VectorDatabase): number
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>;
98
192
  }
99
193
 
100
194
  export interface GetResult {
101
- id: string
102
- vector: Array<number>
103
- metadata: Record<string, unknown>
195
+ id: string;
196
+ vector: Array<number>;
197
+ metadata: Record<string, unknown>;
104
198
  }
105
199
 
106
200
  /**
@@ -138,7 +232,10 @@ export interface GetResult {
138
232
  * });
139
233
  * ```
140
234
  */
141
- export declare function open(path: string, options?: OpenOptions | undefined | null): VectorDatabase
235
+ export declare function open(
236
+ path: string,
237
+ options?: OpenOptions | undefined | null,
238
+ ): VectorDatabase;
142
239
 
143
240
  /**
144
241
  * Configuration options for opening a vector database.
@@ -151,59 +248,62 @@ export declare function open(path: string, options?: OpenOptions | undefined | n
151
248
  * - quantization: null (RaBitQ bit width: 2, 4, or 8 for compression)
152
249
  * - rescore: true when quantization enabled (rerank candidates with exact distance)
153
250
  * - oversample: 3.0 (fetch k*oversample candidates when rescoring)
251
+ * - metric: "l2" (distance metric: "l2", "euclidean", "cosine", "dot", "ip")
154
252
  */
155
253
  export interface OpenOptions {
156
- /** Vector dimensions (default: 128, auto-detected on first insert) */
157
- dimensions?: number
158
- /** HNSW M parameter: neighbors per node (default: 16, range: 4-64) */
159
- m?: number
160
- /** HNSW ef_construction: build quality (default: 100, must be >= m) */
161
- efConstruction?: number
162
- /** HNSW ef_search: search quality/speed tradeoff (default: 100) */
163
- efSearch?: number
164
- /**
165
- * RaBitQ quantization bits: 2, 4, or 8 (default: null = no quantization)
166
- * Enables 4-16x memory compression with ~1-2% recall loss
167
- */
168
- quantization?: number
169
- /**
170
- * Rescore candidates with exact distance (default: true when quantization enabled)
171
- * Set to false for maximum speed at the cost of ~20% recall
172
- */
173
- rescore?: boolean
174
- /**
175
- * Oversampling factor for rescoring (default: 3.0)
176
- * Fetches k*oversample candidates then reranks to return top k
177
- */
178
- oversample?: number
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;
179
279
  }
180
280
 
181
281
  export interface SearchResult {
182
- id: string
183
- distance: number
184
- /** Metadata as JSON (using serde-json feature) */
185
- metadata: Record<string, unknown>
282
+ id: string;
283
+ distance: number;
284
+ /** Metadata as JSON (using serde-json feature) */
285
+ metadata: Record<string, unknown>;
186
286
  }
187
287
 
188
288
  export interface TextSearchResult {
189
- id: string
190
- score: number
191
- metadata: Record<string, unknown>
289
+ id: string;
290
+ score: number;
291
+ metadata: Record<string, unknown>;
192
292
  }
193
293
 
194
294
  export interface VectorItem {
195
- id: string
196
- /** Vector data as array of numbers */
197
- vector: Array<number>
198
- /** Optional metadata */
199
- metadata?: Record<string, unknown> | undefined
200
- /** Optional document text (stored in metadata.document) */
201
- document?: string
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;
202
302
  }
203
303
 
204
304
  export interface VectorItemWithText {
205
- id: string
206
- vector: Array<number>
207
- text: string
208
- metadata?: Record<string, unknown> | undefined
305
+ id: string;
306
+ vector: Array<number>;
307
+ text: string;
308
+ metadata?: Record<string, unknown> | undefined;
209
309
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@omendb/omendb",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
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.10",
53
- "@omendb/omendb-darwin-arm64": "0.0.10",
54
- "@omendb/omendb-linux-x64-gnu": "0.0.10",
55
- "@omendb/omendb-linux-arm64-gnu": "0.0.10"
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"
56
56
  }
57
57
  }