@omendb/omendb 0.0.19 → 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.
- package/index.d.ts +11 -10
- package/index.js +152 -1
- package/package.json +6 -6
package/index.d.ts
CHANGED
|
@@ -21,7 +21,8 @@ export declare class VectorDatabase {
|
|
|
21
21
|
/**
|
|
22
22
|
* Batch search with parallel execution (async).
|
|
23
23
|
*
|
|
24
|
-
* Runs searches in parallel using rayon
|
|
24
|
+
* Runs searches in parallel using rayon on a blocking thread pool,
|
|
25
|
+
* keeping the Node.js event loop free.
|
|
25
26
|
*/
|
|
26
27
|
searchBatch(queries: Array<Array<number> | Float32Array>, k: number, ef?: number | undefined | null): Promise<Array<Array<SearchResult>>>
|
|
27
28
|
/** Get a vector by ID. */
|
|
@@ -44,16 +45,16 @@ export declare class VectorDatabase {
|
|
|
44
45
|
* @example
|
|
45
46
|
* ```javascript
|
|
46
47
|
* // Delete by equality
|
|
47
|
-
* db.
|
|
48
|
+
* db.deleteByFilter({ status: "archived" });
|
|
48
49
|
*
|
|
49
50
|
* // Delete with comparison
|
|
50
|
-
* db.
|
|
51
|
+
* db.deleteByFilter({ score: { $lt: 0.5 } });
|
|
51
52
|
*
|
|
52
53
|
* // Complex filter
|
|
53
|
-
* db.
|
|
54
|
+
* db.deleteByFilter({ $and: [{ type: "draft" }, { age: { $gt: 30 } }] });
|
|
54
55
|
* ```
|
|
55
56
|
*/
|
|
56
|
-
|
|
57
|
+
deleteByFilter(filter: Record<string, unknown>): number
|
|
57
58
|
/**
|
|
58
59
|
* Count vectors, optionally filtered by metadata.
|
|
59
60
|
*
|
|
@@ -185,12 +186,12 @@ export declare class VectorDatabase {
|
|
|
185
186
|
* @param ids - Array of vector IDs to retrieve
|
|
186
187
|
* @returns Array of results in same order as input, null for missing IDs
|
|
187
188
|
*/
|
|
188
|
-
|
|
189
|
+
getBatch(ids: Array<string>): Array<GetResult | undefined | null>
|
|
189
190
|
}
|
|
190
191
|
|
|
191
192
|
export interface GetResult {
|
|
192
193
|
id: string
|
|
193
|
-
vector:
|
|
194
|
+
vector: Float32Array
|
|
194
195
|
metadata: Record<string, unknown>
|
|
195
196
|
}
|
|
196
197
|
|
|
@@ -306,8 +307,8 @@ export interface TextSearchResult {
|
|
|
306
307
|
|
|
307
308
|
export interface VectorItem {
|
|
308
309
|
id: string
|
|
309
|
-
/** Vector data as
|
|
310
|
-
vector:
|
|
310
|
+
/** Vector data as Float32Array */
|
|
311
|
+
vector: Float32Array
|
|
311
312
|
/** Optional metadata */
|
|
312
313
|
metadata?: Record<string, unknown> | undefined
|
|
313
314
|
/** Optional document text (stored in metadata.document) */
|
|
@@ -316,7 +317,7 @@ export interface VectorItem {
|
|
|
316
317
|
|
|
317
318
|
export interface VectorItemWithText {
|
|
318
319
|
id: string
|
|
319
|
-
vector:
|
|
320
|
+
vector: Float32Array
|
|
320
321
|
text: string
|
|
321
322
|
metadata?: Record<string, unknown> | undefined
|
|
322
323
|
}
|
package/index.js
CHANGED
|
@@ -101,7 +101,158 @@ if (!nativeBinding) {
|
|
|
101
101
|
throw new Error(`Failed to load native binding`);
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
-
|
|
104
|
+
// Convert array to Float32Array if needed
|
|
105
|
+
function toFloat32Array(arr) {
|
|
106
|
+
if (arr instanceof Float32Array) {
|
|
107
|
+
return arr;
|
|
108
|
+
}
|
|
109
|
+
return new Float32Array(arr);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Convert VectorItem to use Float32Array
|
|
113
|
+
function convertVectorItem(item) {
|
|
114
|
+
return {
|
|
115
|
+
...item,
|
|
116
|
+
vector: toFloat32Array(item.vector),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Wrap VectorDatabase to handle array conversion
|
|
121
|
+
const NativeVectorDatabase = nativeBinding.VectorDatabase;
|
|
122
|
+
|
|
123
|
+
class VectorDatabase {
|
|
124
|
+
constructor(nativeDb) {
|
|
125
|
+
this._native = nativeDb;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
set(items) {
|
|
129
|
+
return this._native.set(items.map(convertVectorItem));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
search(query, k, ef, filter, maxDistance) {
|
|
133
|
+
return this._native.search(query, k, ef, filter, maxDistance);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
searchBatch(queries, k, ef) {
|
|
137
|
+
return this._native.searchBatch(queries, k, ef);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
get(id) {
|
|
141
|
+
return this._native.get(id);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
delete(ids) {
|
|
145
|
+
return this._native.delete(ids);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
deleteByFilter(filter) {
|
|
149
|
+
return this._native.deleteByFilter(filter);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
count(filter) {
|
|
153
|
+
return this._native.count(filter);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
update(id, vector, metadata) {
|
|
157
|
+
return this._native.update(id, vector, metadata);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
get length() {
|
|
161
|
+
return this._native.length;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
get dimensions() {
|
|
165
|
+
return this._native.dimensions;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
isEmpty() {
|
|
169
|
+
return this._native.isEmpty();
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
stats() {
|
|
173
|
+
return this._native.stats();
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
get efSearch() {
|
|
177
|
+
return this._native.efSearch;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
set efSearch(value) {
|
|
181
|
+
this._native.efSearch = value;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
collection(name) {
|
|
185
|
+
return new VectorDatabase(this._native.collection(name));
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
collections() {
|
|
189
|
+
return this._native.collections();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
deleteCollection(name) {
|
|
193
|
+
return this._native.deleteCollection(name);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
enableTextSearch() {
|
|
197
|
+
return this._native.enableTextSearch();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
get hasTextSearch() {
|
|
201
|
+
return this._native.hasTextSearch;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
setWithText(items) {
|
|
205
|
+
return this._native.setWithText(items.map(convertVectorItem));
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
textSearch(query, k) {
|
|
209
|
+
return this._native.textSearch(query, k);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
hybridSearch(queryVector, queryText, k, filter, alpha, rrfK, subscores) {
|
|
213
|
+
return this._native.hybridSearch(
|
|
214
|
+
queryVector,
|
|
215
|
+
queryText,
|
|
216
|
+
k,
|
|
217
|
+
filter,
|
|
218
|
+
alpha,
|
|
219
|
+
rrfK,
|
|
220
|
+
subscores,
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
flush() {
|
|
225
|
+
return this._native.flush();
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
optimize() {
|
|
229
|
+
return this._native.optimize();
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
mergeFrom(other) {
|
|
233
|
+
return this._native.mergeFrom(other._native);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
ids() {
|
|
237
|
+
return this._native.ids();
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
items() {
|
|
241
|
+
return this._native.items();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
exists(id) {
|
|
245
|
+
return this._native.exists(id);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
getBatch(ids) {
|
|
249
|
+
return this._native.getBatch(ids);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function open(path, options) {
|
|
254
|
+
return new VectorDatabase(nativeBinding.open(path, options));
|
|
255
|
+
}
|
|
105
256
|
|
|
106
257
|
module.exports.VectorDatabase = VectorDatabase;
|
|
107
258
|
module.exports.open = open;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@omendb/omendb",
|
|
3
|
-
"version": "0.0.
|
|
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.
|
|
54
|
-
"@omendb/omendb-darwin-arm64": "0.0.
|
|
55
|
-
"@omendb/omendb-linux-x64-gnu": "0.0.
|
|
56
|
-
"@omendb/omendb-linux-arm64-gnu": "0.0.
|
|
57
|
-
"@omendb/omendb-win32-x64-msvc": "0.0.
|
|
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
|
}
|