@delali/narsil 0.3.1-next.96 → 0.3.1-next.98
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 +2 -1
- package/dist/adapters/filesystem.d.ts +1 -1
- package/dist/adapters/filesystem.mjs +1 -1
- package/dist/adapters/indexeddb.d.ts +1 -1
- package/dist/adapters/indexeddb.mjs +1 -1
- package/dist/adapters/memory.d.ts +1 -1
- package/dist/{adapters-79OIa4xm.d.ts → adapters-BQFQ4PRz.d.ts} +27 -1
- package/dist/browser/{chunk-ZGMR46O3.mjs → chunk-CN4I4FZU.mjs} +2 -2
- package/dist/browser/chunk-JPTQZWJQ.mjs +10 -0
- package/dist/browser/{chunk-WKPJ4E73.mjs → chunk-LD55ZGU3.mjs} +2 -1
- package/dist/browser/{chunk-KPMIHLOV.mjs → chunk-NAFT3K6X.mjs} +240 -135
- package/dist/browser/{chunk-3MYKLHRO.mjs → chunk-NNG3EEB6.mjs} +5 -4
- package/dist/browser/{chunk-HARBSUWP.mjs → chunk-QWES44AW.mjs} +2 -197
- package/dist/browser/chunk-RELZRJNR.mjs +203 -0
- package/dist/browser/{chunk-FYFQJKFW.mjs → chunk-Z7QH2XHB.mjs} +40 -45
- package/dist/browser/{durability-wiring-R7P64REL.mjs → durability-wiring-PY3L7DES.mjs} +7 -5
- package/dist/browser/{module-IEOQI5GI.mjs → module-PDXYHT75.mjs} +18 -10
- package/dist/browser/{restore-queue-WMYC5ZK6.mjs → restore-queue-DVIYJ7RU.mjs} +1 -1
- package/dist/browser/runtime-NYE5TB6O.mjs +557 -0
- package/dist/browser/{snapshot-3A3WDNHO.mjs → snapshot-J57MZK6L.mjs} +8 -6
- package/dist/browser/{write-JODZHKIF.mjs → write-L7FAQA47.mjs} +6 -4
- package/dist/{capabilities-BvxvFzVA.d.ts → capabilities-BTTIs96E.d.ts} +19 -3
- package/dist/{chunk-GJZHU4FC.mjs → chunk-2WYMG3OZ.mjs} +4 -4
- package/dist/{chunk-H75XXPMY.mjs → chunk-45AVKHMJ.mjs} +2 -2
- package/dist/{chunk-QM3VPX4Z.mjs → chunk-ASY5PHYI.mjs} +2 -2
- package/dist/{chunk-RDJKYKMQ.mjs → chunk-AY3AQ3UH.mjs} +1 -1
- package/dist/{chunk-2BY6K52M.mjs → chunk-BKB3XTMI.mjs} +6 -6
- package/dist/{chunk-MWT5WCJ5.mjs → chunk-COVCQ73F.mjs} +5 -5
- package/dist/{chunk-FGMGUDHX.mjs → chunk-E74YLAIG.mjs} +4 -1
- package/dist/chunk-FMWRCP2C.mjs +57 -0
- package/dist/{chunk-ES33L3HO.mjs → chunk-GGSH6KBQ.mjs} +1 -1
- package/dist/chunk-HJSN7UYG.mjs +10 -0
- package/dist/{chunk-ICL2AELD.mjs → chunk-HXJBSHXF.mjs} +40 -46
- package/dist/{chunk-ZHS44YKF.mjs → chunk-JFRNNBOM.mjs} +1 -1
- package/dist/{chunk-CHOGQSHK.mjs → chunk-K25LZA54.mjs} +39 -13
- package/dist/chunk-K7D4ZTSW.mjs +126 -0
- package/dist/{chunk-SYWGORQB.mjs → chunk-KV3AZFT3.mjs} +2 -0
- package/dist/chunk-KZ3NX2P7.mjs +21 -0
- package/dist/{chunk-GMY7F2VA.mjs → chunk-L3L5YFXC.mjs} +4 -4
- package/dist/{chunk-VVFLEGZI.mjs → chunk-LH4NZNJJ.mjs} +10 -10
- package/dist/{chunk-7KC56574.mjs → chunk-LU2CE5AE.mjs} +1 -1
- package/dist/{chunk-4ZJWRETC.mjs → chunk-LXPIXDUJ.mjs} +2 -2
- package/dist/{chunk-Q5DC6WAB.mjs → chunk-LXWDQLTW.mjs} +1 -1
- package/dist/{chunk-SBCEHIPL.mjs → chunk-MHOSCQCQ.mjs} +4 -4
- package/dist/{chunk-R36MIGBU.mjs → chunk-NKRBEGJZ.mjs} +169 -130
- package/dist/{chunk-LJBJQPB5.mjs → chunk-NTRMFARG.mjs} +7 -7
- package/dist/chunk-NW4XDSP2.mjs +212 -0
- package/dist/{chunk-BB7MASRQ.mjs → chunk-OOEXLUGR.mjs} +1 -1
- package/dist/{chunk-3LYY62M6.mjs → chunk-OWNZYMRE.mjs} +10 -10
- package/dist/{chunk-HBVLF3HA.mjs → chunk-PPY2GSIB.mjs} +1 -1
- package/dist/{chunk-WLOF6HSP.mjs → chunk-R7EEKAJE.mjs} +12 -3
- package/dist/{chunk-2GZGBOQI.mjs → chunk-RONEOEON.mjs} +2 -2
- package/dist/{chunk-T2QN2FA4.mjs → chunk-UCDF35PU.mjs} +2 -2
- package/dist/{chunk-O5WPRAVZ.mjs → chunk-VWULPWRJ.mjs} +60 -21
- package/dist/{chunk-F52QGNZ2.mjs → chunk-WCJKUGHB.mjs} +1 -1
- package/dist/{chunk-RUIXODYU.mjs → chunk-YA7XLE2R.mjs} +32 -5
- package/dist/{chunk-TCYUAUHF.mjs → chunk-ZG477IPV.mjs} +7 -7
- package/dist/chunk-ZYNAMIYX.mjs +113 -0
- package/dist/{client-DKwterMb.d.ts → client-i9eLJrw5.d.ts} +3 -3
- package/dist/client.d.ts +9 -9
- package/dist/client.mjs +2 -0
- package/dist/{config-6YBtxekG.d.ts → config-BGB_fDtq.d.ts} +2 -2
- package/dist/{config-DPphZfuM.d.ts → config-P__Diiy4.d.ts} +25 -3
- package/dist/direct-executor-CXZ66ACP.mjs +22 -0
- package/dist/distribution/coordinator/etcd.d.ts +3 -3
- package/dist/distribution/coordinator/etcd.mjs +1 -1
- package/dist/distribution/coordinator/in-memory.d.ts +3 -3
- package/dist/distribution/transport/grpc.mjs +1 -1
- package/dist/distribution.d.ts +24 -12
- package/dist/distribution.mjs +177 -54
- package/dist/{durability-wiring-2VBNYYDY.mjs → durability-wiring-QTHOGFMZ.mjs} +26 -25
- package/dist/embeddings/openai.d.ts +2 -2
- package/dist/embeddings/openai.mjs +22 -133
- package/dist/{engine-CbZmXUp6.d.ts → engine-BGCEm9E_.d.ts} +48 -18
- package/dist/{index-ONAEaqtx.d.ts → index-lcdGLyJH.d.ts} +1 -1
- package/dist/index.browser.mjs +4 -2
- package/dist/index.d.ts +8 -8
- package/dist/index.mjs +19 -18
- package/dist/invalidation/broadcast-channel.d.ts +1 -1
- package/dist/invalidation/filesystem.d.ts +1 -1
- package/dist/invalidation/noop.d.ts +1 -1
- package/dist/{memory-COdoGthn.d.ts → memory-CUEDwr-F.d.ts} +70 -2
- package/dist/{module-IUTNXWMV.mjs → module-3NONKBZX.mjs} +25 -18
- package/dist/partial-words.mjs +6 -6
- package/dist/pattern.mjs +3 -3
- package/dist/persistence/durability/checkpoint-worker.d.ts +2 -2
- package/dist/persistence/durability/checkpoint-worker.mjs +23 -22
- package/dist/react.d.ts +8 -8
- package/dist/react.mjs +2 -0
- package/dist/rerank-NWTKK636.mjs +60 -0
- package/dist/rerankers/http.d.ts +50 -0
- package/dist/rerankers/http.mjs +104 -0
- package/dist/{restore-queue-UFIQJTSG.mjs → restore-queue-JPRBUYII.mjs} +1 -1
- package/dist/runtime-ZKYZFJJC.mjs +177 -0
- package/dist/{schema-DttzM-ln.d.ts → schema-4W_7tk1f.d.ts} +2 -2
- package/dist/server.d.ts +11 -11
- package/dist/server.mjs +63 -22
- package/dist/{snapshot-XII3ANGW.mjs → snapshot-HOGXNO5W.mjs} +29 -28
- package/dist/synonyms.mjs +3 -3
- package/dist/{tasks-BJmamiC4.d.ts → tasks-HG3rlxx6.d.ts} +1 -1
- package/dist/{thread-U7XYJWGG.mjs → thread-B657LQXK.mjs} +49 -30
- package/dist/vector/search-worker.d.ts +6 -2
- package/dist/vector/search-worker.mjs +9 -7
- package/dist/workers/entry.mjs +5 -5
- package/dist/{write-6M3VG4TU.mjs → write-XLIGTXBU.mjs} +21 -20
- package/package.json +11 -7
- package/dist/direct-executor-5KJGVQHM.mjs +0 -22
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { singleFoldTable, appendFoldedCodePoint, compareCodePoints, EARLIER_RELEASE_MIN_M, MIN_M, MAX_M, MAX_FILE_BYTES, detectRuntime, splitWorkerBudget, resolveWorkerCount, CHECKSUM_YIELD_CHUNK_BYTES, resolveWorkerEntry, missingWorkerEntry, DEFAULT_REQUEST_TIMEOUT_MS, toReducedSortValue, resolveRequestThreadCount, defaultSortMode, holdsUnpairedSurrogate, compareComparableValues, readSortField, exceedsCodePoints, toComparableSortValue, SORT_VALUE_MAX_CODE_POINTS, compareComparableKeys, truncateSortString, sortModeOf, isSortMode, SORT_MODES, SHUTDOWN_TIMEOUT_MS, MIN_OVERSAMPLE, MAX_RENUMBERED_SEARCH_ATTEMPTS, compareSortValues, DEFAULT_BACKPRESSURE_LIMIT, CONSECUTIVE_TIMEOUTS_BEFORE_DEATH, codePointCount } from './chunk-QWES44AW.mjs';
|
|
2
|
+
import { DEFAULT_MAX_RERANK_WINDOW, DEFAULT_RERANK_TIMEOUT_MS } from './chunk-JPTQZWJQ.mjs';
|
|
3
|
+
import { ErrorCodes, NarsilError, createNarsilError, ABSOLUTE_WINDOWS_PATH_PATTERN, MODULE_URL_SCHEME_PATTERN, MAX_SWEEP_INTERVAL_MS, MIN_SWEEP_INTERVAL_MS, STATISTICS_BROADCAST_INTERVAL_MS, MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN, MAX_EXPORT_LINE_BYTES, IMPORT_BATCH_DOCUMENTS, MAX_SUGGEST_LIMIT, MAX_INDEX_CONFIGURATION_BYTES, FOREIGN_STATS_TTL_MS, HEAP_PRESSURE_WARNING_FRACTION, MAX_IMPORT_REFUSALS_REPORTED, DEFAULT_SUGGEST_LIMIT, DEFAULT_FUZZY_PREFIX_LENGTH, MAX_CURSOR_LENGTH, MAX_CURSOR_ANCHOR_CODE_POINTS, MAX_SORT_FIELDS, MAX_SORT_FIELD_NAME_LENGTH, RESULT_WINDOW, DEFAULT_LIMIT, DEFAULT_OFFSET, DEFAULT_LINEAR_ALPHA, MIN_LINEAR_ALPHA, MAX_LINEAR_ALPHA, DEFAULT_RANK_CONSTANT, MIN_RANK_CONSTANT, MIN_DOCUMENTS_FOR_SEGMENTS, DEFAULT_PAGE_SIZE, DEFAULT_MAX_PER_GROUP, PREFIX_MAX_EXPANSIONS, HEAP_PRESSURE_REARM_FRACTION, MAX_TOLERANCE, MAX_PREFIX_LENGTH, BATCH_CHUNK_SIZE, MAX_DOC_ID_LENGTH } from './chunk-RELZRJNR.mjs';
|
|
2
4
|
import { Decoder, encode, decode } from '@msgpack/msgpack';
|
|
3
5
|
|
|
4
6
|
// src/analysis/registry.ts
|
|
@@ -2112,6 +2114,9 @@ var NARSIL_CONFIG_KEYS = {
|
|
|
2112
2114
|
workers: true,
|
|
2113
2115
|
embedding: true,
|
|
2114
2116
|
embeddingAdapters: true,
|
|
2117
|
+
rerankAdapters: true,
|
|
2118
|
+
rerankTimeout: true,
|
|
2119
|
+
maxRerankWindow: true,
|
|
2115
2120
|
durability: true,
|
|
2116
2121
|
analysis: true,
|
|
2117
2122
|
lifecycle: true,
|
|
@@ -9554,12 +9559,38 @@ var FNV_OFFSET_BASIS = 2166136261;
|
|
|
9554
9559
|
var FNV_PRIME = 16777619;
|
|
9555
9560
|
var encoder = new TextEncoder();
|
|
9556
9561
|
function fnv1aBytes(bytes) {
|
|
9557
|
-
|
|
9558
|
-
|
|
9559
|
-
|
|
9560
|
-
|
|
9562
|
+
return fnv1aContinue(FNV_OFFSET_BASIS, bytes, bytes.length) >>> 0;
|
|
9563
|
+
}
|
|
9564
|
+
function fnv1aContinue(start, bytes, length) {
|
|
9565
|
+
let hash = start;
|
|
9566
|
+
for (let i = 0; i < length; i++) {
|
|
9567
|
+
hash = Math.imul(hash ^ bytes[i], FNV_PRIME);
|
|
9568
|
+
}
|
|
9569
|
+
return hash;
|
|
9570
|
+
}
|
|
9571
|
+
var scratchNumber = new Float64Array(1);
|
|
9572
|
+
var scratchBytes = new Uint8Array(scratchNumber.buffer);
|
|
9573
|
+
var HOST_IS_LITTLE_ENDIAN = new Uint8Array(new Uint16Array([1]).buffer)[0] === 1;
|
|
9574
|
+
function fnv1aContinueTaggedNumbers(start, tag, numbers) {
|
|
9575
|
+
let hash = start;
|
|
9576
|
+
const b = scratchBytes;
|
|
9577
|
+
for (let i = 0; i < numbers.length; i++) {
|
|
9578
|
+
scratchNumber[0] = Math.fround(numbers[i]);
|
|
9579
|
+
hash = Math.imul(hash ^ tag, FNV_PRIME);
|
|
9580
|
+
if (HOST_IS_LITTLE_ENDIAN) {
|
|
9581
|
+
hash = Math.imul(hash ^ b[7], FNV_PRIME);
|
|
9582
|
+
hash = Math.imul(hash ^ b[6], FNV_PRIME);
|
|
9583
|
+
hash = Math.imul(hash ^ b[5], FNV_PRIME);
|
|
9584
|
+
hash = Math.imul(hash ^ b[4], FNV_PRIME);
|
|
9585
|
+
hash = Math.imul(hash ^ b[3], FNV_PRIME);
|
|
9586
|
+
hash = Math.imul(hash ^ b[2], FNV_PRIME);
|
|
9587
|
+
hash = Math.imul(hash ^ b[1], FNV_PRIME);
|
|
9588
|
+
hash = Math.imul(hash ^ b[0], FNV_PRIME);
|
|
9589
|
+
} else {
|
|
9590
|
+
for (let at = 0; at < 8; at++) hash = Math.imul(hash ^ b[at], FNV_PRIME);
|
|
9591
|
+
}
|
|
9561
9592
|
}
|
|
9562
|
-
return hash
|
|
9593
|
+
return hash;
|
|
9563
9594
|
}
|
|
9564
9595
|
function fnv1a(input) {
|
|
9565
9596
|
return fnv1aBytes(encoder.encode(input));
|
|
@@ -9661,6 +9692,24 @@ function createPluginRegistry() {
|
|
|
9661
9692
|
};
|
|
9662
9693
|
}
|
|
9663
9694
|
|
|
9695
|
+
// src/rerank/registry.ts
|
|
9696
|
+
function validateRerankAdapter(name, adapter) {
|
|
9697
|
+
if (typeof name !== "string" || name.trim().length === 0) {
|
|
9698
|
+
throw new NarsilError(ErrorCodes.RERANK_CONFIG_INVALID, "A rerank adapter needs a non-empty string name");
|
|
9699
|
+
}
|
|
9700
|
+
const rerank = typeof adapter === "object" && adapter !== null ? adapter.rerank : void 0;
|
|
9701
|
+
if (typeof rerank !== "function") {
|
|
9702
|
+
throw new NarsilError(ErrorCodes.RERANK_CONFIG_INVALID, `Rerank adapter "${name}" must provide a rerank function`, {
|
|
9703
|
+
adapter: name
|
|
9704
|
+
});
|
|
9705
|
+
}
|
|
9706
|
+
}
|
|
9707
|
+
function registerEngineRerankAdapter(core, name, adapter) {
|
|
9708
|
+
core.guardShutdown();
|
|
9709
|
+
validateRerankAdapter(name, adapter);
|
|
9710
|
+
core.rerankAdapters.set(name, adapter);
|
|
9711
|
+
}
|
|
9712
|
+
|
|
9664
9713
|
// src/schema/embedding-validator.ts
|
|
9665
9714
|
var VECTOR_DIMENSION_PATTERN = /^vector\[(\d+)]$/;
|
|
9666
9715
|
function validateEmbeddingConfig(embeddingConfig, schema, instanceAdapter) {
|
|
@@ -14883,7 +14932,7 @@ function requireLoadedVectorCode() {
|
|
|
14883
14932
|
function loadVectorCode() {
|
|
14884
14933
|
if (loaded !== null) return Promise.resolve(loaded);
|
|
14885
14934
|
if (loading === null) {
|
|
14886
|
-
loading = import('./module-
|
|
14935
|
+
loading = import('./module-PDXYHT75.mjs').then(
|
|
14887
14936
|
(code) => {
|
|
14888
14937
|
loaded = code;
|
|
14889
14938
|
return code;
|
|
@@ -18970,6 +19019,7 @@ async function emitWriteEventAfter(source, indexName, write) {
|
|
|
18970
19019
|
// src/engine/core.ts
|
|
18971
19020
|
async function createEngineCore(config, hooks, capacityScope = "index") {
|
|
18972
19021
|
validateWorkerConfig(config?.workers, config?.lifecycle);
|
|
19022
|
+
const rerankSettings = config?.rerankTimeout === void 0 && config?.maxRerankWindow === void 0 ? { timeoutMs: DEFAULT_RERANK_TIMEOUT_MS, maxWindow: DEFAULT_MAX_RERANK_WINDOW } : (await import('./runtime-NYE5TB6O.mjs')).resolveRerankSettings(config);
|
|
18973
19023
|
const eventHandlers = eventHandlersOf(config?.events);
|
|
18974
19024
|
const vectorWorkerCount = splitWorkerBudget(resolveWorkerCount(config?.workers?.count)).vector;
|
|
18975
19025
|
const vectorCopyPolicy = {
|
|
@@ -18980,7 +19030,7 @@ async function createEngineCore(config, hooks, capacityScope = "index") {
|
|
|
18980
19030
|
if (config?.lifecycle !== void 0 && durabilityTier === null) {
|
|
18981
19031
|
throw new NarsilError(ErrorCodes.CONFIG_INVALID, "Index lifecycle settings require durability");
|
|
18982
19032
|
}
|
|
18983
|
-
const durabilityWiring = durabilityTier === null ? null : await import('./durability-wiring-
|
|
19033
|
+
const durabilityWiring = durabilityTier === null ? null : await import('./durability-wiring-PY3L7DES.mjs');
|
|
18984
19034
|
const filesystemDurability = durabilityTier?.kind === "wal";
|
|
18985
19035
|
const executor = createDirectExecutor({
|
|
18986
19036
|
vectorWorkerCopies: vectorCopyPolicy,
|
|
@@ -18999,6 +19049,11 @@ async function createEngineCore(config, hooks, capacityScope = "index") {
|
|
|
18999
19049
|
embeddingAdapters.set(name, adapter);
|
|
19000
19050
|
}
|
|
19001
19051
|
}
|
|
19052
|
+
const rerankAdapters = /* @__PURE__ */ new Map();
|
|
19053
|
+
for (const [name, adapter] of Object.entries(config?.rerankAdapters ?? {})) {
|
|
19054
|
+
validateRerankAdapter(name, adapter);
|
|
19055
|
+
rerankAdapters.set(name, adapter);
|
|
19056
|
+
}
|
|
19002
19057
|
const shutdownState = { isShutdown: false };
|
|
19003
19058
|
const abortController = new AbortController();
|
|
19004
19059
|
const rebalancingIndexes = /* @__PURE__ */ new Set();
|
|
@@ -19199,6 +19254,8 @@ async function createEngineCore(config, hooks, capacityScope = "index") {
|
|
|
19199
19254
|
idGenerator,
|
|
19200
19255
|
indexRegistry,
|
|
19201
19256
|
embeddingAdapters,
|
|
19257
|
+
rerankAdapters,
|
|
19258
|
+
rerankSettings,
|
|
19202
19259
|
eventHandlers,
|
|
19203
19260
|
shutdownState,
|
|
19204
19261
|
abortController,
|
|
@@ -19265,6 +19322,9 @@ async function shutdownEngine(core) {
|
|
|
19265
19322
|
} catch {
|
|
19266
19323
|
}
|
|
19267
19324
|
}
|
|
19325
|
+
if (core.rerankAdapters.size > 0) {
|
|
19326
|
+
await (await import('./runtime-NYE5TB6O.mjs')).shutdownRerankAdapters(core.rerankAdapters);
|
|
19327
|
+
}
|
|
19268
19328
|
await orchestrator.shutdown();
|
|
19269
19329
|
await executor.shutdown();
|
|
19270
19330
|
eventHandlers.clear();
|
|
@@ -22399,14 +22459,14 @@ function portabilityOperations(core, config, engine) {
|
|
|
22399
22459
|
return {
|
|
22400
22460
|
snapshot(indexName) {
|
|
22401
22461
|
return withOpenIndex(indexName, async () => {
|
|
22402
|
-
const { createSnapshot } = await import('./snapshot-
|
|
22462
|
+
const { createSnapshot } = await import('./snapshot-J57MZK6L.mjs');
|
|
22403
22463
|
return createSnapshot(snapshotDepsOf(indexName));
|
|
22404
22464
|
});
|
|
22405
22465
|
},
|
|
22406
22466
|
async restore(indexName, data) {
|
|
22407
22467
|
core.guardShutdown();
|
|
22408
22468
|
validateIndexName(indexName);
|
|
22409
|
-
const restored = import('./restore-queue-
|
|
22469
|
+
const restored = import('./restore-queue-DVIYJ7RU.mjs').then(
|
|
22410
22470
|
({ queueRestore }) => queueRestore(core, restoreHost, restoresInFlight, indexName, data)
|
|
22411
22471
|
);
|
|
22412
22472
|
await emitWriteEventAfter(core, indexName, restored);
|
|
@@ -22415,8 +22475,8 @@ function portabilityOperations(core, config, engine) {
|
|
|
22415
22475
|
exportDocuments(indexName) {
|
|
22416
22476
|
return withOpenIndex(indexName, async () => {
|
|
22417
22477
|
const [{ checkpointForArchive }, { documentExportStream }] = await Promise.all([
|
|
22418
|
-
import('./snapshot-
|
|
22419
|
-
import('./write-
|
|
22478
|
+
import('./snapshot-J57MZK6L.mjs'),
|
|
22479
|
+
import('./write-L7FAQA47.mjs')
|
|
22420
22480
|
]);
|
|
22421
22481
|
const header = indexConfigurationOf(core.requireIndex(indexName));
|
|
22422
22482
|
return documentExportStream(header, await checkpointForArchive(snapshotDepsOf(indexName)));
|
|
@@ -22441,6 +22501,10 @@ var MAP_TAG = 7;
|
|
|
22441
22501
|
var LENGTH_BYTES = 4;
|
|
22442
22502
|
var LAST_ASCII_UNIT = 127;
|
|
22443
22503
|
var encoder5 = new TextEncoder();
|
|
22504
|
+
function flush2(stream) {
|
|
22505
|
+
stream.hash = fnv1aContinue(stream.hash, stream.bytes, stream.length);
|
|
22506
|
+
stream.length = 0;
|
|
22507
|
+
}
|
|
22444
22508
|
function ensureCapacity(stream, extra) {
|
|
22445
22509
|
if (stream.length + extra <= stream.bytes.length) return;
|
|
22446
22510
|
const grown = new Uint8Array(Math.max(stream.bytes.length * 2, stream.length + extra));
|
|
@@ -22496,23 +22560,11 @@ var NumberList = class {
|
|
|
22496
22560
|
this.members = members;
|
|
22497
22561
|
}
|
|
22498
22562
|
};
|
|
22499
|
-
var NUMBER_MEMBER_BYTES = 9;
|
|
22500
|
-
var LIST_HEADER_BYTES = 5;
|
|
22501
22563
|
function writeNumberList(stream, list) {
|
|
22502
|
-
|
|
22503
|
-
|
|
22504
|
-
|
|
22505
|
-
|
|
22506
|
-
let at = stream.length;
|
|
22507
|
-
bytes[at] = LIST_TAG;
|
|
22508
|
-
view.setUint32(at + 1, count, false);
|
|
22509
|
-
at += LIST_HEADER_BYTES;
|
|
22510
|
-
for (let i = 0; i < count; i++) {
|
|
22511
|
-
bytes[at] = NUMBER_TAG2;
|
|
22512
|
-
view.setFloat64(at + 1, Math.fround(list.members[i]), false);
|
|
22513
|
-
at += NUMBER_MEMBER_BYTES;
|
|
22514
|
-
}
|
|
22515
|
-
stream.length = at;
|
|
22564
|
+
writeByte(stream, LIST_TAG);
|
|
22565
|
+
writeUint32(stream, list.members.length);
|
|
22566
|
+
flush2(stream);
|
|
22567
|
+
stream.hash = fnv1aContinueTaggedNumbers(stream.hash, NUMBER_TAG2, list.members);
|
|
22516
22568
|
}
|
|
22517
22569
|
function writeValue(stream, value) {
|
|
22518
22570
|
if (value instanceof NumberList) {
|
|
@@ -22570,17 +22622,26 @@ function boundVectorOf(vector) {
|
|
|
22570
22622
|
}
|
|
22571
22623
|
return bound;
|
|
22572
22624
|
}
|
|
22625
|
+
function boundRerankOf(rerank) {
|
|
22626
|
+
if (typeof rerank !== "object" || rerank === null || Array.isArray(rerank)) return rerank;
|
|
22627
|
+
const present = {};
|
|
22628
|
+
for (const [key, value] of Object.entries(rerank)) {
|
|
22629
|
+
if (value !== void 0) present[key] = value;
|
|
22630
|
+
}
|
|
22631
|
+
return present;
|
|
22632
|
+
}
|
|
22573
22633
|
var FILTERS_SLOT = 2;
|
|
22574
22634
|
var BOUND_SLOT_COUNT = 16;
|
|
22575
22635
|
function bindingOf(values) {
|
|
22576
|
-
const stream = { bytes: new Uint8Array(256), length: 0 };
|
|
22636
|
+
const stream = { bytes: new Uint8Array(256), length: 0, hash: FNV_OFFSET_BASIS };
|
|
22577
22637
|
for (const value of values) {
|
|
22578
22638
|
writeValue(stream, value);
|
|
22579
22639
|
}
|
|
22580
|
-
|
|
22640
|
+
flush2(stream);
|
|
22641
|
+
return (stream.hash >>> 0).toString(16).padStart(8, "0");
|
|
22581
22642
|
}
|
|
22582
22643
|
function queryBindingOf(params) {
|
|
22583
|
-
|
|
22644
|
+
const values = [
|
|
22584
22645
|
params.term,
|
|
22585
22646
|
params.fields,
|
|
22586
22647
|
params.filters,
|
|
@@ -22597,7 +22658,9 @@ function queryBindingOf(params) {
|
|
|
22597
22658
|
params.hybrid,
|
|
22598
22659
|
boundVectorOf(params.vector),
|
|
22599
22660
|
params.scoring ?? "local"
|
|
22600
|
-
]
|
|
22661
|
+
];
|
|
22662
|
+
if (params.rerank !== void 0) values.push(boundRerankOf(params.rerank));
|
|
22663
|
+
return bindingOf(values);
|
|
22601
22664
|
}
|
|
22602
22665
|
function listBindingOf(filters) {
|
|
22603
22666
|
const values = new Array(BOUND_SLOT_COUNT).fill(void 0);
|
|
@@ -23262,81 +23325,6 @@ function applyHighlights(hits, params, language, analysis, schema, readStoredDoc
|
|
|
23262
23325
|
}
|
|
23263
23326
|
}
|
|
23264
23327
|
|
|
23265
|
-
// src/engine/query/sorted.ts
|
|
23266
|
-
function sortsWithoutScores(params) {
|
|
23267
|
-
return params.includeScores !== true && params.includeScoreComponents !== true && params.minScore === void 0 && params.group === void 0 && params.pinned === void 0 && (params.termMatch === void 0 || params.termMatch === "any");
|
|
23268
|
-
}
|
|
23269
|
-
function executeSortedQueryPage(params, context, limit, offset, sortSignature) {
|
|
23270
|
-
const { manager, language, config } = context;
|
|
23271
|
-
const schema = config.schema;
|
|
23272
|
-
let anchorKey = null;
|
|
23273
|
-
let anchorId = null;
|
|
23274
|
-
if (params.searchAfter !== void 0) {
|
|
23275
|
-
const decoded = decodePageCursor(params.searchAfter);
|
|
23276
|
-
requireMatchingCursor(decoded, params.searchAfter, sortSignature, true, context.cursorBinding);
|
|
23277
|
-
anchorKey = decoded.sortKey;
|
|
23278
|
-
anchorId = decoded.anchor;
|
|
23279
|
-
}
|
|
23280
|
-
const normalized = normalizeSort(params.sort);
|
|
23281
|
-
const fields = normalized.map((entry) => entry.field);
|
|
23282
|
-
const directions = normalized.map((entry) => entry.direction);
|
|
23283
|
-
const flatSchema = flattenSchema(schema);
|
|
23284
|
-
const fieldTypes = fields.map((field) => flatSchema[field]);
|
|
23285
|
-
const modes = sortModesOf(normalized);
|
|
23286
|
-
const options = searchOptionsFor(manager, context.patternWork);
|
|
23287
|
-
const partitions = partitionsFor(manager, context.partitionIds);
|
|
23288
|
-
const partitionLimit = offset + limit + 1;
|
|
23289
|
-
const merged = [];
|
|
23290
|
-
const partitionFacets = [];
|
|
23291
|
-
const partitionFacetConfig = params.facets !== void 0 && partitions.length > 1 ? everyValueFacetConfig(params.facets) : params.facets;
|
|
23292
|
-
let count = 0;
|
|
23293
|
-
for (const partition of partitions) {
|
|
23294
|
-
const matches = fulltextMatches(partition, params, language, schema, options);
|
|
23295
|
-
if (partitionFacetConfig !== void 0) {
|
|
23296
|
-
partitionFacets.push(
|
|
23297
|
-
partition.computeFacets(
|
|
23298
|
-
matches === null ? /* @__PURE__ */ new Set() : { ordinalBitset: matches.ordinalBitset() },
|
|
23299
|
-
partitionFacetConfig,
|
|
23300
|
-
schema
|
|
23301
|
-
)
|
|
23302
|
-
);
|
|
23303
|
-
}
|
|
23304
|
-
if (matches === null || matches.count === 0) continue;
|
|
23305
|
-
count += matches.count;
|
|
23306
|
-
const page2 = partition.sortedPage({
|
|
23307
|
-
fields,
|
|
23308
|
-
directions,
|
|
23309
|
-
fieldTypes,
|
|
23310
|
-
modes,
|
|
23311
|
-
limit: partitionLimit,
|
|
23312
|
-
anchorKey,
|
|
23313
|
-
anchorId,
|
|
23314
|
-
matches
|
|
23315
|
-
});
|
|
23316
|
-
for (const entry of page2) merged.push(entry);
|
|
23317
|
-
}
|
|
23318
|
-
merged.sort((a, b) => compareComparableKeys(a.key, b.key, directions) || compareCodePoints(a.id, b.id));
|
|
23319
|
-
const hasMore = merged.length > offset + limit;
|
|
23320
|
-
const page = merged.slice(offset, offset + limit);
|
|
23321
|
-
const last = page[page.length - 1];
|
|
23322
|
-
let cursor;
|
|
23323
|
-
if (hasMore && last !== void 0) {
|
|
23324
|
-
cursor = encodePageCursor({
|
|
23325
|
-
anchor: last.id,
|
|
23326
|
-
score: null,
|
|
23327
|
-
sortKey: last.key,
|
|
23328
|
-
sortSignature,
|
|
23329
|
-
binding: context.cursorBinding
|
|
23330
|
-
});
|
|
23331
|
-
}
|
|
23332
|
-
return {
|
|
23333
|
-
hits: page.map((entry) => ({ id: entry.id, document: void 0 })),
|
|
23334
|
-
count,
|
|
23335
|
-
cursor,
|
|
23336
|
-
facets: params.facets !== void 0 && partitionFacets.length > 0 ? mergeFacets(partitionFacets, params.facets) : void 0
|
|
23337
|
-
};
|
|
23338
|
-
}
|
|
23339
|
-
|
|
23340
23328
|
// src/search/fusion.ts
|
|
23341
23329
|
function rankConstantOf(k) {
|
|
23342
23330
|
if (k === void 0 || k === null) return DEFAULT_RANK_CONSTANT;
|
|
@@ -23369,30 +23357,27 @@ function resolveHybridFusion(hybrid) {
|
|
|
23369
23357
|
}
|
|
23370
23358
|
function reciprocalRankFusion(lists, options) {
|
|
23371
23359
|
const k = options.k;
|
|
23372
|
-
const
|
|
23373
|
-
const
|
|
23360
|
+
const positions = /* @__PURE__ */ new Map();
|
|
23361
|
+
const result = [];
|
|
23374
23362
|
for (const list of lists) {
|
|
23375
23363
|
for (let rank = 0; rank < list.length; rank++) {
|
|
23376
23364
|
const doc = list[rank];
|
|
23377
23365
|
const rrfContribution = 1 / (k + rank + 1);
|
|
23378
|
-
|
|
23379
|
-
if (
|
|
23380
|
-
|
|
23366
|
+
const position = positions.get(doc.docId);
|
|
23367
|
+
if (position === void 0) {
|
|
23368
|
+
positions.set(doc.docId, result.length);
|
|
23369
|
+
result.push({
|
|
23370
|
+
docId: doc.docId,
|
|
23371
|
+
score: rrfContribution,
|
|
23372
|
+
termFrequencies: doc.termFrequencies,
|
|
23373
|
+
fieldLengths: doc.fieldLengths,
|
|
23374
|
+
idf: doc.idf
|
|
23375
|
+
});
|
|
23376
|
+
} else {
|
|
23377
|
+
result[position].score += rrfContribution;
|
|
23381
23378
|
}
|
|
23382
23379
|
}
|
|
23383
23380
|
}
|
|
23384
|
-
const result = [];
|
|
23385
|
-
for (const [docId, score] of scores) {
|
|
23386
|
-
const original = docData.get(docId);
|
|
23387
|
-
if (!original) continue;
|
|
23388
|
-
result.push({
|
|
23389
|
-
docId,
|
|
23390
|
-
score,
|
|
23391
|
-
termFrequencies: original.termFrequencies,
|
|
23392
|
-
fieldLengths: original.fieldLengths,
|
|
23393
|
-
idf: original.idf
|
|
23394
|
-
});
|
|
23395
|
-
}
|
|
23396
23381
|
result.sort((a, b) => b.score - a.score || compareCodePoints(a.docId, b.docId));
|
|
23397
23382
|
return result;
|
|
23398
23383
|
}
|
|
@@ -23519,12 +23504,13 @@ function filteredSearchOf(params, context) {
|
|
|
23519
23504
|
const collectAgain = () => collectFilterSubsets(manager, filters, config.schema, partitionIds, patternWork);
|
|
23520
23505
|
return { first: collectAgain(), collectAgain };
|
|
23521
23506
|
}
|
|
23522
|
-
function searchField(vecIndex, vectorConfig, queryVector, k, context, filtered) {
|
|
23507
|
+
function searchField(vecIndex, vectorConfig, queryVector, k, context, filtered, rescoreWindow) {
|
|
23523
23508
|
const options = {
|
|
23524
23509
|
metric: vectorConfig.metric ?? "cosine",
|
|
23525
23510
|
minSimilarity: vectorConfig.similarity ?? -Infinity,
|
|
23526
23511
|
efSearch: vectorConfig.efSearch,
|
|
23527
|
-
oversample: oversampleOf(vectorConfig)
|
|
23512
|
+
oversample: oversampleOf(vectorConfig),
|
|
23513
|
+
...rescoreWindow !== void 0 ? { rescoreWindow } : {}
|
|
23528
23514
|
};
|
|
23529
23515
|
if (filtered !== void 0) {
|
|
23530
23516
|
return searchCurrentSubsets(
|
|
@@ -23556,7 +23542,7 @@ async function executeVectorSearch(params, context, limit, offset, cursorDepth =
|
|
|
23556
23542
|
}
|
|
23557
23543
|
const queryVec = new Float32Array(vectorConfig.value);
|
|
23558
23544
|
const k = vectorFetchDepth(limit, offset, cursorDepth);
|
|
23559
|
-
const outcome = await searchField(vecIndex, vectorConfig, queryVec, k, context, filtered);
|
|
23545
|
+
const outcome = await searchField(vecIndex, vectorConfig, queryVec, k, context, filtered, context.rescoreWindow);
|
|
23560
23546
|
const scored = vectorResultsToScored(outcome.results);
|
|
23561
23547
|
return { scored, totalMatched: outcome.matched, matchedExact: outcome.matchedExact };
|
|
23562
23548
|
}
|
|
@@ -23582,10 +23568,10 @@ async function textLeg(textOnlyParams, context) {
|
|
|
23582
23568
|
searchOptionsFor(manager, context.patternWork)
|
|
23583
23569
|
);
|
|
23584
23570
|
}
|
|
23585
|
-
async function vectorLeg(vectorConfig, queryVector, context, filtered, k) {
|
|
23571
|
+
async function vectorLeg(vectorConfig, queryVector, context, filtered, k, rescoreWindow) {
|
|
23586
23572
|
const vecIndex = resolveVectorIndex(context, vectorConfig.field);
|
|
23587
23573
|
if (!vecIndex) return { scored: [], holdsEveryMatch: true };
|
|
23588
|
-
const outcome = await searchField(vecIndex, vectorConfig, queryVector, k, context, filtered);
|
|
23574
|
+
const outcome = await searchField(vecIndex, vectorConfig, queryVector, k, context, filtered, rescoreWindow);
|
|
23589
23575
|
return {
|
|
23590
23576
|
scored: vectorResultsToScored(outcome.results),
|
|
23591
23577
|
holdsEveryMatch: outcome.matchedExact && outcome.results.length === outcome.matched
|
|
@@ -23630,6 +23616,107 @@ async function executeHybridSearch(params, context, limit, offset, cursorDepth =
|
|
|
23630
23616
|
};
|
|
23631
23617
|
}
|
|
23632
23618
|
|
|
23619
|
+
// src/engine/query/runtime-host.ts
|
|
23620
|
+
var runtimeHost = {
|
|
23621
|
+
now,
|
|
23622
|
+
compareCodePoints,
|
|
23623
|
+
clampRowCount,
|
|
23624
|
+
resolveProjection,
|
|
23625
|
+
projectionKeepsField,
|
|
23626
|
+
decodePageCursor,
|
|
23627
|
+
encodePageCursor,
|
|
23628
|
+
requireMatchingCursor,
|
|
23629
|
+
dedupePinnedEntries,
|
|
23630
|
+
placePinned,
|
|
23631
|
+
normalizeSort,
|
|
23632
|
+
flattenSchema,
|
|
23633
|
+
parsedTypeOf,
|
|
23634
|
+
isStringValuedBase,
|
|
23635
|
+
applyHighlights,
|
|
23636
|
+
textLeg,
|
|
23637
|
+
vectorLeg,
|
|
23638
|
+
filteredSearchOf,
|
|
23639
|
+
filterSubsetsMatchNothing,
|
|
23640
|
+
reciprocalRankFusion,
|
|
23641
|
+
linearCombination,
|
|
23642
|
+
resolveHybridFusion
|
|
23643
|
+
};
|
|
23644
|
+
|
|
23645
|
+
// src/engine/query/sorted.ts
|
|
23646
|
+
function sortsWithoutScores(params) {
|
|
23647
|
+
return params.includeScores !== true && params.includeScoreComponents !== true && params.minScore === void 0 && params.group === void 0 && params.pinned === void 0 && (params.termMatch === void 0 || params.termMatch === "any");
|
|
23648
|
+
}
|
|
23649
|
+
function executeSortedQueryPage(params, context, limit, offset, sortSignature) {
|
|
23650
|
+
const { manager, language, config } = context;
|
|
23651
|
+
const schema = config.schema;
|
|
23652
|
+
let anchorKey = null;
|
|
23653
|
+
let anchorId = null;
|
|
23654
|
+
if (params.searchAfter !== void 0) {
|
|
23655
|
+
const decoded = decodePageCursor(params.searchAfter);
|
|
23656
|
+
requireMatchingCursor(decoded, params.searchAfter, sortSignature, true, context.cursorBinding);
|
|
23657
|
+
anchorKey = decoded.sortKey;
|
|
23658
|
+
anchorId = decoded.anchor;
|
|
23659
|
+
}
|
|
23660
|
+
const normalized = normalizeSort(params.sort);
|
|
23661
|
+
const fields = normalized.map((entry) => entry.field);
|
|
23662
|
+
const directions = normalized.map((entry) => entry.direction);
|
|
23663
|
+
const flatSchema = flattenSchema(schema);
|
|
23664
|
+
const fieldTypes = fields.map((field) => flatSchema[field]);
|
|
23665
|
+
const modes = sortModesOf(normalized);
|
|
23666
|
+
const options = searchOptionsFor(manager, context.patternWork);
|
|
23667
|
+
const partitions = partitionsFor(manager, context.partitionIds);
|
|
23668
|
+
const partitionLimit = offset + limit + 1;
|
|
23669
|
+
const merged = [];
|
|
23670
|
+
const partitionFacets = [];
|
|
23671
|
+
const partitionFacetConfig = params.facets !== void 0 && partitions.length > 1 ? everyValueFacetConfig(params.facets) : params.facets;
|
|
23672
|
+
let count = 0;
|
|
23673
|
+
for (const partition of partitions) {
|
|
23674
|
+
const matches = fulltextMatches(partition, params, language, schema, options);
|
|
23675
|
+
if (partitionFacetConfig !== void 0) {
|
|
23676
|
+
partitionFacets.push(
|
|
23677
|
+
partition.computeFacets(
|
|
23678
|
+
matches === null ? /* @__PURE__ */ new Set() : { ordinalBitset: matches.ordinalBitset() },
|
|
23679
|
+
partitionFacetConfig,
|
|
23680
|
+
schema
|
|
23681
|
+
)
|
|
23682
|
+
);
|
|
23683
|
+
}
|
|
23684
|
+
if (matches === null || matches.count === 0) continue;
|
|
23685
|
+
count += matches.count;
|
|
23686
|
+
const page2 = partition.sortedPage({
|
|
23687
|
+
fields,
|
|
23688
|
+
directions,
|
|
23689
|
+
fieldTypes,
|
|
23690
|
+
modes,
|
|
23691
|
+
limit: partitionLimit,
|
|
23692
|
+
anchorKey,
|
|
23693
|
+
anchorId,
|
|
23694
|
+
matches
|
|
23695
|
+
});
|
|
23696
|
+
for (const entry of page2) merged.push(entry);
|
|
23697
|
+
}
|
|
23698
|
+
merged.sort((a, b) => compareComparableKeys(a.key, b.key, directions) || compareCodePoints(a.id, b.id));
|
|
23699
|
+
const hasMore = merged.length > offset + limit;
|
|
23700
|
+
const page = merged.slice(offset, offset + limit);
|
|
23701
|
+
const last = page[page.length - 1];
|
|
23702
|
+
let cursor;
|
|
23703
|
+
if (hasMore && last !== void 0) {
|
|
23704
|
+
cursor = encodePageCursor({
|
|
23705
|
+
anchor: last.id,
|
|
23706
|
+
score: null,
|
|
23707
|
+
sortKey: last.key,
|
|
23708
|
+
sortSignature,
|
|
23709
|
+
binding: context.cursorBinding
|
|
23710
|
+
});
|
|
23711
|
+
}
|
|
23712
|
+
return {
|
|
23713
|
+
hits: page.map((entry) => ({ id: entry.id, document: void 0 })),
|
|
23714
|
+
count,
|
|
23715
|
+
cursor,
|
|
23716
|
+
facets: params.facets !== void 0 && partitionFacets.length > 0 ? mergeFacets(partitionFacets, params.facets) : void 0
|
|
23717
|
+
};
|
|
23718
|
+
}
|
|
23719
|
+
|
|
23633
23720
|
// src/engine/query/index.ts
|
|
23634
23721
|
function requireCursorDepth(cursor, signature, binding) {
|
|
23635
23722
|
if (cursor === void 0) return 0;
|
|
@@ -23637,7 +23724,19 @@ function requireCursorDepth(cursor, signature, binding) {
|
|
|
23637
23724
|
requireMatchingCursor(decoded, cursor, signature, true, binding);
|
|
23638
23725
|
return decoded.depth ?? 0;
|
|
23639
23726
|
}
|
|
23640
|
-
|
|
23727
|
+
function hybridSearchOf(params, context, limit, offset, cursorDepth) {
|
|
23728
|
+
if ((params.hybrid?.depth ?? null) === null) return executeHybridSearch(params, context, limit, offset, cursorDepth);
|
|
23729
|
+
return import('./runtime-NYE5TB6O.mjs').then(
|
|
23730
|
+
(runtime) => runtime.searchFixedDepthHybrid(params, context, { cursorDepth: cursorDepth ?? 0, offset, limit }, runtimeHost)
|
|
23731
|
+
);
|
|
23732
|
+
}
|
|
23733
|
+
function executeQuery(request, callerContext) {
|
|
23734
|
+
if (request.rerank === void 0) return runQuery(request, callerContext);
|
|
23735
|
+
return import('./runtime-NYE5TB6O.mjs').then(
|
|
23736
|
+
(runtime) => runtime.executeRerankedQuery(request, callerContext, executeQuery, runtimeHost)
|
|
23737
|
+
);
|
|
23738
|
+
}
|
|
23739
|
+
async function runQuery(request, callerContext) {
|
|
23641
23740
|
const context = withPatternWork(callerContext);
|
|
23642
23741
|
const { manager, language, config, workerSearch, indexName } = context;
|
|
23643
23742
|
const startTime = now();
|
|
@@ -23682,7 +23781,7 @@ async function executeQuery(request, callerContext) {
|
|
|
23682
23781
|
fanOutResult = await executeVectorSearch(params, context, limit, offset, depth);
|
|
23683
23782
|
} else if (isHybridMode && hasGlobalVectorIndex) {
|
|
23684
23783
|
const depth = requireCursorDepth(params.searchAfter, sortSignature, context.cursorBinding);
|
|
23685
|
-
fanOutResult = await
|
|
23784
|
+
fanOutResult = await hybridSearchOf(params, context, limit, offset, depth);
|
|
23686
23785
|
} else {
|
|
23687
23786
|
const scoring = scoringConfigFor(params, context);
|
|
23688
23787
|
const workerResult = workerSearch ? await workerSearch(
|
|
@@ -23768,7 +23867,7 @@ async function executeQuery(request, callerContext) {
|
|
|
23768
23867
|
};
|
|
23769
23868
|
}
|
|
23770
23869
|
const pinnedIds = params.pinned !== void 0 && params.searchAfter === void 0 ? new Set(params.pinned.map((entry) => entry.docId)) : void 0;
|
|
23771
|
-
const paged = applyPagination(
|
|
23870
|
+
const paged = (fanOutResult.paginate ?? applyPagination)(
|
|
23772
23871
|
hits,
|
|
23773
23872
|
limit,
|
|
23774
23873
|
offset,
|
|
@@ -23846,7 +23945,7 @@ async function executePreflight(request, callerContext) {
|
|
|
23846
23945
|
totalMatched = result.totalMatched;
|
|
23847
23946
|
countExact = result.matchedExact !== false;
|
|
23848
23947
|
} else if (isHybridMode && hasGlobalVectorIndex) {
|
|
23849
|
-
const result = await
|
|
23948
|
+
const result = await hybridSearchOf(params, context, preflightLimit, preflightOffset);
|
|
23850
23949
|
totalMatched = result.totalMatched;
|
|
23851
23950
|
countExact = result.matchedExact !== false;
|
|
23852
23951
|
} else if (countsWithoutScores(params)) {
|
|
@@ -24014,8 +24113,9 @@ async function runEngineQuery(core, indexName, params, options) {
|
|
|
24014
24113
|
const manager = core.requireManager(indexName);
|
|
24015
24114
|
const scoped = scopedParams(params, options);
|
|
24016
24115
|
await core.pluginRegistry.runHook("beforeSearch", { indexName, params: scoped });
|
|
24116
|
+
const rerank = scoped.rerank === void 0 ? void 0 : await import('./runtime-NYE5TB6O.mjs');
|
|
24017
24117
|
const resolvedParams = await resolveVectorText(
|
|
24018
|
-
scoped,
|
|
24118
|
+
rerank === void 0 ? scoped : rerank.withRerankQueryText(scoped),
|
|
24019
24119
|
entry.embeddingAdapter,
|
|
24020
24120
|
core.abortController.signal,
|
|
24021
24121
|
entry.embeddingAdapterName
|
|
@@ -24029,8 +24129,10 @@ async function runEngineQuery(core, indexName, params, options) {
|
|
|
24029
24129
|
indexName,
|
|
24030
24130
|
broadcastStats: broadcastStatsFor(core, options),
|
|
24031
24131
|
partitionIds: options?.partitionIds,
|
|
24132
|
+
rescoreWindow: options?.rescoreWindow,
|
|
24032
24133
|
cursorBinding: queryBindingOf(params),
|
|
24033
|
-
patternWorkCap: core.patternWorkCap
|
|
24134
|
+
patternWorkCap: core.patternWorkCap,
|
|
24135
|
+
rerank: rerank?.rerankRunnerFor(core)
|
|
24034
24136
|
};
|
|
24035
24137
|
const { result, analysisStale } = await readUnderOneAnalysis(
|
|
24036
24138
|
core,
|
|
@@ -24184,6 +24286,9 @@ function createNarsilFromCore(core, config) {
|
|
|
24184
24286
|
registerEmbeddingAdapter(name, adapter) {
|
|
24185
24287
|
registerEngineEmbeddingAdapter(core, name, adapter);
|
|
24186
24288
|
},
|
|
24289
|
+
registerRerankAdapter(name, adapter) {
|
|
24290
|
+
registerEngineRerankAdapter(core, name, adapter);
|
|
24291
|
+
},
|
|
24187
24292
|
dropIndex(name) {
|
|
24188
24293
|
return emitWriteEventAfter(core, name, dropEngineIndex(core, name));
|
|
24189
24294
|
},
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { KEYWORD_SEGMENT_ENVELOPE_VERSION, decodeKeywordSegment, restoreVectorFields, KEYWORD_SEGMENT_PAYLOAD_VERSION, littleEndianBytes } from './chunk-
|
|
2
|
-
import { VERSION, rulesOfStoredSynonyms, flattenSchema, packChecksummedEnvelope, openChecksummedEnvelope, requireValidFieldTypes, isCompositePartition, crc32, reconstructSchemaFromMetadata, extractVectorFieldsFromSchema, readHeader, HEADER_SIZE, engineVersionParts, writeHeader, partialFieldsOf, getLanguage, decodeEveryStoredDocument, createSharedFrozenSegment, shareSegmentArrays, VECTOR_PATTERN, isQuantizationMode, isStorageMode, survivorDocumentsOf, partitionStateOf, freezeSegmentShared, createFrozenSegment, createPartitionManager, createPartitionRouter, buildSegmentPayload, resolvePartitionInsertOptions, fnv1a, selectionKeeps, decodeMapWithoutFields, prepareDocumentVectors, messagePackUpperBoundBytes, segmentArraysOf, mergeSegmentContents, resolveIndexAnalysis } from './chunk-
|
|
3
|
-
import { decodeVectorGraphPartPayload, assembleGraphParts, decodeVectorFilePayload, countDead, VECTOR_FILE_MAX_VECTORS, deadBytesFor } from './chunk-
|
|
4
|
-
import { compareCodePoints,
|
|
1
|
+
import { KEYWORD_SEGMENT_ENVELOPE_VERSION, decodeKeywordSegment, restoreVectorFields, KEYWORD_SEGMENT_PAYLOAD_VERSION, littleEndianBytes } from './chunk-CN4I4FZU.mjs';
|
|
2
|
+
import { VERSION, rulesOfStoredSynonyms, flattenSchema, packChecksummedEnvelope, openChecksummedEnvelope, requireValidFieldTypes, isCompositePartition, crc32, reconstructSchemaFromMetadata, extractVectorFieldsFromSchema, readHeader, HEADER_SIZE, engineVersionParts, writeHeader, partialFieldsOf, getLanguage, decodeEveryStoredDocument, createSharedFrozenSegment, shareSegmentArrays, VECTOR_PATTERN, isQuantizationMode, isStorageMode, survivorDocumentsOf, partitionStateOf, freezeSegmentShared, createFrozenSegment, createPartitionManager, createPartitionRouter, buildSegmentPayload, resolvePartitionInsertOptions, fnv1a, selectionKeeps, decodeMapWithoutFields, prepareDocumentVectors, messagePackUpperBoundBytes, segmentArraysOf, mergeSegmentContents, resolveIndexAnalysis } from './chunk-NAFT3K6X.mjs';
|
|
3
|
+
import { decodeVectorGraphPartPayload, assembleGraphParts, decodeVectorFilePayload, countDead, VECTOR_FILE_MAX_VECTORS, deadBytesFor } from './chunk-LD55ZGU3.mjs';
|
|
4
|
+
import { compareCodePoints, MAX_FILE_BYTES, VALID_HNSW_METRICS } from './chunk-QWES44AW.mjs';
|
|
5
|
+
import { NarsilError, ErrorCodes } from './chunk-RELZRJNR.mjs';
|
|
5
6
|
import { decode, encode } from '@msgpack/msgpack';
|
|
6
7
|
|
|
7
8
|
// src/engine/durability-metadata.ts
|