@delali/narsil 0.3.1-next.127 → 0.3.1-next.129

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 (101) hide show
  1. package/dist/adapters/filesystem.mjs +1 -1
  2. package/dist/adapters/indexeddb.mjs +1 -1
  3. package/dist/browser/{chunk-LJS6PREA.mjs → chunk-3NVZD52E.mjs} +3 -1
  4. package/dist/browser/{chunk-4Y2EGA3U.mjs → chunk-5D6NJD6C.mjs} +554 -127
  5. package/dist/browser/{chunk-6POI2KNI.mjs → chunk-II5POT55.mjs} +3 -3
  6. package/dist/browser/{chunk-2CBQ2PCC.mjs → chunk-WLD6DDIX.mjs} +1 -1
  7. package/dist/browser/{chunk-V5DCQIOT.mjs → chunk-WZBTVTSU.mjs} +2 -2
  8. package/dist/browser/{chunk-B65QVTST.mjs → chunk-XTFJZHQP.mjs} +14 -9
  9. package/dist/browser/{chunk-P7C2S5JX.mjs → chunk-YAGXZU4W.mjs} +2 -2
  10. package/dist/browser/{durability-wiring-PUC4QSCR.mjs → durability-wiring-HCCC6BJB.mjs} +6 -6
  11. package/dist/browser/{module-ACWDC7YI.mjs → module-S2VDU2JE.mjs} +5 -5
  12. package/dist/browser/{restore-queue-MLUEUEAN.mjs → restore-queue-BZ7WWEC4.mjs} +1 -1
  13. package/dist/browser/{runtime-BX6XRFYR.mjs → runtime-PL4TTFJE.mjs} +1 -1
  14. package/dist/browser/{snapshot-U5Y346XG.mjs → snapshot-RTUCHI2L.mjs} +7 -7
  15. package/dist/browser/{write-GZHR6AVG.mjs → write-IMU7G5NU.mjs} +5 -5
  16. package/dist/{capabilities-9YwwCcqP.d.ts → capabilities-BTjv-tK8.d.ts} +10 -3
  17. package/dist/{chunk-N57XXGPG.mjs → chunk-2HQQ7Y5D.mjs} +23 -4
  18. package/dist/{chunk-ENBN5VQ6.mjs → chunk-2YOAGAGF.mjs} +115 -46
  19. package/dist/{chunk-QSCVJJW5.mjs → chunk-37RTD6KD.mjs} +8 -8
  20. package/dist/{chunk-N6J6EJW3.mjs → chunk-3LJVM6XM.mjs} +2 -2
  21. package/dist/{chunk-VK45J47R.mjs → chunk-3XHFVYIQ.mjs} +1 -1
  22. package/dist/{chunk-LOBYK2FG.mjs → chunk-43Q7HAI2.mjs} +20 -9
  23. package/dist/{chunk-6PN3U6XW.mjs → chunk-44TB6AIZ.mjs} +1 -1
  24. package/dist/{chunk-6ODIY6ZB.mjs → chunk-4XEVROSP.mjs} +1 -1
  25. package/dist/{chunk-4IHMMDRF.mjs → chunk-5LC5VMDQ.mjs} +4 -4
  26. package/dist/{chunk-MFPJVITN.mjs → chunk-5VSTAJET.mjs} +2 -2
  27. package/dist/{chunk-DG62H7OD.mjs → chunk-AFOZR4ZQ.mjs} +2 -2
  28. package/dist/{chunk-P34VZEXB.mjs → chunk-AN3CUMPZ.mjs} +2 -2
  29. package/dist/{chunk-4PQNDHSA.mjs → chunk-CSSCLRGY.mjs} +2 -2
  30. package/dist/{chunk-HWQDZB2U.mjs → chunk-CTF6WFTX.mjs} +3 -3
  31. package/dist/{chunk-E74YLAIG.mjs → chunk-DX2FI4LU.mjs} +2 -1
  32. package/dist/{chunk-22CK2LQO.mjs → chunk-EZIGAOUJ.mjs} +5 -5
  33. package/dist/{chunk-KCQG2PJT.mjs → chunk-F4UKMTKM.mjs} +4 -4
  34. package/dist/{chunk-542TD4BL.mjs → chunk-FRSWYMXH.mjs} +1 -1
  35. package/dist/{chunk-ANFNYCQG.mjs → chunk-J4LRE5Q7.mjs} +6 -6
  36. package/dist/{chunk-OGFSUXYY.mjs → chunk-K73PZTBR.mjs} +4 -4
  37. package/dist/{chunk-IBGMFR5Y.mjs → chunk-K76F5YYX.mjs} +274 -75
  38. package/dist/{chunk-FUUP45IS.mjs → chunk-M6MBSVIJ.mjs} +1 -1
  39. package/dist/{chunk-IR4KQ4WB.mjs → chunk-MGD7XETB.mjs} +32 -30
  40. package/dist/{chunk-7ZZQNOIY.mjs → chunk-OPO5SE4J.mjs} +1 -1
  41. package/dist/{chunk-UKXMSO5H.mjs → chunk-PCRWCOZC.mjs} +155 -31
  42. package/dist/{chunk-HFJXEFFV.mjs → chunk-PTIJAZWL.mjs} +3 -3
  43. package/dist/chunk-Q2AP2FSN.mjs +15 -0
  44. package/dist/{chunk-SEG4CL6W.mjs → chunk-QQS4QZQA.mjs} +4 -4
  45. package/dist/{chunk-OFYKBKKV.mjs → chunk-RC27KF7F.mjs} +1 -1
  46. package/dist/{chunk-JEXJDCQH.mjs → chunk-RYH3PASD.mjs} +17 -12
  47. package/dist/{chunk-IE43SRL3.mjs → chunk-TB7YMDD5.mjs} +10 -6
  48. package/dist/{chunk-ZR63OGT2.mjs → chunk-TY64A3ZW.mjs} +2 -2
  49. package/dist/{chunk-Z4DZ4KK2.mjs → chunk-UJWGQIXU.mjs} +1 -0
  50. package/dist/{chunk-OBWUWZRA.mjs → chunk-WI5Q3L43.mjs} +1 -0
  51. package/dist/{chunk-SJEIIR56.mjs → chunk-WQYB4TNR.mjs} +2 -2
  52. package/dist/{chunk-JIXO442E.mjs → chunk-WUIDPBSY.mjs} +16 -10
  53. package/dist/{chunk-62IPM62F.mjs → chunk-XRXBCOA4.mjs} +2 -2
  54. package/dist/{chunk-U6NGTWI3.mjs → chunk-XTER67YM.mjs} +1 -1
  55. package/dist/{chunk-LXWDQLTW.mjs → chunk-Y4NOHICF.mjs} +1 -1
  56. package/dist/{chunk-OCB7TMUQ.mjs → chunk-Y4US5EGH.mjs} +1 -1
  57. package/dist/{client-DyiYkQ8o.d.ts → client-BOcveV7A.d.ts} +34 -11
  58. package/dist/client.d.ts +8 -8
  59. package/dist/client.mjs +42 -20
  60. package/dist/{config-DLVnlByZ.d.ts → config-C3YXk5Rn.d.ts} +2 -2
  61. package/dist/{config-CtTfxbpV.d.ts → config-CPmIY3aH.d.ts} +2 -2
  62. package/dist/{direct-executor-6KCVVHYT.mjs → direct-executor-ULA6V5HC.mjs} +12 -12
  63. package/dist/distribution/coordinator/etcd.d.ts +2 -2
  64. package/dist/distribution/coordinator/etcd.mjs +18 -1
  65. package/dist/distribution/coordinator/in-memory.d.ts +2 -2
  66. package/dist/distribution/coordinator/in-memory.mjs +33 -1
  67. package/dist/distribution/transport/grpc.mjs +1 -1
  68. package/dist/distribution.d.ts +71 -43
  69. package/dist/distribution.mjs +359 -115
  70. package/dist/{durability-wiring-UGGUNATA.mjs → durability-wiring-6R26AJDI.mjs} +26 -26
  71. package/dist/embeddings/openai.mjs +2 -2
  72. package/dist/{engine-Bq5wz6c1.d.ts → engine-JjRAXpT3.d.ts} +38 -8
  73. package/dist/{events-x2aVu0_o.d.ts → events-pM0lna7M.d.ts} +12 -1
  74. package/dist/{index-Cl5qQauj.d.ts → index-DkQ2DlgR.d.ts} +37 -3
  75. package/dist/index.browser.mjs +3 -3
  76. package/dist/index.d.ts +7 -7
  77. package/dist/index.mjs +19 -19
  78. package/dist/{long-query-thread-5BIPZVS6.mjs → long-query-thread-6VLA6YJI.mjs} +15 -15
  79. package/dist/{module-7OHZ2OPI.mjs → module-S4WGMFNW.mjs} +11 -11
  80. package/dist/partial-words.mjs +6 -6
  81. package/dist/pattern.mjs +3 -3
  82. package/dist/persistence/durability/checkpoint-worker.d.ts +2 -1
  83. package/dist/persistence/durability/checkpoint-worker.mjs +22 -22
  84. package/dist/react.d.ts +7 -7
  85. package/dist/react.mjs +1 -0
  86. package/dist/{rerank-NYX5S7OG.mjs → rerank-V4J4MIWR.mjs} +6 -6
  87. package/dist/rerankers/http.mjs +2 -2
  88. package/dist/{restore-queue-NVMWJMHI.mjs → restore-queue-PUGWCPCX.mjs} +1 -1
  89. package/dist/{runtime-XNYW6AWX.mjs → runtime-TBFBQQQO.mjs} +7 -7
  90. package/dist/{schema-4W_7tk1f.d.ts → schema-DGAP_8HJ.d.ts} +50 -24
  91. package/dist/server.d.ts +10 -10
  92. package/dist/server.mjs +27 -15
  93. package/dist/{snapshot-P7IQGNNQ.mjs → snapshot-PUVSMV7E.mjs} +27 -27
  94. package/dist/synonyms.mjs +3 -3
  95. package/dist/{tasks-DLQIfXqy.d.ts → tasks-txGvNz6h.d.ts} +4 -6
  96. package/dist/{thread-QPETQEPK.mjs → thread-TA7QQBWP.mjs} +14 -14
  97. package/dist/vector/search-worker.d.ts +1 -1
  98. package/dist/vector/search-worker.mjs +4 -4
  99. package/dist/workers/entry.mjs +8 -8
  100. package/dist/{write-WZVM7ZL6.mjs → write-TGKYT3C4.mjs} +21 -21
  101. package/package.json +7 -7
@@ -1,12 +1,13 @@
1
- import { decodeVectorGraphPartPayload, assembleGraphParts, decodeVectorFilePayload, countDead, VECTOR_FILE_MAX_VECTORS, deadBytesFor } from './chunk-OCB7TMUQ.mjs';
2
- import { MAX_SEGMENT_ID, MANIFEST_ENVELOPE_VERSION, EARLIER_SEGMENT_MANIFEST_VERSION, SEGMENT_MANIFEST_VERSION, MAX_SEGMENTS_PER_PARTITION, segmentKey, readSegmentFile, manifestKey, segmentsPrefix, readListedFile, requireListedChecksum, vectorFileKey, graphPartKey } from './chunk-QSCVJJW5.mjs';
3
- import { VERSION, rulesOfStoredSynonyms, openChecksummedEnvelope, readHeader, HEADER_SIZE, crc32, engineVersionParts, writeHeader, packChecksummedEnvelope } from './chunk-ENBN5VQ6.mjs';
4
- import { decodeEveryStoredDocument, createSharedFrozenSegment, shareSegmentArrays } from './chunk-JEXJDCQH.mjs';
5
- import { flattenSchema, requireValidFieldTypes, isQuantizationMode, isStorageMode } from './chunk-DG62H7OD.mjs';
1
+ import { decodeVectorGraphPartPayload, assembleGraphParts, decodeVectorFilePayload, countDead, VECTOR_FILE_MAX_VECTORS, deadBytesFor } from './chunk-Y4US5EGH.mjs';
2
+ import { MAX_SEGMENT_ID, MANIFEST_ENVELOPE_VERSION, EARLIER_SEGMENT_MANIFEST_VERSION, SEGMENT_MANIFEST_VERSION, MAX_SEGMENTS_PER_PARTITION, segmentKey, readSegmentFile, manifestKey, segmentsPrefix, readListedFile, requireListedChecksum, vectorFileKey, graphPartKey } from './chunk-37RTD6KD.mjs';
3
+ import { VERSION, rulesOfStoredSynonyms, openChecksummedEnvelope, readHeader, HEADER_SIZE, crc32, engineVersionParts, writeHeader, packChecksummedEnvelope } from './chunk-2YOAGAGF.mjs';
4
+ import { decodeEveryStoredDocument, createSharedFrozenSegment, shareSegmentArrays } from './chunk-RYH3PASD.mjs';
5
+ import { DEFAULT_BM25_B, DEFAULT_BM25_K1 } from './chunk-K76F5YYX.mjs';
6
+ import { flattenSchema, requireValidFieldTypes, isQuantizationMode, isStorageMode } from './chunk-AFOZR4ZQ.mjs';
6
7
  import { MAX_FILE_BYTES, VALID_HNSW_METRICS } from './chunk-U476IXKQ.mjs';
7
8
  import { compareCodePoints } from './chunk-YTJCGKM4.mjs';
8
9
  import { VECTOR_PATTERN } from './chunk-L5ORED7V.mjs';
9
- import { NarsilError, ErrorCodes } from './chunk-OBWUWZRA.mjs';
10
+ import { NarsilError, ErrorCodes } from './chunk-WI5Q3L43.mjs';
10
11
  import { decode, encode } from '@msgpack/msgpack';
11
12
 
12
13
  // src/engine/durability-metadata.ts
@@ -16,7 +17,11 @@ function metadataFromConfig(indexName, config, partitionCount, documentCount) {
16
17
  schema: config.schema,
17
18
  language: config.language,
18
19
  partitionCount: partitionCount ?? config.partitionCount,
19
- bm25Params: { k1: config.k1, b: config.b },
20
+ bm25Params: {
21
+ k1: config.k1,
22
+ b: config.b,
23
+ ...config.bm25Fields !== void 0 ? { fields: config.bm25Fields } : {}
24
+ },
20
25
  createdAt: Date.now(),
21
26
  engineVersion: VERSION
22
27
  };
@@ -83,8 +88,9 @@ function metadataConfigOf(entry) {
83
88
  partitionCount: entry.partitionCount,
84
89
  schema: flattenSchema(entry.config.schema),
85
90
  language: entry.language.name,
86
- k1: entry.config.bm25?.k1 ?? 1.2,
87
- b: entry.config.bm25?.b ?? 0.75,
91
+ k1: entry.config.bm25?.k1 ?? DEFAULT_BM25_K1,
92
+ b: entry.config.bm25?.b ?? DEFAULT_BM25_B,
93
+ ...entry.config.bm25?.fields !== void 0 ? { bm25Fields: entry.config.bm25.fields } : {},
88
94
  ...embedding !== void 0 ? { embedding } : {},
89
95
  surfaceForms: entry.config.surfaceForms !== false,
90
96
  ...entry.analysisRevision !== null ? { analysisRevision: entry.analysisRevision } : {},
@@ -364,7 +370,7 @@ function wireToMetadata(raw) {
364
370
  schema: raw.schema ?? {},
365
371
  language: raw.language ?? "english",
366
372
  partitionCount: raw.partition_count ?? 1,
367
- bm25Params: raw.bm25_params ?? { k1: 1.2, b: 0.75 },
373
+ bm25Params: raw.bm25_params ?? { k1: DEFAULT_BM25_K1, b: DEFAULT_BM25_B },
368
374
  createdAt: raw.created_at ?? 0,
369
375
  engineVersion: raw.engine_version ?? "0.0.0"
370
376
  };
@@ -2,11 +2,11 @@ import { stopUsingTheNativeSearchCore, noteFallback, nativeSearchCoreIsEnabled }
2
2
  import { unpackLevels, readTrailer, stageQueryLevels, osqCodeBytes, osqStagedQueryBytes, osqRecordBytes, writeRecord } from './chunk-37CD3OKS.mjs';
3
3
  import { markSimdUnavailable } from './chunk-KOKM4PQN.mjs';
4
4
  import { MAX_WASM_PAGES, WASM_PAGE_BYTES, VECTOR_SCRATCH_SLOTS, UNPLACED_FLAG_CHUNK_ORDINALS, OSQ_STEPS, OSQ_GRID, VECTOR_BLOCK_INITIAL_SLOTS, MAX_VECTOR_ORDINALS, VECTOR_STORE_INITIAL_CAPACITY, LOCK_SPIN_ITERATIONS, LOCK_WAIT_SLICE_MS, OSQ_REFINE_ROUNDS, OSQ_REFINE_TOLERANCE, OSQ_PLACEMENT_QUERY_BITS, GRAPH_LOCK_WAIT_SLICE_MS, OSQ_QUERY_BITS, NATIVE_ATTACH_RETRY_MS, GRAPH_LOCK_WAIT_DEADLINE_MS, OSQ_LAMBDA, MAX_DOC_ID_TABLE_BYTES } from './chunk-QSK35UC2.mjs';
5
- import { loadNativeCore } from './chunk-VK45J47R.mjs';
5
+ import { loadNativeCore } from './chunk-3XHFVYIQ.mjs';
6
6
  import { COMPACTION_TOMBSTONE_RATIO, COMPACTION_ABSOLUTE_THRESHOLD, PLACEMENT_ROOM_REQUESTS, MAX_LAYER_CAP, INITIAL_LIST_CAPACITY, INITIAL_UPPER_SLOTS, DEFAULT_EF_SEARCH, NEAREST_LINK_FALLBACK_HOSTS, FARTHEST_REJECTED_LINKS_KEPT } from './chunk-VJS4JFBQ.mjs';
7
7
  import { compareCodePoints } from './chunk-YTJCGKM4.mjs';
8
8
  import { threadSlotGone } from './chunk-RFBLQLLZ.mjs';
9
- import { NarsilError, ErrorCodes } from './chunk-OBWUWZRA.mjs';
9
+ import { NarsilError, ErrorCodes } from './chunk-WI5Q3L43.mjs';
10
10
 
11
11
  // src/vector/shared-buffers/growable.ts
12
12
  function sharedMemoryAvailable() {
@@ -14,7 +14,7 @@ function requireLoadedVectorCode() {
14
14
  function loadVectorCode() {
15
15
  if (loaded !== null) return Promise.resolve(loaded);
16
16
  if (loading === null) {
17
- loading = import('./module-7OHZ2OPI.mjs').then(
17
+ loading = import('./module-S4WGMFNW.mjs').then(
18
18
  (code) => {
19
19
  loaded = code;
20
20
  return code;
@@ -1,4 +1,4 @@
1
- import { DEFAULT_PAGE_SIZE } from './chunk-E74YLAIG.mjs';
1
+ import { DEFAULT_PAGE_SIZE } from './chunk-DX2FI4LU.mjs';
2
2
 
3
3
  // src/engine/constants.ts
4
4
  var MIN_DOCUMENTS_FOR_SEGMENTS = 64;
@@ -1,6 +1,6 @@
1
1
  import { osqRecordBytes } from './chunk-37CD3OKS.mjs';
2
2
  import { MAX_M, EARLIER_RELEASE_MIN_M, MIN_M } from './chunk-VJS4JFBQ.mjs';
3
- import { NarsilError, ErrorCodes } from './chunk-OBWUWZRA.mjs';
3
+ import { NarsilError, ErrorCodes } from './chunk-WI5Q3L43.mjs';
4
4
 
5
5
  // src/vector/vector-index/dead-bits.ts
6
6
  var NO_LIVE_VECTOR_AT_POSITION = -1;
@@ -1,7 +1,7 @@
1
- import { P as PartitionConfig, A as AnyDocument, a as InsertOptions, W as WriteOptions } from './schema-4W_7tk1f.js';
2
- import { V as VectorMaintenanceResult, B as BatchResult, L as ListParams, g as ListResult, I as IndexInfo, k as IndexStats, l as PartitionStatsResult, Q as QueryParams, e as QueryResult, P as PreflightResult, h as SuggestParams, j as SuggestResult } from './events-x2aVu0_o.js';
1
+ import { P as PartitionConfig, B as BM25Params, A as AnyDocument, a as InsertOptions, W as WriteOptions } from './schema-DGAP_8HJ.js';
2
+ import { V as VectorMaintenanceResult, B as BatchResult, L as ListParams, g as ListResult, I as IndexInfo, k as IndexStats, l as PartitionStatsResult, Q as QueryParams, e as QueryResult, P as PreflightResult, h as SuggestParams, j as SuggestResult } from './events-pM0lna7M.js';
3
3
  import { a as SynonymRule } from './synonyms-CpOAHPa-.js';
4
- import { e as TaskRecord, M as MemoryStatsResponse, b as ImportResult, H as HttpIndexConfig, c as TaskListQuery, T as TaskListPage } from './tasks-DLQIfXqy.js';
4
+ import { e as TaskRecord, M as MemoryStatsResponse, b as ImportResult, H as HttpIndexConfig, c as TaskListQuery, T as TaskListPage } from './tasks-txGvNz6h.js';
5
5
 
6
6
  /**
7
7
  * This is the `fetch` implementation the client sends every request through.
@@ -35,9 +35,15 @@ interface NarsilClientOptions {
35
35
  *
36
36
  * The client moves a request to the next URL when the connection fails, when
37
37
  * the request times out, or when the server answers 502, 503, or 504. It
38
- * tries each URL at most once per request, and it fails with the error from
39
- * the last URL once every URL has failed. `timeoutMs` applies to each URL
40
- * that the client tries.
38
+ * tries each URL at most once as it moves down the list, and it fails with
39
+ * the error from its last try once every URL has failed. `timeoutMs` applies
40
+ * to each try.
41
+ *
42
+ * The client tries a read once more when every URL has failed its connection
43
+ * or answered 502, 503, or 504, so a list of N URLs can take N + 1 requests.
44
+ * With one URL, the second try goes to that same URL. The client sends the
45
+ * extra try straight away, to the first URL in the skip order below. A read
46
+ * that timed out on any URL takes no extra try.
41
47
  *
42
48
  * The client repeats a request on another URL only where repeating it cannot
43
49
  * apply a change twice. A read, meaning a get, a search, a listing, or a
@@ -82,9 +88,10 @@ interface NarsilClientOptions {
82
88
  /** The client sends these headers with every request, and a per-call header of the same name replaces one. */
83
89
  headers?: Record<string, string>;
84
90
  /**
85
- * The client waits this many milliseconds for an answer before it fails with
86
- * `CLIENT_REQUEST_TIMEOUT`, and it waits 30000 unless you say otherwise. Pass
87
- * 0 so that it waits for as long as the server takes. Three routes carry a
91
+ * The client waits this many milliseconds for an answer on each try before it
92
+ * fails with `CLIENT_REQUEST_TIMEOUT`, and it waits 30000 unless you say
93
+ * otherwise, so a read that tries again can take longer than this in total.
94
+ * Pass 0 so that it waits for as long as the server takes. Three routes carry a
88
95
  * corpus or a whole index, so {@link BulkOperations.importDocuments},
89
96
  * {@link AdminOperations.snapshot}, and {@link AdminOperations.restore} set no
90
97
  * deadline of their own until this one arrives.
@@ -112,7 +119,7 @@ interface NarsilClientOptions {
112
119
  interface RequestOptions {
113
120
  /** Aborting this stops the request, which then fails with `CLIENT_REQUEST_ABORTED`. */
114
121
  signal?: AbortSignal;
115
- /** The client waits this many milliseconds for this one answer, and 0 waits for as long as the server takes. */
122
+ /** The client waits this many milliseconds on each try of this one request, and 0 waits for as long as the server takes. */
116
123
  timeoutMs?: number;
117
124
  /** The client adds these headers to this request, and one of the same name replaces what it would otherwise send. */
118
125
  headers?: Record<string, string>;
@@ -294,6 +301,22 @@ interface AdminOperations {
294
301
  * set passes its limits. The index then keeps the set that it held before.
295
302
  */
296
303
  updateSynonyms(indexName: string, synonyms: SynonymRule[], options?: RequestOptions): Promise<void>;
304
+ /**
305
+ * Replaces the BM25 setting of an index, which takes effect from the next
306
+ * search without a rebuild. A value that the call leaves out returns to its
307
+ * default, and `{}` clears the setting.
308
+ *
309
+ * @param indexName - The server replaces the setting of this index.
310
+ * @param bm25 - This is the new setting, in the shape that
311
+ * {@link BM25Params} describes.
312
+ * @param options - This sets the signal, the deadline, and the headers for
313
+ * this request.
314
+ * @throws A `NarsilError` with `CONFIG_INVALID` when `k1` is not a number
315
+ * from 0 to 1,000, when `b` is not a number from 0 to 1, or when `fields`
316
+ * holds a name that is not a text field. The index then keeps the setting
317
+ * that it held before.
318
+ */
319
+ updateBM25(indexName: string, bm25: BM25Params, options?: RequestOptions): Promise<void>;
297
320
  /**
298
321
  * Reads the synonym set of an index, with every word as the caller wrote it.
299
322
  *
@@ -845,7 +868,7 @@ interface ServerOperations {
845
868
  /**
846
869
  * These settings say how {@link TaskOperations.waitForTask} follows a task.
847
870
  *
848
- * `timeoutMs` bounds each poll request, as it does everywhere else, while
871
+ * `timeoutMs` bounds each try of a poll request, as it does everywhere else, while
849
872
  * `waitTimeoutMs` bounds the whole wait.
850
873
  *
851
874
  * @public
package/dist/client.d.ts CHANGED
@@ -1,11 +1,11 @@
1
- export { C as ClientErrorCode, a as ClientErrorCodes, E as ErrorCode, b as ErrorCodes, N as NarsilError, c as NarsilErrorCode, S as ServerErrorCode, d as ServerErrorCodes, i as isNarsilError } from './events-x2aVu0_o.js';
2
- export { A as ASYNC_IMPORT_CAPABILITY, D as DOCUMENT_EXPORT_CAPABILITY, E as ErrorEnvelope, I as INDEX_LIFECYCLE_CAPABILITY, R as REBUILD_ANALYSIS_CAPABILITY, S as SERVER_CAPABILITIES, a as SYNONYMS_CAPABILITY, T as TASK_CANCEL_CAPABILITY, b as TASK_FILTER_CAPABILITY } from './capabilities-9YwwCcqP.js';
3
- export { C as CapabilitiesResponse, a as CreateIndexEmbedding, H as HttpIndexConfig, I as ImportError, b as ImportResult, M as MemoryStatsResponse, T as TaskListPage, c as TaskListQuery, d as TaskProgress, e as TaskRecord, f as TaskStatus, g as TaskType } from './tasks-DLQIfXqy.js';
4
- export { A as AdminOperations, B as BulkOperations, D as DocumentOperations, F as FetchFunction, I as ImportSource, a as IndexOperations, N as NarsilClient, b as NarsilClientOptions, P as PutResult, R as RequestOptions, S as SearchOperations, c as ServerOperations, d as ServerVersion, T as TaskOperations, W as WaitForTaskOptions, e as createNarsilClient } from './client-DyiYkQ8o.js';
5
- import './schema-4W_7tk1f.js';
1
+ export { C as ClientErrorCode, a as ClientErrorCodes, E as ErrorCode, b as ErrorCodes, N as NarsilError, c as NarsilErrorCode, S as ServerErrorCode, d as ServerErrorCodes, i as isNarsilError } from './events-pM0lna7M.js';
2
+ export { A as ASYNC_IMPORT_CAPABILITY, B as BM25_TUNING_CAPABILITY, D as DOCUMENT_EXPORT_CAPABILITY, E as ErrorEnvelope, I as INDEX_LIFECYCLE_CAPABILITY, R as REBUILD_ANALYSIS_CAPABILITY, S as SERVER_CAPABILITIES, a as SYNONYMS_CAPABILITY, T as TASK_CANCEL_CAPABILITY, b as TASK_FILTER_CAPABILITY } from './capabilities-BTjv-tK8.js';
3
+ export { C as CapabilitiesResponse, a as CreateIndexEmbedding, H as HttpIndexConfig, I as ImportError, b as ImportResult, M as MemoryStatsResponse, T as TaskListPage, c as TaskListQuery, d as TaskProgress, e as TaskRecord, f as TaskStatus, g as TaskType } from './tasks-txGvNz6h.js';
4
+ export { A as AdminOperations, B as BulkOperations, D as DocumentOperations, F as FetchFunction, I as ImportSource, a as IndexOperations, N as NarsilClient, b as NarsilClientOptions, P as PutResult, R as RequestOptions, S as SearchOperations, c as ServerOperations, d as ServerVersion, T as TaskOperations, W as WaitForTaskOptions, e as createNarsilClient } from './client-BOcveV7A.js';
5
+ import './schema-DGAP_8HJ.js';
6
6
  import './adapters-BQFQ4PRz.js';
7
7
  import './synonyms-CpOAHPa-.js';
8
- import './config-CtTfxbpV.js';
9
- import './config-DLVnlByZ.js';
10
- import './index-Cl5qQauj.js';
8
+ import './config-CPmIY3aH.js';
9
+ import './config-C3YXk5Rn.js';
10
+ import './index-DkQ2DlgR.js';
11
11
  import './types-DvncmvuQ.js';
package/dist/client.mjs CHANGED
@@ -32,6 +32,7 @@ var ErrorCodes = {
32
32
  SEARCH_INVALID_CURSOR: "SEARCH_INVALID_CURSOR",
33
33
  SEARCH_RESULT_WINDOW_EXCEEDED: "SEARCH_RESULT_WINDOW_EXCEEDED",
34
34
  SEARCH_WORK_CAP_EXCEEDED: "SEARCH_WORK_CAP_EXCEEDED",
35
+ BM25_NOT_READY: "BM25_NOT_READY",
35
36
  LANGUAGE_NOT_SUPPORTED: "LANGUAGE_NOT_SUPPORTED",
36
37
  ENVELOPE_VERSION_MISMATCH: "ENVELOPE_VERSION_MISMATCH",
37
38
  ENVELOPE_INVALID_MAGIC: "ENVELOPE_INVALID_MAGIC",
@@ -166,6 +167,7 @@ var REBUILD_ANALYSIS_CAPABILITY = "indexes.rebuildAnalysis";
166
167
  var INDEX_LIFECYCLE_CAPABILITY = "indexes.lifecycle";
167
168
  var DOCUMENT_EXPORT_CAPABILITY = "indexes.documentExport";
168
169
  var SYNONYMS_CAPABILITY = "indexes.synonyms";
170
+ var BM25_TUNING_CAPABILITY = "indexes.bm25";
169
171
  var SERVER_CAPABILITIES = [
170
172
  ASYNC_IMPORT_CAPABILITY,
171
173
  TASK_CANCEL_CAPABILITY,
@@ -173,7 +175,8 @@ var SERVER_CAPABILITIES = [
173
175
  REBUILD_ANALYSIS_CAPABILITY,
174
176
  INDEX_LIFECYCLE_CAPABILITY,
175
177
  DOCUMENT_EXPORT_CAPABILITY,
176
- SYNONYMS_CAPABILITY
178
+ SYNONYMS_CAPABILITY,
179
+ BM25_TUNING_CAPABILITY
177
180
  ];
178
181
 
179
182
  // src/json-encoding.ts
@@ -323,6 +326,9 @@ function createAdminOperations(transport) {
323
326
  async updateSynonyms(indexName, synonyms, options) {
324
327
  await postJson(`${indexPath(indexName)}/synonyms`, { synonyms }, options);
325
328
  },
329
+ async updateBM25(indexName, bm25, options) {
330
+ await postJson(`${indexPath(indexName)}/bm25`, bm25, options);
331
+ },
326
332
  async getSynonyms(indexName, options) {
327
333
  const path = `${indexPath(indexName)}/synonyms`;
328
334
  const body = await readBody(
@@ -563,6 +569,9 @@ function movesOnAfterAnswer(status, code, repeatable) {
563
569
  if (!answersUnavailable(status)) return false;
564
570
  return repeatable || code === ErrorCodes.NODE_NOT_READY;
565
571
  }
572
+ function earnsExtraTry(failure) {
573
+ return failure.code === ClientErrorCodes.CLIENT_CONNECTION_FAILED;
574
+ }
566
575
  function movesOnAfterFailure(failure, sentNothing, repeatable) {
567
576
  if (failure.code === ClientErrorCodes.CLIENT_REQUEST_TIMEOUT) return repeatable;
568
577
  if (failure.code === ClientErrorCodes.CLIENT_CONNECTION_FAILED) return repeatable || sentNothing;
@@ -744,30 +753,43 @@ function createTransport(options) {
744
753
  if (perCall !== void 0) return perCall;
745
754
  return options.maxResponseBytes ?? 0;
746
755
  }
756
+ function recordAttempt(entry, attempt, repeatable) {
757
+ if (attempt.kind === "answer") {
758
+ if (!answersUnavailable(attempt.status)) {
759
+ pool.answered(entry);
760
+ return false;
761
+ }
762
+ return movesOnAfterAnswer(attempt.status, envelopeCodeOf(attempt.text), repeatable);
763
+ }
764
+ if (attempt.error.code === ClientErrorCodes.CLIENT_CONNECTION_FAILED) pool.refused(entry, Date.now());
765
+ return movesOnAfterFailure(attempt.error, attempt.sentNothing, repeatable);
766
+ }
767
+ function outcomeOf(attempt) {
768
+ if (attempt === null) throw new NarsilError(ErrorCodes.CONFIG_INVALID, "The client holds no server address");
769
+ if (attempt.kind === "failure") throw attempt.error;
770
+ return attempt;
771
+ }
747
772
  async function exchange(spec, keepsStream = false) {
748
773
  const repeatable = spec.repeatable === true || spec.method === "GET";
749
774
  const replayable = !(spec.body instanceof ReadableStream);
775
+ const tryOn = async (entry2) => {
776
+ pool.took(entry2);
777
+ return exchangeOnce(entry2.base, spec, keepsStream);
778
+ };
779
+ let triesOnceMore = repeatable && replayable;
750
780
  let last = null;
751
- for (const entry of pool.order(Date.now())) {
752
- pool.took(entry);
753
- const attempt = await exchangeOnce(entry.base, spec, keepsStream);
754
- if (attempt.kind === "answer") {
755
- const unavailable = answersUnavailable(attempt.status);
756
- const code = unavailable ? envelopeCodeOf(attempt.text) : void 0;
757
- if (!replayable || !movesOnAfterAnswer(attempt.status, code, repeatable)) {
758
- if (!unavailable) pool.answered(entry);
759
- return attempt;
760
- }
761
- } else {
762
- if (attempt.error.code === ClientErrorCodes.CLIENT_CONNECTION_FAILED) pool.refused(entry, Date.now());
763
- if (!replayable || !movesOnAfterFailure(attempt.error, attempt.sentNothing, repeatable)) throw attempt.error;
764
- }
765
- last = attempt;
781
+ for (const entry2 of pool.order(Date.now())) {
782
+ last = await tryOn(entry2);
783
+ const moves = recordAttempt(entry2, last, repeatable);
784
+ if (!replayable || !moves) return outcomeOf(last);
785
+ if (last.kind === "failure" && !earnsExtraTry(last.error)) triesOnceMore = false;
766
786
  }
767
- if (last === null || last.kind === "failure") {
768
- throw last?.error ?? new NarsilError(ErrorCodes.CONFIG_INVALID, "The client holds no server address");
787
+ const [entry] = pool.order(Date.now());
788
+ if (triesOnceMore && entry !== void 0) {
789
+ last = await tryOn(entry);
790
+ recordAttempt(entry, last, repeatable);
769
791
  }
770
- return last;
792
+ return outcomeOf(last);
771
793
  }
772
794
  async function exchangeOnce(base, spec, keepsStream) {
773
795
  const url = `${base}${withQuery(spec.path, spec.query)}`;
@@ -1040,4 +1062,4 @@ function createNarsilClient(options) {
1040
1062
  };
1041
1063
  }
1042
1064
 
1043
- export { ASYNC_IMPORT_CAPABILITY, ClientErrorCodes, DOCUMENT_EXPORT_CAPABILITY, ErrorCodes, INDEX_LIFECYCLE_CAPABILITY, NarsilError, REBUILD_ANALYSIS_CAPABILITY, SERVER_CAPABILITIES, SYNONYMS_CAPABILITY, ServerErrorCodes, TASK_CANCEL_CAPABILITY, TASK_FILTER_CAPABILITY, createNarsilClient, isNarsilError };
1065
+ export { ASYNC_IMPORT_CAPABILITY, BM25_TUNING_CAPABILITY, ClientErrorCodes, DOCUMENT_EXPORT_CAPABILITY, ErrorCodes, INDEX_LIFECYCLE_CAPABILITY, NarsilError, REBUILD_ANALYSIS_CAPABILITY, SERVER_CAPABILITIES, SYNONYMS_CAPABILITY, ServerErrorCodes, TASK_CANCEL_CAPABILITY, TASK_FILTER_CAPABILITY, createNarsilClient, isNarsilError };
@@ -1,6 +1,6 @@
1
1
  import { P as PersistenceAdapter, I as InvalidationAdapter, E as EmbeddingAdapter, R as RerankAdapter } from './adapters-BQFQ4PRz.js';
2
- import { Q as QueryParams, e as QueryResult, f as NarsilEventHandlers } from './events-x2aVu0_o.js';
3
- import { I as IndexConfig, A as AnyDocument } from './schema-4W_7tk1f.js';
2
+ import { Q as QueryParams, e as QueryResult, f as NarsilEventHandlers } from './events-pM0lna7M.js';
3
+ import { I as IndexConfig, A as AnyDocument } from './schema-DGAP_8HJ.js';
4
4
 
5
5
  /**
6
6
  * Hooks that the engine calls alongside its own work, so that an application
@@ -1,5 +1,5 @@
1
- import { N as NarsilConfig } from './config-DLVnlByZ.js';
2
- import { A as AllocationTable, N as NodeRole, a as NodeRegistration, C as ClusterCoordinator, b as NodeCapacity } from './index-Cl5qQauj.js';
1
+ import { N as NarsilConfig } from './config-C3YXk5Rn.js';
2
+ import { A as AllocationTable, N as NodeRole, a as NodeRegistration, C as ClusterCoordinator, b as NodeCapacity } from './index-DkQ2DlgR.js';
3
3
  import { N as NodeTransport } from './types-DvncmvuQ.js';
4
4
 
5
5
  /**
@@ -1,26 +1,26 @@
1
- export { createDirectExecutor } from './chunk-JEXJDCQH.mjs';
2
- import './chunk-IBGMFR5Y.mjs';
3
- import './chunk-FUUP45IS.mjs';
1
+ export { createDirectExecutor } from './chunk-RYH3PASD.mjs';
2
+ import './chunk-K76F5YYX.mjs';
3
+ import './chunk-M6MBSVIJ.mjs';
4
4
  import './chunk-ZATRDAYU.mjs';
5
5
  import './chunk-EBIHRL7B.mjs';
6
6
  import './chunk-TGP5M5R7.mjs';
7
7
  import './chunk-U2BKYEC7.mjs';
8
- import './chunk-P34VZEXB.mjs';
8
+ import './chunk-AN3CUMPZ.mjs';
9
9
  import './chunk-WQBCBKY3.mjs';
10
- import './chunk-KCQG2PJT.mjs';
11
- import './chunk-DG62H7OD.mjs';
10
+ import './chunk-F4UKMTKM.mjs';
11
+ import './chunk-AFOZR4ZQ.mjs';
12
12
  import './chunk-U476IXKQ.mjs';
13
- import './chunk-E74YLAIG.mjs';
13
+ import './chunk-DX2FI4LU.mjs';
14
14
  import './chunk-VJS4JFBQ.mjs';
15
15
  import './chunk-GES7U2PM.mjs';
16
- import './chunk-6ODIY6ZB.mjs';
17
- import './chunk-IR4KQ4WB.mjs';
16
+ import './chunk-4XEVROSP.mjs';
17
+ import './chunk-MGD7XETB.mjs';
18
18
  import './chunk-X5CV2E2B.mjs';
19
19
  import './chunk-7X5JST5L.mjs';
20
- import './chunk-OFYKBKKV.mjs';
20
+ import './chunk-RC27KF7F.mjs';
21
21
  import './chunk-R6A773WK.mjs';
22
22
  import './chunk-YTJCGKM4.mjs';
23
- import './chunk-U6NGTWI3.mjs';
23
+ import './chunk-XTER67YM.mjs';
24
24
  import './chunk-22YPZVMG.mjs';
25
25
  import './chunk-L5ORED7V.mjs';
26
- import './chunk-OBWUWZRA.mjs';
26
+ import './chunk-WI5Q3L43.mjs';
@@ -1,5 +1,5 @@
1
- import { C as ClusterCoordinator } from '../../index-Cl5qQauj.js';
2
- import '../../schema-4W_7tk1f.js';
1
+ import { C as ClusterCoordinator } from '../../index-DkQ2DlgR.js';
2
+ import '../../schema-DGAP_8HJ.js';
3
3
  import '../../adapters-BQFQ4PRz.js';
4
4
  import '../../synonyms-CpOAHPa-.js';
5
5
 
@@ -1,7 +1,8 @@
1
+ import { INDEX_METADATA_KEY_PREFIX, indexNameOfMetadataSuffix } from '../../chunk-Q2AP2FSN.mjs';
1
2
  import { MAX_NODE_ID_LENGTH, CONTROLLER_LEASE_KEY, MAX_WATCHERS } from '../../chunk-44W3CBNG.mjs';
2
3
  import '../../chunk-R6A773WK.mjs';
3
4
  import { compareCodePoints } from '../../chunk-YTJCGKM4.mjs';
4
- import { NarsilError, ErrorCodes, describeError } from '../../chunk-OBWUWZRA.mjs';
5
+ import { NarsilError, ErrorCodes, describeError } from '../../chunk-WI5Q3L43.mjs';
5
6
  import { encode, decode } from '@msgpack/msgpack';
6
7
 
7
8
  // src/distribution/coordinator/etcd/constants.ts
@@ -760,6 +761,22 @@ function storedValueMethods(context) {
760
761
  handler({ type: "schema_dropped", indexName: extractSuffix(fullKey, prefix), schema: null });
761
762
  }
762
763
  });
764
+ },
765
+ async watchIndexMetadata(handler) {
766
+ assertNotShutdown();
767
+ const prefix = keys.generic(INDEX_METADATA_KEY_PREFIX);
768
+ const nameOf = (fullKey) => indexNameOfMetadataSuffix(fullKey.slice(prefix.length));
769
+ return watchPrefix2(prefix, {
770
+ put(kv) {
771
+ const indexName = nameOf(kv.key.toString());
772
+ if (indexName === null) return;
773
+ handler({ indexName, metadata: kv.value.byteLength === 0 ? null : new Uint8Array(kv.value) });
774
+ },
775
+ delete(fullKey) {
776
+ const indexName = nameOf(fullKey);
777
+ if (indexName !== null) handler({ indexName, metadata: null });
778
+ }
779
+ });
763
780
  }
764
781
  };
765
782
  }
@@ -1,5 +1,5 @@
1
- import { C as ClusterCoordinator } from '../../index-Cl5qQauj.js';
2
- import '../../schema-4W_7tk1f.js';
1
+ import { C as ClusterCoordinator } from '../../index-DkQ2DlgR.js';
2
+ import '../../schema-DGAP_8HJ.js';
3
3
  import '../../adapters-BQFQ4PRz.js';
4
4
  import '../../synonyms-CpOAHPa-.js';
5
5
 
@@ -1,7 +1,32 @@
1
+ import { indexNameOfMetadataKey } from '../../chunk-Q2AP2FSN.mjs';
1
2
  import { CONTROLLER_LEASE_KEY, NODE_HEARTBEAT_TTL_MS } from '../../chunk-44W3CBNG.mjs';
2
3
  import '../../chunk-R6A773WK.mjs';
3
4
  import { compareCodePoints } from '../../chunk-YTJCGKM4.mjs';
4
5
 
6
+ // src/distribution/coordinator/index-metadata-watchers.ts
7
+ function createIndexMetadataWatchers() {
8
+ const handlers = /* @__PURE__ */ new Set();
9
+ return {
10
+ watch(handler) {
11
+ handlers.add(handler);
12
+ return () => {
13
+ handlers.delete(handler);
14
+ };
15
+ },
16
+ emit(key, value) {
17
+ const indexName = indexNameOfMetadataKey(key);
18
+ if (indexName === null) return;
19
+ const metadata = value === null || value.byteLength === 0 ? null : new Uint8Array(value);
20
+ for (const handler of handlers) {
21
+ try {
22
+ handler({ indexName, metadata });
23
+ } catch (_) {
24
+ }
25
+ }
26
+ }
27
+ };
28
+ }
29
+
5
30
  // src/distribution/coordinator/in-memory.ts
6
31
  var NODE_HEARTBEAT_PREFIX = "_narsil/node/";
7
32
  function bytesEqual(a, b) {
@@ -26,6 +51,7 @@ function createInMemoryCoordinator() {
26
51
  const nodeWatchers = /* @__PURE__ */ new Set();
27
52
  const allocationWatchers = /* @__PURE__ */ new Set();
28
53
  const schemaWatchers = /* @__PURE__ */ new Set();
54
+ const indexMetadataWatchers = createIndexMetadataWatchers();
29
55
  let isShutdown = false;
30
56
  function assertNotShutdown() {
31
57
  if (isShutdown) {
@@ -232,6 +258,7 @@ function createInMemoryCoordinator() {
232
258
  return false;
233
259
  }
234
260
  kvStore.set(key, new Uint8Array(value));
261
+ indexMetadataWatchers.emit(key, value);
235
262
  return true;
236
263
  }
237
264
  if (current === void 0) {
@@ -241,11 +268,12 @@ function createInMemoryCoordinator() {
241
268
  return false;
242
269
  }
243
270
  kvStore.set(key, new Uint8Array(value));
271
+ indexMetadataWatchers.emit(key, value);
244
272
  return true;
245
273
  },
246
274
  async delete(key) {
247
275
  assertNotShutdown();
248
- kvStore.delete(key);
276
+ if (kvStore.delete(key)) indexMetadataWatchers.emit(key, null);
249
277
  },
250
278
  async getSchema(indexName) {
251
279
  assertNotShutdown();
@@ -274,6 +302,10 @@ function createInMemoryCoordinator() {
274
302
  schemaWatchers.delete(handler);
275
303
  };
276
304
  },
305
+ async watchIndexMetadata(handler) {
306
+ assertNotShutdown();
307
+ return indexMetadataWatchers.watch(handler);
308
+ },
277
309
  async getLeaseHolder(key) {
278
310
  assertNotShutdown();
279
311
  if (!isLeaseValid(key)) {
@@ -2,7 +2,7 @@ import { decodeTransportMessage, encodeTransportMessage } from '../../chunk-J6YV
2
2
  import { timeoutsOf, replyDeadlineMs } from '../../chunk-PWIWSUCX.mjs';
3
3
  import { MAX_MESSAGE_SIZE_BYTES, GRPC_KEEPALIVE_TIMEOUT_MS, GRPC_KEEPALIVE_TIME_MS, GRPC_ENVELOPE_OVERHEAD_BYTES } from '../../chunk-UNEEFTEU.mjs';
4
4
  import { TransportError, TransportErrorCodes } from '../../chunk-YH5OIL7B.mjs';
5
- import { NarsilError, ErrorCodes } from '../../chunk-OBWUWZRA.mjs';
5
+ import { NarsilError, ErrorCodes } from '../../chunk-WI5Q3L43.mjs';
6
6
 
7
7
  // src/distribution/transport/grpc/codec.ts
8
8
  var FIELD_ONE_LENGTH_DELIMITED_KEY = 10;