hermes-wasm 1.8.31 → 1.8.32
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 +88 -34
- package/hermes_wasm.d.ts +65 -15
- package/hermes_wasm.js +119 -5
- package/hermes_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -131,43 +131,47 @@ const doc = await index.get_document(
|
|
|
131
131
|
|
|
132
132
|
### `LocalIndex`
|
|
133
133
|
|
|
134
|
-
| Method
|
|
135
|
-
|
|
|
136
|
-
| `LocalIndex.create(sdl)`
|
|
137
|
-
| `LocalIndex.withStorage(storage, sdl)`
|
|
138
|
-
| `index.addDocument(json)`
|
|
139
|
-
| `index.addDocuments(jsonArray)`
|
|
140
|
-
| `index.commit()`
|
|
141
|
-
| `index.search(query, limit)`
|
|
142
|
-
| `index.searchOffset(query, limit, offset)`
|
|
143
|
-
| `index.
|
|
144
|
-
| `index.
|
|
145
|
-
| `index.
|
|
146
|
-
| `index.
|
|
134
|
+
| Method | Description |
|
|
135
|
+
| ------------------------------------------------------- | -------------------------------------------------- |
|
|
136
|
+
| `LocalIndex.create(sdl)` | Create in-memory index from SDL schema |
|
|
137
|
+
| `LocalIndex.withStorage(storage, sdl)` | Create or open index with pluggable storage |
|
|
138
|
+
| `index.addDocument(json)` | Add a single document |
|
|
139
|
+
| `index.addDocuments(jsonArray)` | Add multiple documents, returns count |
|
|
140
|
+
| `index.commit()` | Commit pending docs, sync to storage if configured |
|
|
141
|
+
| `index.search(query, limit)` | Search with BM25 ranking |
|
|
142
|
+
| `index.searchOffset(query, limit, offset)` | Search with pagination |
|
|
143
|
+
| `index.searchStructured(request)` | Structured query with inline doc retrieval |
|
|
144
|
+
| `index.getDocument(segmentId, docId)` | Retrieve stored document |
|
|
145
|
+
| `index.getDocumentWithFields(segmentId, docId, fields)` | Retrieve only specified fields |
|
|
146
|
+
| `index.numDocs()` | Count of committed documents |
|
|
147
|
+
| `index.pendingDocs()` | Count of uncommitted documents |
|
|
148
|
+
| `index.fieldNames()` | List of field names |
|
|
147
149
|
|
|
148
150
|
### `RemoteIndex`
|
|
149
151
|
|
|
150
|
-
| Method
|
|
151
|
-
|
|
|
152
|
-
| `new RemoteIndex(url)`
|
|
153
|
-
| `RemoteIndex.with_cache_size(url, bytes)`
|
|
154
|
-
| `index.load()`
|
|
155
|
-
| `index.load_with_idb_cache()`
|
|
156
|
-
| `index.search(query, limit)`
|
|
157
|
-
| `index.search_offset(query, limit, offset)`
|
|
158
|
-
| `index.
|
|
159
|
-
| `index.
|
|
160
|
-
| `index.
|
|
161
|
-
| `index.
|
|
162
|
-
| `index.
|
|
163
|
-
| `index.
|
|
164
|
-
| `index.
|
|
165
|
-
| `index.
|
|
166
|
-
| `index.
|
|
167
|
-
| `index.
|
|
168
|
-
| `index.
|
|
169
|
-
| `index.
|
|
170
|
-
| `index.
|
|
152
|
+
| Method | Description |
|
|
153
|
+
| ---------------------------------------------------------- | ----------------------------------- |
|
|
154
|
+
| `new RemoteIndex(url)` | Create remote index pointing to URL |
|
|
155
|
+
| `RemoteIndex.with_cache_size(url, bytes)` | Create with custom cache size |
|
|
156
|
+
| `index.load()` | Load index metadata and segments |
|
|
157
|
+
| `index.load_with_idb_cache()` | Load with IndexedDB cache pre-fill |
|
|
158
|
+
| `index.search(query, limit)` | Search |
|
|
159
|
+
| `index.search_offset(query, limit, offset)` | Search with pagination |
|
|
160
|
+
| `index.searchStructured(request)` | Structured query with inline docs |
|
|
161
|
+
| `index.get_document(segmentId, docId)` | Retrieve document |
|
|
162
|
+
| `index.get_document_with_fields(segmentId, docId, fields)` | Retrieve only specified fields |
|
|
163
|
+
| `index.num_docs()` | Document count |
|
|
164
|
+
| `index.num_segments()` | Segment count |
|
|
165
|
+
| `index.field_names()` | Field names |
|
|
166
|
+
| `index.default_fields()` | Default search fields |
|
|
167
|
+
| `index.export_cache()` | Export slice cache as `Uint8Array` |
|
|
168
|
+
| `index.import_cache(data)` | Import previously exported cache |
|
|
169
|
+
| `index.save_cache_to_idb()` | Persist slice cache to IndexedDB |
|
|
170
|
+
| `index.load_cache_from_idb()` | Restore cache from IndexedDB |
|
|
171
|
+
| `index.clear_idb_cache()` | Remove persisted cache |
|
|
172
|
+
| `index.cache_stats()` | Cache utilization info |
|
|
173
|
+
| `index.network_stats()` | HTTP request statistics |
|
|
174
|
+
| `index.reset_network_stats()` | Clear network statistics |
|
|
171
175
|
|
|
172
176
|
### `IpfsIndex`
|
|
173
177
|
|
|
@@ -185,6 +189,16 @@ Same API as `RemoteIndex` but loaded via JavaScript callbacks instead of HTTP:
|
|
|
185
189
|
|
|
186
190
|
All other methods (`search`, `get_document`, `cache_stats`, etc.) are identical to `RemoteIndex`.
|
|
187
191
|
|
|
192
|
+
### Logging
|
|
193
|
+
|
|
194
|
+
Debug output is off by default (level: `warn`). Enable verbose logging for diagnostics:
|
|
195
|
+
|
|
196
|
+
```js
|
|
197
|
+
import { set_log_level } from "hermes-wasm";
|
|
198
|
+
|
|
199
|
+
set_log_level("debug"); // "error" | "warn" | "info" | "debug" | "trace"
|
|
200
|
+
```
|
|
201
|
+
|
|
188
202
|
### `IndexRegistry`
|
|
189
203
|
|
|
190
204
|
Manages multiple named remote indexes:
|
|
@@ -223,6 +237,46 @@ index <name> {
|
|
|
223
237
|
| Group | `(rust OR go) AND web` | Grouping |
|
|
224
238
|
| Phrase | `"search engine"` | Exact phrase |
|
|
225
239
|
|
|
240
|
+
### Structured Query API
|
|
241
|
+
|
|
242
|
+
`searchStructured()` accepts a query object and returns hits with documents inline:
|
|
243
|
+
|
|
244
|
+
```js
|
|
245
|
+
const results = await index.searchStructured({
|
|
246
|
+
query: { term: { field: "title", value: "rust" } },
|
|
247
|
+
limit: 10,
|
|
248
|
+
offset: 0,
|
|
249
|
+
fieldsToLoad: ["title", "body"],
|
|
250
|
+
});
|
|
251
|
+
// { hits: [{ address, score, doc: { title: "...", body: "..." } }], total_hits }
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
**Query types:**
|
|
255
|
+
|
|
256
|
+
```js
|
|
257
|
+
// Term query (tokenized with field's stemmer)
|
|
258
|
+
{ term: { field: "title", value: "rust" } }
|
|
259
|
+
|
|
260
|
+
// Match query (tokenized, OR across tokens)
|
|
261
|
+
{ match: { field: "body", text: "search engine" } }
|
|
262
|
+
|
|
263
|
+
// Boolean query (recursive composition)
|
|
264
|
+
{ boolean: {
|
|
265
|
+
must: [{ term: { field: "title", value: "rust" } }],
|
|
266
|
+
should: [{ match: { field: "body", text: "fast" } }],
|
|
267
|
+
mustNot: [{ term: { field: "title", value: "python" } }],
|
|
268
|
+
} }
|
|
269
|
+
|
|
270
|
+
// Prefix query
|
|
271
|
+
{ prefix: { field: "title", value: "rus" } }
|
|
272
|
+
|
|
273
|
+
// Sparse vector query (pre-tokenized)
|
|
274
|
+
{ sparseVector: { field: "emb", indices: [1, 5, 10], values: [0.5, 0.3, 0.2] } }
|
|
275
|
+
|
|
276
|
+
// Dense vector query (ANN)
|
|
277
|
+
{ denseVector: { field: "emb", vector: [0.1, 0.2, 0.3], nprobe: 32 } }
|
|
278
|
+
```
|
|
279
|
+
|
|
226
280
|
## Building
|
|
227
281
|
|
|
228
282
|
```bash
|
package/hermes_wasm.d.ts
CHANGED
|
@@ -55,6 +55,10 @@ export class IpfsIndex {
|
|
|
55
55
|
* Get field names
|
|
56
56
|
*/
|
|
57
57
|
field_names(): any;
|
|
58
|
+
/**
|
|
59
|
+
* Get a document by address, loading only the specified fields.
|
|
60
|
+
*/
|
|
61
|
+
getDocumentWithFields(segment_id: string, doc_id: number, fields_to_load: string[]): Promise<any>;
|
|
58
62
|
/**
|
|
59
63
|
* Get a document by address
|
|
60
64
|
*/
|
|
@@ -118,6 +122,10 @@ export class IpfsIndex {
|
|
|
118
122
|
* Use `get_document(hit.address.segment_id, hit.address.doc_id)` to fetch document content.
|
|
119
123
|
*/
|
|
120
124
|
search(query_str: string, limit: number): Promise<any>;
|
|
125
|
+
/**
|
|
126
|
+
* Structured search: accepts a query object instead of a query string.
|
|
127
|
+
*/
|
|
128
|
+
searchStructured(request: any): Promise<any>;
|
|
121
129
|
/**
|
|
122
130
|
* Search the index with offset for pagination
|
|
123
131
|
*/
|
|
@@ -171,6 +179,12 @@ export class LocalIndex {
|
|
|
171
179
|
* Get a document by its address.
|
|
172
180
|
*/
|
|
173
181
|
getDocument(segment_id: string, doc_id: number): Promise<any>;
|
|
182
|
+
/**
|
|
183
|
+
* Get a document by its address, loading only the specified fields.
|
|
184
|
+
*
|
|
185
|
+
* `fields_to_load` is a JS array of field name strings, e.g. `["title", "body"]`.
|
|
186
|
+
*/
|
|
187
|
+
getDocumentWithFields(segment_id: string, doc_id: number, fields_to_load: string[]): Promise<any>;
|
|
174
188
|
/**
|
|
175
189
|
* Number of indexed documents (across all committed segments).
|
|
176
190
|
*/
|
|
@@ -189,6 +203,19 @@ export class LocalIndex {
|
|
|
189
203
|
* Search with offset for pagination.
|
|
190
204
|
*/
|
|
191
205
|
searchOffset(query_str: string, limit: number, offset: number): Promise<any>;
|
|
206
|
+
/**
|
|
207
|
+
* Structured search: accepts a query object instead of a query string.
|
|
208
|
+
*
|
|
209
|
+
* ```js
|
|
210
|
+
* const results = await index.searchStructured({
|
|
211
|
+
* query: { boolean: { must: [{ term: { field: "title", value: "rust" } }] } },
|
|
212
|
+
* limit: 10,
|
|
213
|
+
* offset: 0,
|
|
214
|
+
* fieldsToLoad: ["title"],
|
|
215
|
+
* });
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
searchStructured(request: any): Promise<any>;
|
|
192
219
|
/**
|
|
193
220
|
* Create or open an index with a pluggable storage backend.
|
|
194
221
|
*
|
|
@@ -237,6 +264,13 @@ export class RemoteIndex {
|
|
|
237
264
|
* Get field names
|
|
238
265
|
*/
|
|
239
266
|
field_names(): any;
|
|
267
|
+
/**
|
|
268
|
+
* Get a document by its address, loading only the specified fields.
|
|
269
|
+
*
|
|
270
|
+
* `fields_to_load` is a JS array of field name strings, e.g. `["title", "body"]`.
|
|
271
|
+
* Only the requested fields are returned (skips expensive reads for dense vectors).
|
|
272
|
+
*/
|
|
273
|
+
getDocumentWithFields(segment_id: string, doc_id: number, fields_to_load: string[]): Promise<any>;
|
|
240
274
|
/**
|
|
241
275
|
* Get a document by its address (segment_id + doc_id)
|
|
242
276
|
*
|
|
@@ -307,6 +341,10 @@ export class RemoteIndex {
|
|
|
307
341
|
* Use `get_document(hit.address.segment_id, hit.address.doc_id)` to fetch document content.
|
|
308
342
|
*/
|
|
309
343
|
search(query_str: string, limit: number): Promise<any>;
|
|
344
|
+
/**
|
|
345
|
+
* Structured search: accepts a query object instead of a query string.
|
|
346
|
+
*/
|
|
347
|
+
searchStructured(request: any): Promise<any>;
|
|
310
348
|
/**
|
|
311
349
|
* Search with offset for pagination
|
|
312
350
|
*/
|
|
@@ -318,10 +356,15 @@ export class RemoteIndex {
|
|
|
318
356
|
}
|
|
319
357
|
|
|
320
358
|
/**
|
|
321
|
-
* Initialize panic hook and logging
|
|
359
|
+
* Initialize panic hook and logging (defaults to Warn level)
|
|
322
360
|
*/
|
|
323
361
|
export function init(): void;
|
|
324
362
|
|
|
363
|
+
/**
|
|
364
|
+
* Set log level: "error", "warn", "info", "debug", "trace", "off"
|
|
365
|
+
*/
|
|
366
|
+
export function set_log_level(level: string): void;
|
|
367
|
+
|
|
325
368
|
/**
|
|
326
369
|
* Setup logging to browser console (can be called explicitly)
|
|
327
370
|
*/
|
|
@@ -331,6 +374,20 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
331
374
|
|
|
332
375
|
export interface InitOutput {
|
|
333
376
|
readonly memory: WebAssembly.Memory;
|
|
377
|
+
readonly __wbg_localindex_free: (a: number, b: number) => void;
|
|
378
|
+
readonly localindex_addDocument: (a: number, b: any) => any;
|
|
379
|
+
readonly localindex_addDocuments: (a: number, b: any) => any;
|
|
380
|
+
readonly localindex_commit: (a: number) => any;
|
|
381
|
+
readonly localindex_create: (a: number, b: number) => any;
|
|
382
|
+
readonly localindex_fieldNames: (a: number) => any;
|
|
383
|
+
readonly localindex_getDocument: (a: number, b: number, c: number, d: number) => any;
|
|
384
|
+
readonly localindex_getDocumentWithFields: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
|
|
385
|
+
readonly localindex_numDocs: (a: number) => number;
|
|
386
|
+
readonly localindex_pendingDocs: (a: number) => number;
|
|
387
|
+
readonly localindex_search: (a: number, b: number, c: number, d: number) => any;
|
|
388
|
+
readonly localindex_searchOffset: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
389
|
+
readonly localindex_searchStructured: (a: number, b: any) => any;
|
|
390
|
+
readonly localindex_withStorage: (a: any, b: number, c: number) => any;
|
|
334
391
|
readonly __wbg_indexregistry_free: (a: number, b: number) => void;
|
|
335
392
|
readonly __wbg_ipfsindex_free: (a: number, b: number) => void;
|
|
336
393
|
readonly __wbg_remoteindex_free: (a: number, b: number) => void;
|
|
@@ -344,6 +401,7 @@ export interface InitOutput {
|
|
|
344
401
|
readonly ipfsindex_default_fields: (a: number) => any;
|
|
345
402
|
readonly ipfsindex_export_cache: (a: number) => [number, number];
|
|
346
403
|
readonly ipfsindex_field_names: (a: number) => any;
|
|
404
|
+
readonly ipfsindex_getDocumentWithFields: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
|
|
347
405
|
readonly ipfsindex_get_document: (a: number, b: number, c: number, d: number) => any;
|
|
348
406
|
readonly ipfsindex_import_cache: (a: number, b: number, c: number) => [number, number];
|
|
349
407
|
readonly ipfsindex_load: (a: number, b: any, c: any) => any;
|
|
@@ -356,6 +414,7 @@ export interface InitOutput {
|
|
|
356
414
|
readonly ipfsindex_reset_network_stats: (a: number) => void;
|
|
357
415
|
readonly ipfsindex_save_cache_to_idb: (a: number) => any;
|
|
358
416
|
readonly ipfsindex_search: (a: number, b: number, c: number, d: number) => any;
|
|
417
|
+
readonly ipfsindex_searchStructured: (a: number, b: any) => any;
|
|
359
418
|
readonly ipfsindex_search_offset: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
360
419
|
readonly ipfsindex_with_cache_size: (a: number, b: number, c: number) => number;
|
|
361
420
|
readonly remoteindex_cache_stats: (a: number) => any;
|
|
@@ -363,6 +422,7 @@ export interface InitOutput {
|
|
|
363
422
|
readonly remoteindex_default_fields: (a: number) => any;
|
|
364
423
|
readonly remoteindex_export_cache: (a: number) => [number, number];
|
|
365
424
|
readonly remoteindex_field_names: (a: number) => any;
|
|
425
|
+
readonly remoteindex_getDocumentWithFields: (a: number, b: number, c: number, d: number, e: number, f: number) => any;
|
|
366
426
|
readonly remoteindex_get_document: (a: number, b: number, c: number, d: number) => any;
|
|
367
427
|
readonly remoteindex_import_cache: (a: number, b: number, c: number) => [number, number];
|
|
368
428
|
readonly remoteindex_load: (a: number) => any;
|
|
@@ -373,24 +433,14 @@ export interface InitOutput {
|
|
|
373
433
|
readonly remoteindex_reset_network_stats: (a: number) => void;
|
|
374
434
|
readonly remoteindex_save_cache_to_idb: (a: number) => any;
|
|
375
435
|
readonly remoteindex_search: (a: number, b: number, c: number, d: number) => any;
|
|
436
|
+
readonly remoteindex_searchStructured: (a: number, b: any) => any;
|
|
376
437
|
readonly remoteindex_search_offset: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
377
438
|
readonly remoteindex_with_cache_size: (a: number, b: number, c: number) => number;
|
|
378
|
-
readonly
|
|
379
|
-
readonly remoteindex_num_segments: (a: number) => number;
|
|
380
|
-
readonly __wbg_localindex_free: (a: number, b: number) => void;
|
|
381
|
-
readonly localindex_addDocument: (a: number, b: any) => any;
|
|
382
|
-
readonly localindex_addDocuments: (a: number, b: any) => any;
|
|
383
|
-
readonly localindex_commit: (a: number) => any;
|
|
384
|
-
readonly localindex_create: (a: number, b: number) => any;
|
|
385
|
-
readonly localindex_fieldNames: (a: number) => any;
|
|
386
|
-
readonly localindex_getDocument: (a: number, b: number, c: number, d: number) => any;
|
|
387
|
-
readonly localindex_numDocs: (a: number) => number;
|
|
388
|
-
readonly localindex_pendingDocs: (a: number) => number;
|
|
389
|
-
readonly localindex_search: (a: number, b: number, c: number, d: number) => any;
|
|
390
|
-
readonly localindex_searchOffset: (a: number, b: number, c: number, d: number, e: number) => any;
|
|
391
|
-
readonly localindex_withStorage: (a: any, b: number, c: number) => any;
|
|
439
|
+
readonly set_log_level: (a: number, b: number) => void;
|
|
392
440
|
readonly init: () => void;
|
|
393
441
|
readonly setup_logging: () => void;
|
|
442
|
+
readonly remoteindex_num_docs: (a: number) => number;
|
|
443
|
+
readonly remoteindex_num_segments: (a: number) => number;
|
|
394
444
|
readonly rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
|
|
395
445
|
readonly rust_zstd_wasm_shim_free: (a: number) => void;
|
|
396
446
|
readonly rust_zstd_wasm_shim_malloc: (a: number) => number;
|
package/hermes_wasm.js
CHANGED
|
@@ -138,6 +138,21 @@ export class IpfsIndex {
|
|
|
138
138
|
const ret = wasm.ipfsindex_field_names(this.__wbg_ptr);
|
|
139
139
|
return ret;
|
|
140
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Get a document by address, loading only the specified fields.
|
|
143
|
+
* @param {string} segment_id
|
|
144
|
+
* @param {number} doc_id
|
|
145
|
+
* @param {string[]} fields_to_load
|
|
146
|
+
* @returns {Promise<any>}
|
|
147
|
+
*/
|
|
148
|
+
getDocumentWithFields(segment_id, doc_id, fields_to_load) {
|
|
149
|
+
const ptr0 = passStringToWasm0(segment_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
150
|
+
const len0 = WASM_VECTOR_LEN;
|
|
151
|
+
const ptr1 = passArrayJsValueToWasm0(fields_to_load, wasm.__wbindgen_malloc);
|
|
152
|
+
const len1 = WASM_VECTOR_LEN;
|
|
153
|
+
const ret = wasm.ipfsindex_getDocumentWithFields(this.__wbg_ptr, ptr0, len0, doc_id, ptr1, len1);
|
|
154
|
+
return ret;
|
|
155
|
+
}
|
|
141
156
|
/**
|
|
142
157
|
* Get a document by address
|
|
143
158
|
* @param {string} segment_id
|
|
@@ -267,6 +282,15 @@ export class IpfsIndex {
|
|
|
267
282
|
const ret = wasm.ipfsindex_search(this.__wbg_ptr, ptr0, len0, limit);
|
|
268
283
|
return ret;
|
|
269
284
|
}
|
|
285
|
+
/**
|
|
286
|
+
* Structured search: accepts a query object instead of a query string.
|
|
287
|
+
* @param {any} request
|
|
288
|
+
* @returns {Promise<any>}
|
|
289
|
+
*/
|
|
290
|
+
searchStructured(request) {
|
|
291
|
+
const ret = wasm.ipfsindex_searchStructured(this.__wbg_ptr, request);
|
|
292
|
+
return ret;
|
|
293
|
+
}
|
|
270
294
|
/**
|
|
271
295
|
* Search the index with offset for pagination
|
|
272
296
|
* @param {string} query_str
|
|
@@ -385,6 +409,23 @@ export class LocalIndex {
|
|
|
385
409
|
const ret = wasm.localindex_getDocument(this.__wbg_ptr, ptr0, len0, doc_id);
|
|
386
410
|
return ret;
|
|
387
411
|
}
|
|
412
|
+
/**
|
|
413
|
+
* Get a document by its address, loading only the specified fields.
|
|
414
|
+
*
|
|
415
|
+
* `fields_to_load` is a JS array of field name strings, e.g. `["title", "body"]`.
|
|
416
|
+
* @param {string} segment_id
|
|
417
|
+
* @param {number} doc_id
|
|
418
|
+
* @param {string[]} fields_to_load
|
|
419
|
+
* @returns {Promise<any>}
|
|
420
|
+
*/
|
|
421
|
+
getDocumentWithFields(segment_id, doc_id, fields_to_load) {
|
|
422
|
+
const ptr0 = passStringToWasm0(segment_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
423
|
+
const len0 = WASM_VECTOR_LEN;
|
|
424
|
+
const ptr1 = passArrayJsValueToWasm0(fields_to_load, wasm.__wbindgen_malloc);
|
|
425
|
+
const len1 = WASM_VECTOR_LEN;
|
|
426
|
+
const ret = wasm.localindex_getDocumentWithFields(this.__wbg_ptr, ptr0, len0, doc_id, ptr1, len1);
|
|
427
|
+
return ret;
|
|
428
|
+
}
|
|
388
429
|
/**
|
|
389
430
|
* Number of indexed documents (across all committed segments).
|
|
390
431
|
* @returns {number}
|
|
@@ -428,6 +469,24 @@ export class LocalIndex {
|
|
|
428
469
|
const ret = wasm.localindex_searchOffset(this.__wbg_ptr, ptr0, len0, limit, offset);
|
|
429
470
|
return ret;
|
|
430
471
|
}
|
|
472
|
+
/**
|
|
473
|
+
* Structured search: accepts a query object instead of a query string.
|
|
474
|
+
*
|
|
475
|
+
* ```js
|
|
476
|
+
* const results = await index.searchStructured({
|
|
477
|
+
* query: { boolean: { must: [{ term: { field: "title", value: "rust" } }] } },
|
|
478
|
+
* limit: 10,
|
|
479
|
+
* offset: 0,
|
|
480
|
+
* fieldsToLoad: ["title"],
|
|
481
|
+
* });
|
|
482
|
+
* ```
|
|
483
|
+
* @param {any} request
|
|
484
|
+
* @returns {Promise<any>}
|
|
485
|
+
*/
|
|
486
|
+
searchStructured(request) {
|
|
487
|
+
const ret = wasm.localindex_searchStructured(this.__wbg_ptr, request);
|
|
488
|
+
return ret;
|
|
489
|
+
}
|
|
431
490
|
/**
|
|
432
491
|
* Create or open an index with a pluggable storage backend.
|
|
433
492
|
*
|
|
@@ -525,6 +584,24 @@ export class RemoteIndex {
|
|
|
525
584
|
const ret = wasm.remoteindex_field_names(this.__wbg_ptr);
|
|
526
585
|
return ret;
|
|
527
586
|
}
|
|
587
|
+
/**
|
|
588
|
+
* Get a document by its address, loading only the specified fields.
|
|
589
|
+
*
|
|
590
|
+
* `fields_to_load` is a JS array of field name strings, e.g. `["title", "body"]`.
|
|
591
|
+
* Only the requested fields are returned (skips expensive reads for dense vectors).
|
|
592
|
+
* @param {string} segment_id
|
|
593
|
+
* @param {number} doc_id
|
|
594
|
+
* @param {string[]} fields_to_load
|
|
595
|
+
* @returns {Promise<any>}
|
|
596
|
+
*/
|
|
597
|
+
getDocumentWithFields(segment_id, doc_id, fields_to_load) {
|
|
598
|
+
const ptr0 = passStringToWasm0(segment_id, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
599
|
+
const len0 = WASM_VECTOR_LEN;
|
|
600
|
+
const ptr1 = passArrayJsValueToWasm0(fields_to_load, wasm.__wbindgen_malloc);
|
|
601
|
+
const len1 = WASM_VECTOR_LEN;
|
|
602
|
+
const ret = wasm.remoteindex_getDocumentWithFields(this.__wbg_ptr, ptr0, len0, doc_id, ptr1, len1);
|
|
603
|
+
return ret;
|
|
604
|
+
}
|
|
528
605
|
/**
|
|
529
606
|
* Get a document by its address (segment_id + doc_id)
|
|
530
607
|
*
|
|
@@ -657,6 +734,15 @@ export class RemoteIndex {
|
|
|
657
734
|
const ret = wasm.remoteindex_search(this.__wbg_ptr, ptr0, len0, limit);
|
|
658
735
|
return ret;
|
|
659
736
|
}
|
|
737
|
+
/**
|
|
738
|
+
* Structured search: accepts a query object instead of a query string.
|
|
739
|
+
* @param {any} request
|
|
740
|
+
* @returns {Promise<any>}
|
|
741
|
+
*/
|
|
742
|
+
searchStructured(request) {
|
|
743
|
+
const ret = wasm.remoteindex_searchStructured(this.__wbg_ptr, request);
|
|
744
|
+
return ret;
|
|
745
|
+
}
|
|
660
746
|
/**
|
|
661
747
|
* Search with offset for pagination
|
|
662
748
|
* @param {string} query_str
|
|
@@ -686,12 +772,22 @@ export class RemoteIndex {
|
|
|
686
772
|
if (Symbol.dispose) RemoteIndex.prototype[Symbol.dispose] = RemoteIndex.prototype.free;
|
|
687
773
|
|
|
688
774
|
/**
|
|
689
|
-
* Initialize panic hook and logging
|
|
775
|
+
* Initialize panic hook and logging (defaults to Warn level)
|
|
690
776
|
*/
|
|
691
777
|
export function init() {
|
|
692
778
|
wasm.init();
|
|
693
779
|
}
|
|
694
780
|
|
|
781
|
+
/**
|
|
782
|
+
* Set log level: "error", "warn", "info", "debug", "trace", "off"
|
|
783
|
+
* @param {string} level
|
|
784
|
+
*/
|
|
785
|
+
export function set_log_level(level) {
|
|
786
|
+
const ptr0 = passStringToWasm0(level, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
787
|
+
const len0 = WASM_VECTOR_LEN;
|
|
788
|
+
wasm.set_log_level(ptr0, len0);
|
|
789
|
+
}
|
|
790
|
+
|
|
695
791
|
/**
|
|
696
792
|
* Setup logging to browser console (can be called explicitly)
|
|
697
793
|
*/
|
|
@@ -706,6 +802,10 @@ function __wbg_get_imports() {
|
|
|
706
802
|
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
707
803
|
return ret;
|
|
708
804
|
},
|
|
805
|
+
__wbg_Number_a5a435bd7bbec835: function(arg0) {
|
|
806
|
+
const ret = Number(arg0);
|
|
807
|
+
return ret;
|
|
808
|
+
},
|
|
709
809
|
__wbg_String_8564e559799eccda: function(arg0, arg1) {
|
|
710
810
|
const ret = String(arg1);
|
|
711
811
|
const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
@@ -901,6 +1001,10 @@ function __wbg_get_imports() {
|
|
|
901
1001
|
const ret = arg0[arg1 >>> 0];
|
|
902
1002
|
return ret;
|
|
903
1003
|
},
|
|
1004
|
+
__wbg_get_with_ref_key_6412cf3094599694: function(arg0, arg1) {
|
|
1005
|
+
const ret = arg0[arg1];
|
|
1006
|
+
return ret;
|
|
1007
|
+
},
|
|
904
1008
|
__wbg_has_926ef2ff40b308cf: function() { return handleError(function (arg0, arg1) {
|
|
905
1009
|
const ret = Reflect.has(arg0, arg1);
|
|
906
1010
|
return ret;
|
|
@@ -1244,22 +1348,22 @@ function __wbg_get_imports() {
|
|
|
1244
1348
|
console.warn(arg0);
|
|
1245
1349
|
},
|
|
1246
1350
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
1247
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1351
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 212, function: Function { arguments: [NamedExternref("Event")], shim_idx: 213, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1248
1352
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen_efede8c867e8014b___closure__destroy___dyn_core_5858575f5ab61d4b___ops__function__FnMut__web_sys_108d82c43c7519e2___features__gen_IdbVersionChangeEvent__IdbVersionChangeEvent____Output_______, wasm_bindgen_efede8c867e8014b___convert__closures_____invoke___web_sys_108d82c43c7519e2___features__gen_IdbVersionChangeEvent__IdbVersionChangeEvent______true_);
|
|
1249
1353
|
return ret;
|
|
1250
1354
|
},
|
|
1251
1355
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
1252
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1356
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 212, function: Function { arguments: [NamedExternref("IDBVersionChangeEvent")], shim_idx: 213, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1253
1357
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen_efede8c867e8014b___closure__destroy___dyn_core_5858575f5ab61d4b___ops__function__FnMut__web_sys_108d82c43c7519e2___features__gen_IdbVersionChangeEvent__IdbVersionChangeEvent____Output_______, wasm_bindgen_efede8c867e8014b___convert__closures_____invoke___web_sys_108d82c43c7519e2___features__gen_IdbVersionChangeEvent__IdbVersionChangeEvent______true__1);
|
|
1254
1358
|
return ret;
|
|
1255
1359
|
},
|
|
1256
1360
|
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
1257
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1361
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 800, function: Function { arguments: [], shim_idx: 801, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
1258
1362
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen_efede8c867e8014b___closure__destroy___dyn_core_5858575f5ab61d4b___ops__function__FnMut_____Output_______, wasm_bindgen_efede8c867e8014b___convert__closures_____invoke_______true_);
|
|
1259
1363
|
return ret;
|
|
1260
1364
|
},
|
|
1261
1365
|
__wbindgen_cast_0000000000000004: function(arg0, arg1) {
|
|
1262
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
1366
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 830, function: Function { arguments: [Externref], shim_idx: 831, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
|
|
1263
1367
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen_efede8c867e8014b___closure__destroy___dyn_core_5858575f5ab61d4b___ops__function__FnMut__wasm_bindgen_efede8c867e8014b___JsValue____Output___core_5858575f5ab61d4b___result__Result_____wasm_bindgen_efede8c867e8014b___JsError___, wasm_bindgen_efede8c867e8014b___convert__closures_____invoke___wasm_bindgen_efede8c867e8014b___JsValue__core_5858575f5ab61d4b___result__Result_____wasm_bindgen_efede8c867e8014b___JsError___true_);
|
|
1264
1368
|
return ret;
|
|
1265
1369
|
},
|
|
@@ -1495,6 +1599,16 @@ function passArray8ToWasm0(arg, malloc) {
|
|
|
1495
1599
|
return ptr;
|
|
1496
1600
|
}
|
|
1497
1601
|
|
|
1602
|
+
function passArrayJsValueToWasm0(array, malloc) {
|
|
1603
|
+
const ptr = malloc(array.length * 4, 4) >>> 0;
|
|
1604
|
+
for (let i = 0; i < array.length; i++) {
|
|
1605
|
+
const add = addToExternrefTable0(array[i]);
|
|
1606
|
+
getDataViewMemory0().setUint32(ptr + 4 * i, add, true);
|
|
1607
|
+
}
|
|
1608
|
+
WASM_VECTOR_LEN = array.length;
|
|
1609
|
+
return ptr;
|
|
1610
|
+
}
|
|
1611
|
+
|
|
1498
1612
|
function passStringToWasm0(arg, malloc, realloc) {
|
|
1499
1613
|
if (realloc === undefined) {
|
|
1500
1614
|
const buf = cachedTextEncoder.encode(arg);
|
package/hermes_wasm_bg.wasm
CHANGED
|
Binary file
|