@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.
- package/index.d.ts +215 -238
- 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
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
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
|
-
|
|
196
|
-
|
|
197
|
-
|
|
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
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
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
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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
|
-
|
|
290
|
-
|
|
291
|
-
|
|
266
|
+
id: string
|
|
267
|
+
score: number
|
|
268
|
+
metadata: Record<string, unknown>
|
|
292
269
|
}
|
|
293
270
|
|
|
294
271
|
export interface VectorItem {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
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
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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.
|
|
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.
|
|
53
|
-
"@omendb/omendb-darwin-arm64": "0.0.
|
|
54
|
-
"@omendb/omendb-linux-x64-gnu": "0.0.
|
|
55
|
-
"@omendb/omendb-linux-arm64-gnu": "0.0.
|
|
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
|
}
|