@wiscale/velesdb-wasm 1.3.1 → 1.5.1
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/README.md +80 -8
- package/package.json +1 -1
- package/velesdb_wasm.d.ts +965 -449
- package/velesdb_wasm.js +2540 -1376
- package/velesdb_wasm_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -89,18 +89,14 @@ class VectorStore {
|
|
|
89
89
|
|
|
90
90
|
// Methods
|
|
91
91
|
insert(id: bigint, vector: Float32Array): void;
|
|
92
|
-
insert_with_payload(id: bigint, vector: Float32Array, payload: object): void; //
|
|
93
|
-
insert_batch(batch: Array<[bigint, number[]]>): void; // Bulk insert
|
|
92
|
+
insert_with_payload(id: bigint, vector: Float32Array, payload: object): void; insert_batch(batch: Array<[bigint, number[]]>): void; // Bulk insert
|
|
94
93
|
search(query: Float32Array, k: number): Array<[bigint, number]>;
|
|
95
|
-
search_with_filter(query: Float32Array, k: number, filter: object): Array<{id, score, payload}>;
|
|
96
|
-
text_search(query: string, k: number, field?: string): Array<{id, score, payload}>; // v0.8.5+
|
|
97
|
-
get(id: bigint): {id, vector, payload} | null; // v0.8.5+
|
|
98
|
-
remove(id: bigint): boolean;
|
|
94
|
+
search_with_filter(query: Float32Array, k: number, filter: object): Array<{id, score, payload}>; text_search(query: string, k: number, field?: string): Array<{id, score, payload}>; get(id: bigint): {id, vector, payload} | null; remove(id: bigint): boolean;
|
|
99
95
|
clear(): void;
|
|
100
96
|
reserve(additional: number): void; // Pre-allocate memory
|
|
101
97
|
memory_usage(): number; // Accurate for each storage mode
|
|
102
98
|
|
|
103
|
-
//
|
|
99
|
+
//
|
|
104
100
|
multi_query_search(vectors: Float32Array, num_vectors: number, k: number, strategy?: string, rrf_k?: number): Array<[bigint, number]>;
|
|
105
101
|
hybrid_search(vector: Float32Array, text_query: string, k: number, vector_weight?: number, field?: string): Array<{id, score, payload}>;
|
|
106
102
|
batch_search(vectors: Float32Array, num_vectors: number, k: number): Array<Array<[bigint, number]>>;
|
|
@@ -111,7 +107,7 @@ class VectorStore {
|
|
|
111
107
|
}
|
|
112
108
|
```
|
|
113
109
|
|
|
114
|
-
### Filter Format
|
|
110
|
+
### Filter Format
|
|
115
111
|
|
|
116
112
|
```javascript
|
|
117
113
|
// Equality filter
|
|
@@ -246,6 +242,82 @@ Ultra-fast serialization thanks to contiguous memory layout:
|
|
|
246
242
|
- **Electron/Tauri apps** - Desktop AI without a server
|
|
247
243
|
- **PWA applications** - Full offline support with service workers
|
|
248
244
|
|
|
245
|
+
## ⚠️ Limitations vs REST Backend
|
|
246
|
+
|
|
247
|
+
The WASM build is optimized for client-side use cases but has some limitations compared to the full REST server.
|
|
248
|
+
|
|
249
|
+
### Feature Comparison
|
|
250
|
+
|
|
251
|
+
| Feature | WASM | REST Server |
|
|
252
|
+
|---------|------|-------------|
|
|
253
|
+
| Vector search (NEAR) | ✅ | ✅ |
|
|
254
|
+
| Metadata filtering | ✅ | ✅ |
|
|
255
|
+
| Hybrid search (vector + BM25) | ✅ | ✅ |
|
|
256
|
+
| Full-text search (BM25) | ✅ | ✅ |
|
|
257
|
+
| Multi-query fusion (MQG) | ✅ | ✅ |
|
|
258
|
+
| Batch search | ✅ | ✅ |
|
|
259
|
+
| Full VelesQL queries | ❌ | ✅ |
|
|
260
|
+
| Knowledge Graph operations | ❌ | ✅ |
|
|
261
|
+
| JOIN operations | ❌ | ✅ |
|
|
262
|
+
| Aggregations (GROUP BY) | ❌ | ✅ |
|
|
263
|
+
| Persistence | IndexedDB | Disk (mmap) |
|
|
264
|
+
| Max vectors | ~100K (browser RAM) | Millions |
|
|
265
|
+
|
|
266
|
+
### Unsupported Operations
|
|
267
|
+
|
|
268
|
+
When you try to use unsupported features, you'll get clear error messages:
|
|
269
|
+
|
|
270
|
+
```javascript
|
|
271
|
+
// ❌ VelesQL string queries not supported in WASM
|
|
272
|
+
// Use the native API instead:
|
|
273
|
+
|
|
274
|
+
// Instead of: store.query("SELECT * FROM docs WHERE vector NEAR $v")
|
|
275
|
+
// Use:
|
|
276
|
+
const results = store.search(queryVector, 10);
|
|
277
|
+
|
|
278
|
+
// Instead of: store.query("SELECT * FROM docs WHERE category = 'tech'")
|
|
279
|
+
// Use:
|
|
280
|
+
const results = store.search_with_filter(queryVector, 10, {
|
|
281
|
+
condition: { type: "eq", field: "category", value: "tech" }
|
|
282
|
+
});
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### When to Use REST Backend
|
|
286
|
+
|
|
287
|
+
Consider using the [REST server](https://github.com/cyberlife-coder/VelesDB) if you need:
|
|
288
|
+
|
|
289
|
+
- **Full VelesQL support** - Complex SQL-like queries with JOINs and aggregations
|
|
290
|
+
- **Knowledge Graph** - Entity relationships and graph traversal
|
|
291
|
+
- **Large datasets** - More than 100K vectors
|
|
292
|
+
- **Server-side processing** - Centralized vector database
|
|
293
|
+
|
|
294
|
+
### Migration from WASM to REST
|
|
295
|
+
|
|
296
|
+
```javascript
|
|
297
|
+
// WASM (client-side)
|
|
298
|
+
import { VectorStore } from '@wiscale/velesdb-wasm';
|
|
299
|
+
const store = new VectorStore(768, 'cosine');
|
|
300
|
+
const results = store.search(query, 10);
|
|
301
|
+
|
|
302
|
+
// REST (server-side) - using fetch
|
|
303
|
+
const response = await fetch('http://localhost:8080/collections/docs/search', {
|
|
304
|
+
method: 'POST',
|
|
305
|
+
headers: { 'Content-Type': 'application/json' },
|
|
306
|
+
body: JSON.stringify({ vector: query, top_k: 10 })
|
|
307
|
+
});
|
|
308
|
+
const results = await response.json();
|
|
309
|
+
|
|
310
|
+
// REST with VelesQL
|
|
311
|
+
const response = await fetch('http://localhost:8080/query', {
|
|
312
|
+
method: 'POST',
|
|
313
|
+
headers: { 'Content-Type': 'application/json' },
|
|
314
|
+
body: JSON.stringify({
|
|
315
|
+
query: "SELECT * FROM docs WHERE vector NEAR $v AND category = 'tech' LIMIT 10",
|
|
316
|
+
params: { v: query }
|
|
317
|
+
})
|
|
318
|
+
});
|
|
319
|
+
```
|
|
320
|
+
|
|
249
321
|
## Building from Source
|
|
250
322
|
|
|
251
323
|
```bash
|
package/package.json
CHANGED