@delali/narsil 0.3.1-next.128 → 0.3.1-next.130
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/dist/adapters/filesystem.mjs +1 -1
- package/dist/adapters/indexeddb.mjs +1 -1
- package/dist/browser/chunk-26A5JFT2.mjs +89 -0
- package/dist/browser/{chunk-4Y2EGA3U.mjs → chunk-2Y3CO4EQ.mjs} +878 -310
- package/dist/browser/{chunk-2CBQ2PCC.mjs → chunk-AIIJDWMG.mjs} +1 -1
- package/dist/browser/{chunk-P7C2S5JX.mjs → chunk-D7WQF6DV.mjs} +2 -2
- package/dist/browser/{chunk-V5DCQIOT.mjs → chunk-M5UAAXGU.mjs} +2 -2
- package/dist/browser/{chunk-B65QVTST.mjs → chunk-NSCSR6MA.mjs} +24 -9
- package/dist/browser/{chunk-LJS6PREA.mjs → chunk-UDGB2MWT.mjs} +7 -28
- package/dist/browser/{chunk-6POI2KNI.mjs → chunk-VBBLTD7O.mjs} +4 -3
- package/dist/browser/chunk-VEGHFP2P.mjs +30 -0
- package/dist/browser/{durability-wiring-PUC4QSCR.mjs → durability-wiring-FNZSRH4N.mjs} +8 -6
- package/dist/browser/{module-ACWDC7YI.mjs → module-4HIMOQM5.mjs} +6 -5
- package/dist/browser/phrase-module-WESYVU7K.mjs +327 -0
- package/dist/browser/{restore-queue-MLUEUEAN.mjs → restore-queue-GEZ54CA5.mjs} +1 -1
- package/dist/browser/{runtime-BX6XRFYR.mjs → runtime-3X7ZJ5T3.mjs} +2 -1
- package/dist/browser/{snapshot-U5Y346XG.mjs → snapshot-V7VF6BN6.mjs} +25 -10
- package/dist/browser/{write-GZHR6AVG.mjs → write-YIC2MKRY.mjs} +7 -5
- package/dist/{capabilities-9YwwCcqP.d.ts → capabilities-Bl8G9taj.d.ts} +10 -3
- package/dist/{chunk-VK45J47R.mjs → chunk-2C3WXBQS.mjs} +1 -1
- package/dist/{chunk-QSCVJJW5.mjs → chunk-2JWNJSNE.mjs} +8 -8
- package/dist/{chunk-IBGMFR5Y.mjs → chunk-2MKX2SCO.mjs} +481 -121
- package/dist/{chunk-P34VZEXB.mjs → chunk-2SEL6SBS.mjs} +4 -95
- package/dist/{chunk-7ZZQNOIY.mjs → chunk-2WBY4Y4M.mjs} +1 -1
- package/dist/{chunk-HFJXEFFV.mjs → chunk-4GDLFDPZ.mjs} +3 -3
- package/dist/chunk-4UMZ7KQL.mjs +17 -0
- package/dist/{chunk-ZR63OGT2.mjs → chunk-5LX6MOIB.mjs} +2 -2
- package/dist/{chunk-UKXMSO5H.mjs → chunk-6M6SDH3S.mjs} +189 -45
- package/dist/{chunk-IR4KQ4WB.mjs → chunk-6SSVIW7Y.mjs} +49 -31
- package/dist/{chunk-4IHMMDRF.mjs → chunk-7OIQ2SIO.mjs} +4 -4
- package/dist/{chunk-6ODIY6ZB.mjs → chunk-7XY6VD7B.mjs} +1 -1
- package/dist/{chunk-OBWUWZRA.mjs → chunk-CZ7ISLXA.mjs} +3 -0
- package/dist/{chunk-OFYKBKKV.mjs → chunk-D5TFRB5G.mjs} +3 -15
- package/dist/{chunk-KCQG2PJT.mjs → chunk-EUCX5K74.mjs} +4 -4
- package/dist/{chunk-HWQDZB2U.mjs → chunk-F6AAXI7T.mjs} +3 -3
- package/dist/{chunk-E74YLAIG.mjs → chunk-FQBFZAWG.mjs} +4 -1
- package/dist/{chunk-U6NGTWI3.mjs → chunk-HCGJKDZV.mjs} +1 -1
- package/dist/{chunk-SJEIIR56.mjs → chunk-JJ6EUMXB.mjs} +2 -2
- package/dist/{chunk-N57XXGPG.mjs → chunk-JT3YZGCE.mjs} +23 -4
- package/dist/chunk-JUKYYXSP.mjs +93 -0
- package/dist/{chunk-JIXO442E.mjs → chunk-K77FJXKS.mjs} +26 -10
- package/dist/{chunk-4PQNDHSA.mjs → chunk-NMXRXFGZ.mjs} +2 -2
- package/dist/{chunk-6PN3U6XW.mjs → chunk-NNO7CO3A.mjs} +1 -1
- package/dist/{chunk-542TD4BL.mjs → chunk-PATMDIMN.mjs} +1 -1
- package/dist/{chunk-DG62H7OD.mjs → chunk-PU6SKH7O.mjs} +2 -2
- package/dist/chunk-Q2AP2FSN.mjs +15 -0
- package/dist/{chunk-22CK2LQO.mjs → chunk-QQTXT65X.mjs} +6 -5
- package/dist/{chunk-LXWDQLTW.mjs → chunk-RNSC4NFI.mjs} +1 -1
- package/dist/{chunk-JEXJDCQH.mjs → chunk-RWESFSJI.mjs} +28 -13
- package/dist/{chunk-SEG4CL6W.mjs → chunk-SOHMMNCH.mjs} +4 -4
- package/dist/{chunk-OGFSUXYY.mjs → chunk-SZGRYEIC.mjs} +4 -4
- package/dist/{chunk-LOBYK2FG.mjs → chunk-T4OFG4IQ.mjs} +20 -9
- package/dist/{chunk-ENBN5VQ6.mjs → chunk-TGHNXN7W.mjs} +150 -52
- package/dist/{chunk-Z4DZ4KK2.mjs → chunk-UJWGQIXU.mjs} +1 -0
- package/dist/{chunk-ANFNYCQG.mjs → chunk-WVRDRLIC.mjs} +6 -6
- package/dist/{chunk-62IPM62F.mjs → chunk-X5CNUKD5.mjs} +2 -2
- package/dist/{chunk-IE43SRL3.mjs → chunk-XABMCBHA.mjs} +12 -6
- package/dist/{chunk-OCB7TMUQ.mjs → chunk-Y2U5VVWX.mjs} +1 -1
- package/dist/{chunk-MFPJVITN.mjs → chunk-Y4BVTQ53.mjs} +2 -2
- package/dist/{chunk-N6J6EJW3.mjs → chunk-YBWSV5DV.mjs} +2 -2
- package/dist/{chunk-FUUP45IS.mjs → chunk-ZR4VM4A6.mjs} +1 -1
- package/dist/{client-CsuhZ13c.d.ts → client-Cx-TiqPE.d.ts} +19 -3
- package/dist/client.d.ts +8 -8
- package/dist/client.mjs +10 -2
- package/dist/{config-CtTfxbpV.d.ts → config-CzB9YvF_.d.ts} +2 -2
- package/dist/{config-DLVnlByZ.d.ts → config-hOWGBeC6.d.ts} +7 -5
- package/dist/direct-executor-HQ4QVDX7.mjs +28 -0
- package/dist/distribution/coordinator/etcd.d.ts +2 -2
- package/dist/distribution/coordinator/etcd.mjs +18 -1
- package/dist/distribution/coordinator/in-memory.d.ts +2 -2
- package/dist/distribution/coordinator/in-memory.mjs +33 -1
- package/dist/distribution/transport/grpc.mjs +1 -1
- package/dist/distribution.d.ts +71 -43
- package/dist/distribution.mjs +411 -127
- package/dist/{durability-wiring-UGGUNATA.mjs → durability-wiring-S7OX2MAI.mjs} +28 -26
- package/dist/embeddings/openai.mjs +2 -2
- package/dist/{engine-Bq5wz6c1.d.ts → engine-B_W9sdZK.d.ts} +38 -8
- package/dist/{events-x2aVu0_o.d.ts → events-DErop1LM.d.ts} +23 -2
- package/dist/{index-Cl5qQauj.d.ts → index-CKI1fDEl.d.ts} +37 -3
- package/dist/index.browser.mjs +5 -3
- package/dist/index.d.ts +7 -7
- package/dist/index.mjs +21 -19
- package/dist/{long-query-thread-5BIPZVS6.mjs → long-query-thread-WVSMIBYP.mjs} +17 -15
- package/dist/{module-7OHZ2OPI.mjs → module-2E4XYSGT.mjs} +11 -11
- package/dist/partial-words.mjs +7 -6
- package/dist/pattern.mjs +4 -3
- package/dist/persistence/durability/checkpoint-worker.d.ts +3 -1
- package/dist/persistence/durability/checkpoint-worker.mjs +24 -22
- package/dist/phrase-module-JERF2IDG.mjs +329 -0
- package/dist/react.d.ts +7 -7
- package/dist/react.mjs +3 -0
- package/dist/{rerank-NYX5S7OG.mjs → rerank-DMMT4FZA.mjs} +6 -6
- package/dist/rerankers/http.mjs +2 -2
- package/dist/{restore-queue-NVMWJMHI.mjs → restore-queue-JAMNRC6T.mjs} +1 -1
- package/dist/{runtime-XNYW6AWX.mjs → runtime-7MLQ7J64.mjs} +7 -7
- package/dist/{schema-4W_7tk1f.d.ts → schema-CS-clLun.d.ts} +54 -28
- package/dist/server.d.ts +10 -10
- package/dist/server.mjs +27 -15
- package/dist/{snapshot-P7IQGNNQ.mjs → snapshot-DOQLGGEX.mjs} +45 -30
- package/dist/synonyms.mjs +4 -3
- package/dist/{tasks-DLQIfXqy.d.ts → tasks-BfF-VRhm.d.ts} +4 -6
- package/dist/{thread-QPETQEPK.mjs → thread-DNK5XWXG.mjs} +16 -14
- package/dist/vector/search-worker.d.ts +1 -1
- package/dist/vector/search-worker.mjs +4 -4
- package/dist/workers/entry.mjs +8 -8
- package/dist/{write-WZVM7ZL6.mjs → write-ZKR7SNRT.mjs} +23 -21
- package/package.json +7 -7
- package/dist/direct-executor-6KCVVHYT.mjs +0 -26
|
@@ -1,70 +1,9 @@
|
|
|
1
1
|
import { MAX_FILTER_ARRAY_SIZE } from './chunk-WQBCBKY3.mjs';
|
|
2
|
+
import { bitsetHas, bitsetSet, GrowableUint32, createBitSet, bitsetAnd, bitsetNot } from './chunk-JUKYYXSP.mjs';
|
|
2
3
|
import { tabulatedLevenshtein } from './chunk-GES7U2PM.mjs';
|
|
3
|
-
import { parsedTypeOf } from './chunk-
|
|
4
|
+
import { parsedTypeOf } from './chunk-7XY6VD7B.mjs';
|
|
4
5
|
import { codePointCount, exceedsCodePoints } from './chunk-YTJCGKM4.mjs';
|
|
5
|
-
import { NarsilError, ErrorCodes } from './chunk-
|
|
6
|
-
|
|
7
|
-
// src/core/bitset.ts
|
|
8
|
-
function createBitSet(capacity) {
|
|
9
|
-
return new Uint32Array(capacity + 31 >>> 5 || 1);
|
|
10
|
-
}
|
|
11
|
-
function bitsetSet(bs, index) {
|
|
12
|
-
const word = index >>> 5;
|
|
13
|
-
if (word < bs.length) {
|
|
14
|
-
bs[word] |= 1 << (index & 31);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function bitsetHas(bs, index) {
|
|
18
|
-
const word = index >>> 5;
|
|
19
|
-
if (word >= bs.length) return false;
|
|
20
|
-
return (bs[word] & 1 << (index & 31)) !== 0;
|
|
21
|
-
}
|
|
22
|
-
function bitsetAnd(a, b) {
|
|
23
|
-
const len = Math.min(a.length, b.length);
|
|
24
|
-
const result = new Uint32Array(len);
|
|
25
|
-
for (let i = 0; i < len; i++) {
|
|
26
|
-
result[i] = a[i] & b[i];
|
|
27
|
-
}
|
|
28
|
-
return result;
|
|
29
|
-
}
|
|
30
|
-
function bitsetAndInto(target, other) {
|
|
31
|
-
const shared = Math.min(target.length, other.length);
|
|
32
|
-
for (let i = 0; i < shared; i++) target[i] &= other[i];
|
|
33
|
-
target.fill(0, shared);
|
|
34
|
-
}
|
|
35
|
-
function bitsetOrInto(target, other) {
|
|
36
|
-
const shared = Math.min(target.length, other.length);
|
|
37
|
-
for (let i = 0; i < shared; i++) target[i] |= other[i];
|
|
38
|
-
}
|
|
39
|
-
function bitsetAndNotInto(target, removed) {
|
|
40
|
-
const shared = Math.min(target.length, removed.length);
|
|
41
|
-
for (let i = 0; i < shared; i++) target[i] &= ~removed[i];
|
|
42
|
-
}
|
|
43
|
-
function bitsetNot(bs, capacity) {
|
|
44
|
-
const result = new Uint32Array(bs.length);
|
|
45
|
-
const fullWords = capacity >>> 5;
|
|
46
|
-
for (let i = 0; i < fullWords; i++) {
|
|
47
|
-
result[i] = ~bs[i];
|
|
48
|
-
}
|
|
49
|
-
const remainder = capacity & 31;
|
|
50
|
-
if (remainder > 0 && fullWords < bs.length) {
|
|
51
|
-
result[fullWords] = ~bs[fullWords] & (1 << remainder) - 1;
|
|
52
|
-
}
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
function bitsetIsEmpty(bs) {
|
|
56
|
-
for (let i = 0; i < bs.length; i++) {
|
|
57
|
-
if (bs[i] !== 0) return false;
|
|
58
|
-
}
|
|
59
|
-
return true;
|
|
60
|
-
}
|
|
61
|
-
function bitsetFromSet(set, capacity) {
|
|
62
|
-
const bs = createBitSet(capacity);
|
|
63
|
-
for (const id of set) {
|
|
64
|
-
bs[id >>> 5] |= 1 << (id & 31);
|
|
65
|
-
}
|
|
66
|
-
return bs;
|
|
67
|
-
}
|
|
6
|
+
import { NarsilError, ErrorCodes } from './chunk-CZ7ISLXA.mjs';
|
|
68
7
|
|
|
69
8
|
// src/core/pattern-index/constants.ts
|
|
70
9
|
var DEFAULT_PATTERN_WORK_CAP = 25e6;
|
|
@@ -2035,36 +1974,6 @@ function largestPatternFootprintIn(expression, patternFields, host) {
|
|
|
2035
1974
|
return largest;
|
|
2036
1975
|
}
|
|
2037
1976
|
|
|
2038
|
-
// src/core/partition/growable-uint32.ts
|
|
2039
|
-
var GrowableUint32 = class {
|
|
2040
|
-
values;
|
|
2041
|
-
length = 0;
|
|
2042
|
-
constructor(capacity) {
|
|
2043
|
-
this.values = new Uint32Array(capacity);
|
|
2044
|
-
}
|
|
2045
|
-
growTo(needed, kept) {
|
|
2046
|
-
let capacity = this.values.length * 2;
|
|
2047
|
-
while (capacity < needed) capacity *= 2;
|
|
2048
|
-
const next = new Uint32Array(capacity);
|
|
2049
|
-
next.set(this.values.subarray(0, kept));
|
|
2050
|
-
this.values = next;
|
|
2051
|
-
}
|
|
2052
|
-
reserve(extra) {
|
|
2053
|
-
const needed = this.length + extra;
|
|
2054
|
-
if (needed > this.values.length) this.growTo(needed, this.length);
|
|
2055
|
-
}
|
|
2056
|
-
push(value) {
|
|
2057
|
-
if (this.length === this.values.length) this.growTo(this.length + 1, this.length);
|
|
2058
|
-
this.values[this.length++] = value;
|
|
2059
|
-
}
|
|
2060
|
-
ensureIndex(index) {
|
|
2061
|
-
if (index >= this.values.length) this.growTo(index + 1, this.values.length);
|
|
2062
|
-
}
|
|
2063
|
-
clear() {
|
|
2064
|
-
this.length = 0;
|
|
2065
|
-
}
|
|
2066
|
-
};
|
|
2067
|
-
|
|
2068
1977
|
// src/pattern/runs-arrays.ts
|
|
2069
1978
|
var EMPTY_POSTINGS = new Uint32Array(0);
|
|
2070
1979
|
function remapAscending(source, remap, out) {
|
|
@@ -2596,4 +2505,4 @@ var patternSearchModule = {
|
|
|
2596
2505
|
decodeIndex: decodePatternIndex
|
|
2597
2506
|
};
|
|
2598
2507
|
|
|
2599
|
-
export { DEFAULT_PATTERN_WORK_CAP,
|
|
2508
|
+
export { DEFAULT_PATTERN_WORK_CAP, MATCHER_STATE_BUDGET_BYTES, PATTERN_ELEMENT_OPERATORS, PATTERN_EXPRESSION_OPERATORS, PATTERN_TEST_OPERATORS, PATTERN_WORK_FLUSH_UNITS, TYPO_CLAIM_SLOTS_PER_WORD, invalid, isFiniteNumber, isObjectRecord, isPatternTolerance, kindOfValue, patternSearchModule, requireFieldKind, requireListLength, requireTextRangeField };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { admittedHeapBytes, collectGarbageBeforeAnswerRefusal, collectYoungGenerationBeforeRefusal, reservedHeapBytes, admitHeapBytes } from './chunk-IWVEG5CX.mjs';
|
|
2
2
|
import { readOldGenerationStatistics, processLimitBytes } from './chunk-ZATRDAYU.mjs';
|
|
3
3
|
import { engineThreadYoungGenerationBytes } from './chunk-EBIHRL7B.mjs';
|
|
4
|
-
import { NarsilError, ErrorCodes, ServerErrorCodes } from './chunk-
|
|
4
|
+
import { NarsilError, ErrorCodes, ServerErrorCodes } from './chunk-CZ7ISLXA.mjs';
|
|
5
5
|
|
|
6
6
|
// src/distribution/cluster-node/constants.ts
|
|
7
7
|
var DEFAULT_PARTITION_COUNT = 5;
|
|
@@ -36,7 +36,7 @@ var CATCH_UP_TICK_MS = 1e3;
|
|
|
36
36
|
var CATCH_UP_FEED_WINDOW_MS = 1e3;
|
|
37
37
|
var MAX_CATCH_UP_IN_FLIGHT_BYTES = 67108864;
|
|
38
38
|
var CLEAR_PAGE_SIZE = 1e3;
|
|
39
|
-
var
|
|
39
|
+
var MAX_SETTINGS_REPLACEMENT_ATTEMPTS = 5;
|
|
40
40
|
var DEFAULT_MAX_PER_SOURCE_SNAPSHOTS = 1;
|
|
41
41
|
var DEFAULT_MAX_STREAMS_PER_INDEX = 4;
|
|
42
42
|
var SNAPSHOT_CHUNK_YIELD_INTERVAL_MS = 8;
|
|
@@ -298,4 +298,4 @@ function refuseEncodeWithoutRoom(documents) {
|
|
|
298
298
|
if (refusal2 !== null) throw refusal2;
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
export { ADMISSION_TIMEOUT_MS, ANSWER_DECODE_HEAP_BYTES_PER_PAYLOAD_BYTE, CASE_FOLD_EXPANSION_FACTOR, CATCH_UP_FEED_WINDOW_MS, CATCH_UP_TICK_MS, CLEAR_PAGE_SIZE, COORDINATOR_REQUEST_BUCKET_BOUNDS_SECONDS, COPY_FAILURE_ATTEMPTS, COPY_FAILURE_RETRY_DELAY_MS, DECOMMISSION_RECHECK_INTERVAL_MS, DEFAULT_BLOCK_WRITES_ABOVE, DEFAULT_BOOTSTRAP_SYNC_DEADLINE_MS, DEFAULT_CAPACITY, DEFAULT_CREATE_INDEX_WAIT_MS, DEFAULT_IN_FLIGHT_WRITE_FRACTION, DEFAULT_MAX_PER_SOURCE_SNAPSHOTS, DEFAULT_MAX_STREAMS_PER_INDEX, DEFAULT_PARTITION_COUNT, DEFAULT_REPLICATION_FACTOR, DEFAULT_RESUME_WRITES_BELOW, DISTINCT_TERM_HEAP_BYTES, DOCUMENT_HEAP_BYTES_PER_ESTIMATED_BYTE, DOCUMENT_PROPERTY_HEAP_BYTES, DOCUMENT_VALUE_HEAP_BYTES, DROP_ACKNOWLEDGE_POLL_INTERVAL_MS, ENUM_VALUE_HEAP_BYTES, FETCH_GROUP_DOCUMENT_IDS, FORWARD_RETRY_DELAY_CAP_MS, FORWARD_RETRY_INITIAL_DELAY_MS, FULL_MEMORY_COLLECTION_INTERVAL_MS, MAX_CATCH_UP_IN_FLIGHT_BYTES, MAX_DROP_ACKNOWLEDGE_WAIT_MS, MAX_NODE_LEFT_DELAY_MS,
|
|
301
|
+
export { ADMISSION_TIMEOUT_MS, ANSWER_DECODE_HEAP_BYTES_PER_PAYLOAD_BYTE, CASE_FOLD_EXPANSION_FACTOR, CATCH_UP_FEED_WINDOW_MS, CATCH_UP_TICK_MS, CLEAR_PAGE_SIZE, COORDINATOR_REQUEST_BUCKET_BOUNDS_SECONDS, COPY_FAILURE_ATTEMPTS, COPY_FAILURE_RETRY_DELAY_MS, DECOMMISSION_RECHECK_INTERVAL_MS, DEFAULT_BLOCK_WRITES_ABOVE, DEFAULT_BOOTSTRAP_SYNC_DEADLINE_MS, DEFAULT_CAPACITY, DEFAULT_CREATE_INDEX_WAIT_MS, DEFAULT_IN_FLIGHT_WRITE_FRACTION, DEFAULT_MAX_PER_SOURCE_SNAPSHOTS, DEFAULT_MAX_STREAMS_PER_INDEX, DEFAULT_PARTITION_COUNT, DEFAULT_REPLICATION_FACTOR, DEFAULT_RESUME_WRITES_BELOW, DISTINCT_TERM_HEAP_BYTES, DOCUMENT_HEAP_BYTES_PER_ESTIMATED_BYTE, DOCUMENT_PROPERTY_HEAP_BYTES, DOCUMENT_VALUE_HEAP_BYTES, DROP_ACKNOWLEDGE_POLL_INTERVAL_MS, ENUM_VALUE_HEAP_BYTES, FETCH_GROUP_DOCUMENT_IDS, FORWARD_RETRY_DELAY_CAP_MS, FORWARD_RETRY_INITIAL_DELAY_MS, FULL_MEMORY_COLLECTION_INTERVAL_MS, MAX_CATCH_UP_IN_FLIGHT_BYTES, MAX_DROP_ACKNOWLEDGE_WAIT_MS, MAX_NODE_LEFT_DELAY_MS, MAX_SETTINGS_REPLACEMENT_ATTEMPTS, MAX_SOURCE_ID_LENGTH, MAX_WAIT_FOR_ACTIVE_REPLICAS, MEMORY_SAMPLE_INTERVAL_MS, MIN_CONTROLLER_LEASE_TTL_MS, NORMALIZATION_EXPANSION_FACTOR, PARTIAL_SPELLING_HEAP_BYTES, PARTITION_BYTES_ENTRY_BYTES, PARTITION_BYTES_INDEX_OVERHEAD_BYTES, PARTITION_BYTES_REPORT_BUDGET_BYTES, PARTITION_WRITE_CONCURRENCY, PATTERN_RUN_HEAP_BYTES, PRIMARY_CHANGE_POLL_INTERVAL_MS, PRIMARY_CHANGE_RETRY_WINDOW_MS, REGISTRATION_LEASE_CONFIRM_TIMEOUT_MS, REGISTRATION_LEASE_DRIFT_SHARE, ROLLBACK_RETRY_DELAY_CAP_MS, ROLLBACK_RETRY_INITIAL_DELAY_MS, SEARCH_CONTEXT_ENTRY_HEAP_BYTES, SEARCH_CONTEXT_REAPER_INTERVAL_MS, SNAPSHOT_CHUNK_YIELD_INTERVAL_MS, SYNCED_POSITION_REPORT_TIMEOUT_MS, TERM_UNIT_HEAP_BYTES, VECTOR_COMPONENT_HEAP_BYTES, VECTOR_DOCUMENT_HEAP_BYTES, WRITE_APPLY_YIELD_INTERVAL_MS, WRITE_MEMORY_SAMPLE_MAX_AGE_MS, answerRefusalOf, createWritePressure, estimateDocumentBytes, estimateDocumentsBytes, estimateForwardedBytes, readMemoryFigures, readRecentMemoryFigures, refuseEncodeWithoutRoom, withAdmittedWrite };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/core/partition/constants.ts
|
|
2
|
+
var TARGET_BLOCK_ENTRIES = 128;
|
|
3
|
+
var PRUNING_REJECTION_SLACK = 1e-12;
|
|
4
|
+
var SCORE_BUFFER_INITIAL_TOUCHED_CAPACITY = 1024;
|
|
5
|
+
var SEGMENT_TOKEN_TABLE_START = 1 << 12;
|
|
6
|
+
var PHRASE_ROWS_START = 16;
|
|
7
|
+
var PHRASE_SORT_RADIX_BITS = 11;
|
|
8
|
+
var PHRASE_SORT_CLOCK_ROWS = 65536;
|
|
9
|
+
var SEGMENT_POSTING_LOG_START = 1 << 14;
|
|
10
|
+
var SEGMENT_POSITION_POOL_START = 1 << 16;
|
|
11
|
+
var SEGMENT_FIELD_SCRATCH_START = 1 << 10;
|
|
12
|
+
var LOOKUP_KEY_SCRATCH_BYTES = 4096;
|
|
13
|
+
var FROZEN_REMOVAL_INDEX_MAX_PROCESS_FRACTION = 0.9;
|
|
14
|
+
var SORT_COLUMN_MINIMUM_REBUILD_THRESHOLD = 1024;
|
|
15
|
+
var SORT_COLUMN_REBUILD_FRACTION_SHIFT = 2;
|
|
16
|
+
|
|
17
|
+
export { FROZEN_REMOVAL_INDEX_MAX_PROCESS_FRACTION, LOOKUP_KEY_SCRATCH_BYTES, PHRASE_ROWS_START, PHRASE_SORT_CLOCK_ROWS, PHRASE_SORT_RADIX_BITS, PRUNING_REJECTION_SLACK, SCORE_BUFFER_INITIAL_TOUCHED_CAPACITY, SEGMENT_FIELD_SCRATCH_START, SEGMENT_POSITION_POOL_START, SEGMENT_POSTING_LOG_START, SEGMENT_TOKEN_TABLE_START, SORT_COLUMN_MINIMUM_REBUILD_THRESHOLD, SORT_COLUMN_REBUILD_FRACTION_SHIFT, TARGET_BLOCK_ENTRIES };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MIN_HYBRID_DEPTH, MAX_HYBRID_DEPTH } from './chunk-
|
|
2
|
-
import { NarsilError, ErrorCodes } from './chunk-
|
|
1
|
+
import { MIN_HYBRID_DEPTH, MAX_HYBRID_DEPTH } from './chunk-FQBFZAWG.mjs';
|
|
2
|
+
import { NarsilError, ErrorCodes } from './chunk-CZ7ISLXA.mjs';
|
|
3
3
|
|
|
4
4
|
// src/search/hybrid-depth.ts
|
|
5
5
|
function fixedHybridDepthOf(hybrid) {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { normalizeSort, requireMatchingCursor, encodePageCursor, decodePageCursor, projectionKeepsField, resolveProjection, clampRowCount, sortSignatureOf, requireSortableFields, fanOutQuery, requireWithinResultWindow, sortModesOf, applySorting, applyPagination, countsWithoutScores, fanOutMatchCount, FNV_OFFSET_BASIS, validatedFilterOf, createPatternWorkMeter, partialWordsToHighlight, partialWordHighlighter, pruneStatsToQueryTerms, everyValueFacetConfig, fulltextMatches, mergeFacets, applyPartitionFiltersBitset, fnv1aContinue, partitionsIn, fnv1aContinueTaggedNumbers, undeclaredFieldOnStrictIndex } from './chunk-
|
|
2
|
-
import { MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN, MAX_DOC_ID_LENGTH, DEFAULT_LIMIT, DEFAULT_SUGGEST_LIMIT, MAX_SUGGEST_LIMIT, MAX_SUGGEST_SCATTER_LIMIT, ABSOLUTE_WINDOWS_PATH_PATTERN, MODULE_URL_SCHEME_PATTERN, DEFAULT_OFFSET } from './chunk-
|
|
1
|
+
import { normalizeSort, requireMatchingCursor, encodePageCursor, decodePageCursor, projectionKeepsField, resolveProjection, clampRowCount, bm25SetsValue, sortSignatureOf, requireSortableFields, analyseQueryPhrases, requireLoadedPhraseCode, fanOutQuery, loadPhraseCodeFor, requireWithinResultWindow, sortModesOf, applySorting, applyPagination, countsWithoutScores, fanOutMatchCount, FNV_OFFSET_BASIS, validatedFilterOf, createPatternWorkMeter, partialWordsToHighlight, partialWordHighlighter, pruneStatsToQueryTerms, mergeBM25Levels, everyValueFacetConfig, fulltextMatches, mergeFacets, applyPartitionFiltersBitset, fnv1aContinue, partitionsIn, fnv1aContinueTaggedNumbers, undeclaredFieldOnStrictIndex, MAX_BM25_K1, MAX_BM25_B } from './chunk-2MKX2SCO.mjs';
|
|
2
|
+
import { MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN, MAX_DOC_ID_LENGTH, DEFAULT_LIMIT, DEFAULT_SUGGEST_LIMIT, MAX_SUGGEST_LIMIT, MAX_SUGGEST_SCATTER_LIMIT, ABSOLUTE_WINDOWS_PATH_PATTERN, MODULE_URL_SCHEME_PATTERN, DEFAULT_OFFSET } from './chunk-RNSC4NFI.mjs';
|
|
3
3
|
import { MIN_OVERSAMPLE, MAX_RENUMBERED_SEARCH_ATTEMPTS } from './chunk-QSK35UC2.mjs';
|
|
4
|
-
import { flattenSchema, partialFieldsOf } from './chunk-
|
|
5
|
-
import { DEFAULT_MAX_PER_GROUP, DEFAULT_FUZZY_PREFIX_LENGTH, DEFAULT_LINEAR_ALPHA, MIN_LINEAR_ALPHA, MAX_LINEAR_ALPHA, DEFAULT_RANK_CONSTANT, MIN_RANK_CONSTANT, RESULT_WINDOW, MAX_TOLERANCE, MAX_PREFIX_LENGTH } from './chunk-
|
|
4
|
+
import { flattenSchema, partialFieldsOf } from './chunk-PU6SKH7O.mjs';
|
|
5
|
+
import { DEFAULT_MAX_PER_GROUP, DEFAULT_FUZZY_PREFIX_LENGTH, BM25_DISPLAYED_NAME_LENGTH, DEFAULT_LINEAR_ALPHA, MIN_LINEAR_ALPHA, MAX_LINEAR_ALPHA, DEFAULT_RANK_CONSTANT, MIN_RANK_CONSTANT, RESULT_WINDOW, MAX_TOLERANCE, MAX_PREFIX_LENGTH } from './chunk-FQBFZAWG.mjs';
|
|
6
6
|
import { fuzzyTermMatches } from './chunk-GES7U2PM.mjs';
|
|
7
|
-
import { isStringValuedBase, parsedTypeOf, isWordIndexedFieldType } from './chunk-
|
|
8
|
-
import { tokenize } from './chunk-
|
|
7
|
+
import { isStringValuedBase, parsedTypeOf, isWordIndexedFieldType } from './chunk-7XY6VD7B.mjs';
|
|
8
|
+
import { tokenize } from './chunk-D5TFRB5G.mjs';
|
|
9
9
|
import { compareComparableKeys } from './chunk-R6A773WK.mjs';
|
|
10
10
|
import { compareCodePoints, holdsUnpairedSurrogate } from './chunk-YTJCGKM4.mjs';
|
|
11
|
-
import { MIN_PATTERN_VALUE_LIMIT, MAX_PATTERN_VALUE_LIMIT, isGeopointOrVectorType, VECTOR_PATTERN } from './chunk-L5ORED7V.mjs';
|
|
12
|
-
import { NarsilError, ErrorCodes } from './chunk-
|
|
11
|
+
import { MIN_PATTERN_VALUE_LIMIT, MAX_PATTERN_VALUE_LIMIT, isPlainObject, isGeopointOrVectorType, VECTOR_PATTERN } from './chunk-L5ORED7V.mjs';
|
|
12
|
+
import { NarsilError, ErrorCodes } from './chunk-CZ7ISLXA.mjs';
|
|
13
13
|
|
|
14
14
|
// src/search/cursor-binding.ts
|
|
15
15
|
var ABSENT_TAG = 0;
|
|
@@ -154,6 +154,27 @@ function boundRerankOf(rerank) {
|
|
|
154
154
|
}
|
|
155
155
|
return present;
|
|
156
156
|
}
|
|
157
|
+
function presentMembersOf(record) {
|
|
158
|
+
const present = {};
|
|
159
|
+
for (const [key, value] of Object.entries(record)) {
|
|
160
|
+
if (value !== void 0) present[key] = value;
|
|
161
|
+
}
|
|
162
|
+
return present;
|
|
163
|
+
}
|
|
164
|
+
function boundBm25Of(bm25) {
|
|
165
|
+
const bound = presentMembersOf(bm25);
|
|
166
|
+
const fields = bm25.fields;
|
|
167
|
+
if (typeof fields !== "object" || fields === null) return bound;
|
|
168
|
+
const boundFields = {};
|
|
169
|
+
for (const [name, pair] of Object.entries(fields)) {
|
|
170
|
+
const members = typeof pair === "object" && pair !== null ? presentMembersOf(pair) : pair;
|
|
171
|
+
if (typeof members === "object" && members !== null && Object.keys(members).length === 0) continue;
|
|
172
|
+
boundFields[name] = members;
|
|
173
|
+
}
|
|
174
|
+
if (Object.keys(boundFields).length === 0) delete bound.fields;
|
|
175
|
+
else bound.fields = boundFields;
|
|
176
|
+
return bound;
|
|
177
|
+
}
|
|
157
178
|
var FILTERS_SLOT = 2;
|
|
158
179
|
var BOUND_SLOT_COUNT = 16;
|
|
159
180
|
function bindingOf(values, clock) {
|
|
@@ -184,6 +205,7 @@ function queryBindingOf(params, clock) {
|
|
|
184
205
|
params.scoring ?? "local"
|
|
185
206
|
];
|
|
186
207
|
if (params.rerank !== void 0) values.push(boundRerankOf(params.rerank));
|
|
208
|
+
if (params.bm25 !== void 0 && bm25SetsValue(params.bm25)) values.push(boundBm25Of(params.bm25));
|
|
187
209
|
return bindingOf(values, clock);
|
|
188
210
|
}
|
|
189
211
|
function lazyQueryBinding(params, clock) {
|
|
@@ -199,6 +221,110 @@ function listBindingOf(filters) {
|
|
|
199
221
|
return bindingOf(values);
|
|
200
222
|
}
|
|
201
223
|
|
|
224
|
+
// src/search/bm25-params.ts
|
|
225
|
+
var BM25_KEYS = /* @__PURE__ */ new Set(["k1", "b", "fields"]);
|
|
226
|
+
var BM25_FIELD_KEYS = /* @__PURE__ */ new Set(["k1", "b"]);
|
|
227
|
+
function displayed(value) {
|
|
228
|
+
if (typeof value === "string") return `"${value.slice(0, BM25_DISPLAYED_NAME_LENGTH)}"`;
|
|
229
|
+
if (typeof value === "number" || typeof value === "boolean" || value === null) return String(value);
|
|
230
|
+
return `a value of type ${typeof value}`;
|
|
231
|
+
}
|
|
232
|
+
function requireValue(label, value, maximum, ranges) {
|
|
233
|
+
if (value === void 0) return;
|
|
234
|
+
const usable = typeof value === "number" && Number.isFinite(value) && (ranges === "stored" || value >= 0 && value <= maximum);
|
|
235
|
+
if (usable) return;
|
|
236
|
+
throw new NarsilError(
|
|
237
|
+
ErrorCodes.CONFIG_INVALID,
|
|
238
|
+
`${label} must be a finite number from 0 to ${maximum}, and this request sets ${displayed(value)}`,
|
|
239
|
+
{ parameter: label }
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
function requireKnownKeys(label, value, known) {
|
|
243
|
+
for (const key of Object.keys(value)) {
|
|
244
|
+
if (known.has(key)) continue;
|
|
245
|
+
throw new NarsilError(
|
|
246
|
+
ErrorCodes.CONFIG_INVALID,
|
|
247
|
+
`${label} takes ${[...known].join(", ")}, and this request sets ${displayed(key)}`,
|
|
248
|
+
{ parameter: label }
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function requireFieldPair(name, pair, ranges) {
|
|
253
|
+
const label = `bm25.fields.${name.slice(0, BM25_DISPLAYED_NAME_LENGTH)}`;
|
|
254
|
+
if (!isPlainObject(pair)) {
|
|
255
|
+
throw new NarsilError(ErrorCodes.CONFIG_INVALID, `${label} must be an object that sets k1 or b`, {
|
|
256
|
+
parameter: label
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
requireKnownKeys(label, pair, BM25_FIELD_KEYS);
|
|
260
|
+
requireValue(`${label}.k1`, pair.k1, MAX_BM25_K1, ranges);
|
|
261
|
+
requireValue(`${label}.b`, pair.b, MAX_BM25_B, ranges);
|
|
262
|
+
}
|
|
263
|
+
function requireScoredField(name, flatSchema, unknownFieldCode) {
|
|
264
|
+
const fieldType = Object.hasOwn(flatSchema, name) ? flatSchema[name] : void 0;
|
|
265
|
+
if (typeof fieldType === "string" && isWordIndexedFieldType(fieldType)) return;
|
|
266
|
+
throw new NarsilError(
|
|
267
|
+
unknownFieldCode,
|
|
268
|
+
fieldType === void 0 ? `BM25 parameters apply to a text field that the schema declares, and the schema declares no field ${displayed(name)}` : `BM25 parameters apply to a text field alone, and the schema declares field ${displayed(name)} as ${displayed(fieldType)}`,
|
|
269
|
+
{ field: name.slice(0, BM25_DISPLAYED_NAME_LENGTH) }
|
|
270
|
+
);
|
|
271
|
+
}
|
|
272
|
+
function fieldsOfCheckedSetting(raw, ranges) {
|
|
273
|
+
if (!isPlainObject(raw)) {
|
|
274
|
+
throw new NarsilError(ErrorCodes.CONFIG_INVALID, "bm25 must be an object that sets k1, b, or fields");
|
|
275
|
+
}
|
|
276
|
+
requireKnownKeys("bm25", raw, BM25_KEYS);
|
|
277
|
+
requireValue("bm25.k1", raw.k1, MAX_BM25_K1, ranges);
|
|
278
|
+
requireValue("bm25.b", raw.b, MAX_BM25_B, ranges);
|
|
279
|
+
const fields = raw.fields;
|
|
280
|
+
if (fields === void 0) return void 0;
|
|
281
|
+
if (!isPlainObject(fields)) {
|
|
282
|
+
throw new NarsilError(
|
|
283
|
+
ErrorCodes.CONFIG_INVALID,
|
|
284
|
+
"bm25.fields must be an object that maps a field to its parameters"
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
return fields;
|
|
288
|
+
}
|
|
289
|
+
function validateBM25Shape(raw, ranges) {
|
|
290
|
+
const fields = fieldsOfCheckedSetting(raw, ranges);
|
|
291
|
+
if (fields === void 0) return;
|
|
292
|
+
for (const name of Object.keys(fields)) requireFieldPair(name, fields[name], ranges);
|
|
293
|
+
}
|
|
294
|
+
function validateBM25Params(raw, schema, unknownFieldCode, ranges = "settable") {
|
|
295
|
+
const fields = fieldsOfCheckedSetting(raw, ranges);
|
|
296
|
+
if (fields === void 0) return;
|
|
297
|
+
const names = Object.keys(fields);
|
|
298
|
+
if (names.length === 0) return;
|
|
299
|
+
const flatSchema = flattenSchema(schema);
|
|
300
|
+
for (const name of names) {
|
|
301
|
+
requireScoredField(name, flatSchema, unknownFieldCode);
|
|
302
|
+
requireFieldPair(name, fields[name], ranges);
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
function presentPair(pair) {
|
|
306
|
+
return {
|
|
307
|
+
...pair.k1 !== void 0 ? { k1: pair.k1 } : {},
|
|
308
|
+
...pair.b !== void 0 ? { b: pair.b } : {}
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
function storedBM25Params(params) {
|
|
312
|
+
const stored = presentPair(params);
|
|
313
|
+
const fields = params.fields;
|
|
314
|
+
if (fields !== void 0) {
|
|
315
|
+
const kept = /* @__PURE__ */ Object.create(null);
|
|
316
|
+
let holdsField = false;
|
|
317
|
+
for (const name of Object.keys(fields)) {
|
|
318
|
+
const pair = presentPair(fields[name]);
|
|
319
|
+
if (pair.k1 === void 0 && pair.b === void 0) continue;
|
|
320
|
+
kept[name] = pair;
|
|
321
|
+
holdsField = true;
|
|
322
|
+
}
|
|
323
|
+
if (holdsField) stored.fields = kept;
|
|
324
|
+
}
|
|
325
|
+
return Object.keys(stored).length === 0 ? void 0 : stored;
|
|
326
|
+
}
|
|
327
|
+
|
|
202
328
|
// src/search/query-fields.ts
|
|
203
329
|
function requireBoostableFields(boost, flatSchema) {
|
|
204
330
|
for (const [field, weight] of Object.entries(boost)) {
|
|
@@ -246,6 +372,7 @@ function requireGroupableFields(fields, flatSchema, strict) {
|
|
|
246
372
|
}
|
|
247
373
|
}
|
|
248
374
|
function requireUsableQueryFields(params, schema, strict = false) {
|
|
375
|
+
if (params.bm25 !== void 0) validateBM25Params(params.bm25, schema, ErrorCodes.SEARCH_INVALID_FIELD);
|
|
249
376
|
const groupFields = params.group?.fields;
|
|
250
377
|
const checksGroup = Array.isArray(groupFields) && groupFields.length > 0;
|
|
251
378
|
if (params.boost === void 0 && params.facets === void 0 && !checksGroup) return;
|
|
@@ -324,9 +451,13 @@ function broadcastStatsForWorker(params, context, scoring) {
|
|
|
324
451
|
expansion: { options: params, schema: context.config.schema }
|
|
325
452
|
});
|
|
326
453
|
}
|
|
327
|
-
function
|
|
454
|
+
function bm25SettingFor(params, context) {
|
|
455
|
+
return mergeBM25Levels(params.bm25, context.indexBm25 ?? context.config.bm25);
|
|
456
|
+
}
|
|
457
|
+
function searchOptionsFor(params, context) {
|
|
458
|
+
const { manager, patternWork } = context;
|
|
328
459
|
return {
|
|
329
|
-
bm25Params:
|
|
460
|
+
bm25Params: bm25SettingFor(params, context),
|
|
330
461
|
stopWords: manager.analysis.stopWords,
|
|
331
462
|
customTokenizer: manager.analysis.customTokenizer,
|
|
332
463
|
synonyms: manager.synonyms,
|
|
@@ -378,6 +509,13 @@ function validQueryFilter(filters, schema) {
|
|
|
378
509
|
if (filters === void 0 || filters === null) return filters;
|
|
379
510
|
return validatedFilterOf(filters, flattenSchema(schema));
|
|
380
511
|
}
|
|
512
|
+
function requireUsablePhrases(params, context) {
|
|
513
|
+
if (params.term === void 0) return;
|
|
514
|
+
const quoted = analyseQueryPhrases(params.term, context.language, context.manager.analysis);
|
|
515
|
+
if (quoted === null || quoted.keptPhraseCount === 0) return;
|
|
516
|
+
requireLoadedPhraseCode().requirePhrasesWithinLimits(quoted, context.config.trackPositions !== false);
|
|
517
|
+
context.requirePhraseReady?.();
|
|
518
|
+
}
|
|
381
519
|
function requireVectorSearchable(params, context, needsVector) {
|
|
382
520
|
if (!needsVector) return;
|
|
383
521
|
const field = params.vector?.field;
|
|
@@ -532,16 +670,6 @@ function validateWorkerConfig(workers, lifecycle) {
|
|
|
532
670
|
);
|
|
533
671
|
}
|
|
534
672
|
}
|
|
535
|
-
function validateBM25Params(bm25) {
|
|
536
|
-
if (bm25 === void 0) return;
|
|
537
|
-
const { k1, b } = bm25;
|
|
538
|
-
if (k1 !== void 0 && (!Number.isFinite(k1) || k1 < 0)) {
|
|
539
|
-
throw new NarsilError(ErrorCodes.CONFIG_INVALID, "bm25.k1 must be a finite number at or above 0", { k1 });
|
|
540
|
-
}
|
|
541
|
-
if (b !== void 0 && (!Number.isFinite(b) || b < 0 || b > 1)) {
|
|
542
|
-
throw new NarsilError(ErrorCodes.CONFIG_INVALID, "bm25.b must be between 0 and 1", { b });
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
673
|
function clampLimit(limit) {
|
|
546
674
|
return clampRowCount(limit, DEFAULT_LIMIT);
|
|
547
675
|
}
|
|
@@ -936,8 +1064,8 @@ function highlightField(text, queryTokens, language, options) {
|
|
|
936
1064
|
}
|
|
937
1065
|
|
|
938
1066
|
// src/engine/query/highlight.ts
|
|
939
|
-
function writtenWordsOf(
|
|
940
|
-
return tokenize(
|
|
1067
|
+
function writtenWordsOf(term, language, analysis) {
|
|
1068
|
+
return tokenize(term, language, {
|
|
941
1069
|
stem: false,
|
|
942
1070
|
removeStopWords: true,
|
|
943
1071
|
customTokenizer: analysis.customTokenizer,
|
|
@@ -955,18 +1083,21 @@ function partialWordTagging(params, schema, queryTokens, written, analysis) {
|
|
|
955
1083
|
highlight: { words, customTokenizer: analysis.customTokenizer, stopWordOverride: analysis.stopWords }
|
|
956
1084
|
};
|
|
957
1085
|
}
|
|
958
|
-
function applyHighlights(hits,
|
|
959
|
-
if (!
|
|
960
|
-
const
|
|
1086
|
+
function applyHighlights(hits, request, language, analysis, schema, readStoredDocument, synonymLookup) {
|
|
1087
|
+
if (!request.highlight) return;
|
|
1088
|
+
const quoted = analyseQueryPhrases(request.term ?? "", language, analysis);
|
|
1089
|
+
const params = quoted === null ? request : requireLoadedPhraseCode().withWordsOnly(request, quoted);
|
|
1090
|
+
const words = params.term ?? "";
|
|
1091
|
+
const highlightConfig = request.highlight;
|
|
1092
|
+
const queryTokens = quoted !== null && words.trim().length === 0 ? [] : tokenize(words, language, {
|
|
961
1093
|
stem: true,
|
|
962
1094
|
removeStopWords: true,
|
|
963
1095
|
customTokenizer: analysis.customTokenizer,
|
|
964
1096
|
stopWordOverride: analysis.stopWords
|
|
965
|
-
});
|
|
966
|
-
const queryTokens = queryTokenResult.tokens;
|
|
1097
|
+
}).tokens;
|
|
967
1098
|
const usesPrefix = params.prefix === true && params.exact !== true && queryTokens.length > 0;
|
|
968
1099
|
const usesPartialWords = params.partialWords === true && params.exact !== true && queryTokens.length > 0;
|
|
969
|
-
const written = usesPrefix || usesPartialWords ? writtenWordsOf(
|
|
1100
|
+
const written = usesPrefix || usesPartialWords ? writtenWordsOf(words, language, analysis) : [];
|
|
970
1101
|
let prefixToken;
|
|
971
1102
|
let completedToken;
|
|
972
1103
|
if (usesPrefix) {
|
|
@@ -980,12 +1111,14 @@ function applyHighlights(hits, params, language, analysis, schema, readStoredDoc
|
|
|
980
1111
|
}
|
|
981
1112
|
}
|
|
982
1113
|
const partialWords = usesPartialWords ? partialWordTagging(params, schema, queryTokens, written, analysis) : null;
|
|
983
|
-
const
|
|
1114
|
+
const wordSynonyms = params.exact === true || queryTokens.length === 0 ? void 0 : synonymLookup?.expand(queryTokens.map((qt) => qt.token))?.tokens;
|
|
1115
|
+
const phraseTokens = quoted?.phrases.flatMap((phrase) => phrase.tokens) ?? [];
|
|
1116
|
+
const synonyms = phraseTokens.length === 0 ? wordSynonyms : [...wordSynonyms ?? [], ...phraseTokens];
|
|
984
1117
|
for (const hit of hits) {
|
|
985
1118
|
const highlights = {};
|
|
986
1119
|
const projected = hit.document;
|
|
987
1120
|
let stored;
|
|
988
|
-
for (const field of
|
|
1121
|
+
for (const field of highlightConfig.fields) {
|
|
989
1122
|
let fieldValue = projected[field];
|
|
990
1123
|
if (typeof fieldValue !== "string" && readStoredDocument !== void 0) {
|
|
991
1124
|
stored ??= readStoredDocument(hit.id);
|
|
@@ -993,9 +1126,9 @@ function applyHighlights(hits, params, language, analysis, schema, readStoredDoc
|
|
|
993
1126
|
}
|
|
994
1127
|
if (typeof fieldValue === "string") {
|
|
995
1128
|
highlights[field] = highlightField(fieldValue, queryTokens, language, {
|
|
996
|
-
preTag:
|
|
997
|
-
postTag:
|
|
998
|
-
maxSnippetLength:
|
|
1129
|
+
preTag: highlightConfig.preTag,
|
|
1130
|
+
postTag: highlightConfig.postTag,
|
|
1131
|
+
maxSnippetLength: highlightConfig.maxSnippetLength,
|
|
999
1132
|
prefixToken,
|
|
1000
1133
|
completedToken,
|
|
1001
1134
|
tolerance: params.exact === true ? 0 : params.tolerance ?? 0,
|
|
@@ -1240,7 +1373,8 @@ async function textLeg(textOnlyParams, context) {
|
|
|
1240
1373
|
textOnlyParams,
|
|
1241
1374
|
broadcastStatsForWorker(textOnlyParams, context, scoring),
|
|
1242
1375
|
context.partitionIds,
|
|
1243
|
-
context.patternWork
|
|
1376
|
+
context.patternWork,
|
|
1377
|
+
bm25SettingFor(textOnlyParams, context)
|
|
1244
1378
|
);
|
|
1245
1379
|
if (viaWorker) return viaWorker;
|
|
1246
1380
|
}
|
|
@@ -1250,7 +1384,7 @@ async function textLeg(textOnlyParams, context) {
|
|
|
1250
1384
|
language,
|
|
1251
1385
|
config.schema,
|
|
1252
1386
|
scoring,
|
|
1253
|
-
searchOptionsFor(
|
|
1387
|
+
searchOptionsFor(textOnlyParams, context)
|
|
1254
1388
|
);
|
|
1255
1389
|
}
|
|
1256
1390
|
async function vectorLeg(vectorConfig, queryVector, context, filtered, k, rescoreWindow) {
|
|
@@ -1348,7 +1482,7 @@ function executeSortedQueryPage(params, context, limit, offset, sortSignature) {
|
|
|
1348
1482
|
const flatSchema = flattenSchema(schema);
|
|
1349
1483
|
const fieldTypes = fields.map((field) => flatSchema[field]);
|
|
1350
1484
|
const modes = sortModesOf(normalized);
|
|
1351
|
-
const options = searchOptionsFor(
|
|
1485
|
+
const options = searchOptionsFor(params, context);
|
|
1352
1486
|
const partitions = partitionsFor(manager, context.partitionIds);
|
|
1353
1487
|
const partitionLimit = offset + limit + 1;
|
|
1354
1488
|
const merged = [];
|
|
@@ -1416,13 +1550,17 @@ function requireCursorDepth(cursor, signature, binding) {
|
|
|
1416
1550
|
}
|
|
1417
1551
|
function hybridSearchOf(params, context, limit, offset, cursorDepth) {
|
|
1418
1552
|
if ((params.hybrid?.depth ?? null) === null) return executeHybridSearch(params, context, limit, offset, cursorDepth);
|
|
1419
|
-
return import('./runtime-
|
|
1553
|
+
return import('./runtime-7MLQ7J64.mjs').then(
|
|
1420
1554
|
(runtime) => runtime.searchFixedDepthHybrid(params, context, { cursorDepth: cursorDepth ?? 0, offset, limit }, runtimeHost)
|
|
1421
1555
|
);
|
|
1422
1556
|
}
|
|
1423
1557
|
function executeQuery(request, callerContext) {
|
|
1424
|
-
if (request.rerank === void 0)
|
|
1425
|
-
|
|
1558
|
+
if (request.rerank === void 0) {
|
|
1559
|
+
const loadingPhraseCode = loadPhraseCodeFor(request.term);
|
|
1560
|
+
if (loadingPhraseCode === null) return runQuery(request, callerContext);
|
|
1561
|
+
return loadingPhraseCode.then(() => runQuery(request, callerContext));
|
|
1562
|
+
}
|
|
1563
|
+
return import('./runtime-7MLQ7J64.mjs').then(
|
|
1426
1564
|
(runtime) => runtime.executeRerankedQuery(request, callerContext, executeQuery, runtimeHost)
|
|
1427
1565
|
);
|
|
1428
1566
|
}
|
|
@@ -1449,6 +1587,7 @@ async function runQuery(request, callerContext) {
|
|
|
1449
1587
|
}
|
|
1450
1588
|
const params = validQueryParams(request, config);
|
|
1451
1589
|
requireVectorSearchable(params, context, isVectorOnly || isHybridMode);
|
|
1590
|
+
if (!isVectorOnly) requireUsablePhrases(params, context);
|
|
1452
1591
|
const projection = resolveProjection(params.document);
|
|
1453
1592
|
let paginated;
|
|
1454
1593
|
let nextCursor;
|
|
@@ -1479,7 +1618,8 @@ async function runQuery(request, callerContext) {
|
|
|
1479
1618
|
params,
|
|
1480
1619
|
broadcastStatsForWorker(params, context, scoring),
|
|
1481
1620
|
context.partitionIds,
|
|
1482
|
-
context.patternWork
|
|
1621
|
+
context.patternWork,
|
|
1622
|
+
bm25SettingFor(params, context)
|
|
1483
1623
|
) : null;
|
|
1484
1624
|
if (workerResult) {
|
|
1485
1625
|
fanOutResult = workerResult;
|
|
@@ -1490,7 +1630,7 @@ async function runQuery(request, callerContext) {
|
|
|
1490
1630
|
language,
|
|
1491
1631
|
config.schema,
|
|
1492
1632
|
scoring,
|
|
1493
|
-
searchOptionsFor(
|
|
1633
|
+
searchOptionsFor(params, context)
|
|
1494
1634
|
);
|
|
1495
1635
|
}
|
|
1496
1636
|
}
|
|
@@ -1624,6 +1764,9 @@ async function executePreflight(request, callerContext) {
|
|
|
1624
1764
|
const isHybridMode = params.mode === "hybrid" || hasTerm && hasVector;
|
|
1625
1765
|
const isVectorOnly = (params.mode === "vector" || hasVector && !hasTerm) && !isHybridMode;
|
|
1626
1766
|
requireVectorSearchable(params, context, isVectorOnly || isHybridMode);
|
|
1767
|
+
const loadingPhraseCode = loadPhraseCodeFor(params.term);
|
|
1768
|
+
if (loadingPhraseCode !== null) await loadingPhraseCode;
|
|
1769
|
+
if (!isVectorOnly) requireUsablePhrases(params, context);
|
|
1627
1770
|
const requestedVectorField = params.vector?.field;
|
|
1628
1771
|
const hasGlobalVectorIndex = requestedVectorField !== void 0 && vectorSearchersOf(context).has(requestedVectorField);
|
|
1629
1772
|
let totalMatched;
|
|
@@ -1640,7 +1783,7 @@ async function executePreflight(request, callerContext) {
|
|
|
1640
1783
|
countExact = result.matchedExact !== false;
|
|
1641
1784
|
} else if (countsWithoutScores(params)) {
|
|
1642
1785
|
totalMatched = fanOutMatchCount(manager, params, language, config.schema, {
|
|
1643
|
-
searchOptions: searchOptionsFor(
|
|
1786
|
+
searchOptions: searchOptionsFor(params, context),
|
|
1644
1787
|
partitionIds: context.partitionIds
|
|
1645
1788
|
});
|
|
1646
1789
|
} else {
|
|
@@ -1650,7 +1793,8 @@ async function executePreflight(request, callerContext) {
|
|
|
1650
1793
|
params,
|
|
1651
1794
|
broadcastStatsForWorker(params, context, scoring),
|
|
1652
1795
|
context.partitionIds,
|
|
1653
|
-
context.patternWork
|
|
1796
|
+
context.patternWork,
|
|
1797
|
+
bm25SettingFor(params, context)
|
|
1654
1798
|
) : null;
|
|
1655
1799
|
if (workerResult) {
|
|
1656
1800
|
totalMatched = workerResult.totalMatched;
|
|
@@ -1661,7 +1805,7 @@ async function executePreflight(request, callerContext) {
|
|
|
1661
1805
|
language,
|
|
1662
1806
|
config.schema,
|
|
1663
1807
|
scoring,
|
|
1664
|
-
searchOptionsFor(
|
|
1808
|
+
searchOptionsFor(params, context)
|
|
1665
1809
|
);
|
|
1666
1810
|
totalMatched = fanOutResult.totalMatched;
|
|
1667
1811
|
}
|
|
@@ -1717,4 +1861,4 @@ function pickDisplaySurface(surfaceOccurrences) {
|
|
|
1717
1861
|
return best;
|
|
1718
1862
|
}
|
|
1719
1863
|
|
|
1720
|
-
export { clampLimit, dedupePinnedEntries, executeListDocuments, executePreflight, executeQuery, executeSuggest, foldGroupReducer, hitsKeptPerGroup, lazyQueryBinding, listBindingOf, now, queryBindingOf, requireSurfaceFormsForPartialFields, resolveHybridFusion, runtimeHost, validateBM25Params, validateDocId, validateIndexName, validatePartitionConfig, validatePatternValueLimit, validateWorkerConfig };
|
|
1864
|
+
export { clampLimit, dedupePinnedEntries, executeListDocuments, executePreflight, executeQuery, executeSuggest, foldGroupReducer, hitsKeptPerGroup, lazyQueryBinding, listBindingOf, now, queryBindingOf, requireSurfaceFormsForPartialFields, resolveHybridFusion, runtimeHost, storedBM25Params, validateBM25Params, validateBM25Shape, validateDocId, validateIndexName, validatePartitionConfig, validatePatternValueLimit, validateWorkerConfig };
|