@delali/narsil 0.3.1-next.69 → 0.3.1-next.70
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/{capabilities-B1wz2Zl0.d.ts → capabilities-Dt-7B4Wz.d.ts} +2 -2
- package/dist/{chunk-DD5X23E6.mjs → chunk-2STVUTNA.mjs} +1 -1
- package/dist/chunk-3JGWULDF.mjs +256 -0
- package/dist/{chunk-6TGZG2TV.mjs → chunk-653BNMAF.mjs} +190 -58
- package/dist/{chunk-YA52AC2V.mjs → chunk-FVLQ63B7.mjs} +203 -9
- package/dist/{chunk-5JLSTECC.mjs → chunk-GIVAGD3Q.mjs} +1 -1
- package/dist/{chunk-AV4IJKD2.mjs → chunk-HWQLTLNG.mjs} +18 -1
- package/dist/{chunk-4VU5TWCR.mjs → chunk-LMO5TJUS.mjs} +40 -35
- package/dist/{chunk-BEWOA4VV.mjs → chunk-M76V3OGJ.mjs} +508 -401
- package/dist/{chunk-YMZCMH5M.mjs → chunk-OI42GWLR.mjs} +17 -1
- package/dist/{chunk-2BDG2IWP.mjs → chunk-P4DSQ6M4.mjs} +16 -6
- package/dist/{chunk-6IT3MH5M.mjs → chunk-VNMTB3KC.mjs} +130 -216
- package/dist/{chunk-THYRHHO2.mjs → chunk-YJDQ7NLA.mjs} +1 -1
- package/dist/{client-xVrOCYTW.d.ts → client-COek5GXK.d.ts} +3 -3
- package/dist/client.d.ts +8 -8
- package/dist/{config-CEeSV_Xo.d.ts → config-Dfanyqqt.d.ts} +2 -2
- package/dist/{config-CSvCVtB7.d.ts → config-rBpbgTw8.d.ts} +2 -2
- package/dist/direct-executor-GYJEKNV5.mjs +12 -0
- package/dist/distribution/coordinator/etcd.d.ts +2 -2
- package/dist/distribution/coordinator/etcd.mjs +1 -1
- package/dist/distribution/coordinator/in-memory.d.ts +2 -2
- package/dist/distribution/coordinator/in-memory.mjs +1 -1
- package/dist/distribution.d.ts +8 -8
- package/dist/distribution.mjs +109 -69
- package/dist/{engine-77ErLy8P.d.ts → engine-CXKfmK7I.d.ts} +12 -5
- package/dist/index.browser.mjs +1132 -740
- package/dist/index.d.ts +7 -7
- package/dist/index.mjs +10 -10
- package/dist/invalidation/filesystem.mjs +1 -1
- package/dist/{memory-CKF-9WLP.d.ts → memory-C7UMCMH3.d.ts} +35 -17
- package/dist/persistence/durability/checkpoint-worker.d.ts +2 -1
- package/dist/persistence/durability/checkpoint-worker.mjs +10 -10
- package/dist/react.d.ts +6 -6
- package/dist/{schema-d5Afu03A.d.ts → schema-Bgzr4g7b.d.ts} +62 -10
- package/dist/server.d.ts +10 -10
- package/dist/server.mjs +11 -7
- package/dist/{tasks-BEiNxDRs.d.ts → tasks-BZt_zes6.d.ts} +3 -1
- package/dist/{thread-FLP45EUD.mjs → thread-JEVAYETR.mjs} +6 -6
- package/dist/{types-DAK7mnUZ.d.ts → types-gOUqhs2F.d.ts} +1 -1
- package/dist/vector/search-worker.d.ts +1 -1
- package/dist/vector/search-worker.mjs +2 -2
- package/dist/workers/entry.mjs +3 -3
- package/package.json +7 -7
- package/dist/chunk-VTPLKNWI.mjs +0 -135
- package/dist/direct-executor-3ZYXSGFX.mjs +0 -12
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
// src/core/ordering/code-points.ts
|
|
2
|
+
function exceedsCodePoints(value, maximum) {
|
|
3
|
+
if (value.length <= maximum) return false;
|
|
4
|
+
let counted = 0;
|
|
5
|
+
let i = 0;
|
|
6
|
+
while (i < value.length) {
|
|
7
|
+
const unit = value.charCodeAt(i);
|
|
8
|
+
if (unit >= 55296 && unit < 56320 && i + 1 < value.length) {
|
|
9
|
+
const low = value.charCodeAt(i + 1);
|
|
10
|
+
if (low >= 56320 && low < 57344) i++;
|
|
11
|
+
}
|
|
12
|
+
i++;
|
|
13
|
+
counted++;
|
|
14
|
+
if (counted > maximum) return true;
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
2
18
|
function adjustUtf16Unit(unit) {
|
|
3
19
|
if (unit < 55296) return unit;
|
|
4
20
|
if (unit < 57344) return unit + 8192;
|
|
@@ -228,4 +244,4 @@ function compareSortValues(aValues, bValues, directions) {
|
|
|
228
244
|
return 0;
|
|
229
245
|
}
|
|
230
246
|
|
|
231
|
-
export { SORT_MODES, SORT_VALUE_MAX_CODE_POINTS, compareCodePoints, compareComparableKeys, compareComparableValues, compareSortValues, defaultSortMode, isSortMode, readSortField, sortModeOf, toComparableSortValue, toReducedSortValue };
|
|
247
|
+
export { SORT_MODES, SORT_VALUE_MAX_CODE_POINTS, compareCodePoints, compareComparableKeys, compareComparableValues, compareSortValues, defaultSortMode, exceedsCodePoints, isSortMode, readSortField, sortModeOf, toComparableSortValue, toReducedSortValue, truncateSortString };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
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-
|
|
2
|
-
import { clampRowCount, sortSignatureOf, requireSortableFields, decodePageCursor, requireMatchingCursor, resolveProjection, encodePageCursor, requireWithinResultWindow, normalizeSort, fanOutQuery, sortModesOf, applySorting, applyPagination, projectionKeepsField, countsWithoutScores, fanOutMatchCount, tokenize, fnv1aBytes, requireValidFilter, everyValueFacetConfig, fulltextMatches, mergeFacets, pruneStatsToQueryTerms, partitionsIn, undeclaredFieldOnStrictIndex, fuzzyTermMatches } from './chunk-
|
|
3
|
-
import { DEFAULT_MAX_PER_GROUP, flattenSchema, DEFAULT_LINEAR_ALPHA, MIN_LINEAR_ALPHA, MAX_LINEAR_ALPHA, DEFAULT_RANK_CONSTANT, MIN_RANK_CONSTANT, DEFAULT_FUZZY_PREFIX_LENGTH, RESULT_WINDOW,
|
|
1
|
+
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-GIVAGD3Q.mjs';
|
|
2
|
+
import { clampRowCount, sortSignatureOf, requireSortableFields, decodePageCursor, requireMatchingCursor, resolveProjection, encodePageCursor, requireWithinResultWindow, normalizeSort, fanOutQuery, sortModesOf, applySorting, applyPagination, projectionKeepsField, countsWithoutScores, fanOutMatchCount, tokenize, fnv1aBytes, requireValidFilter, everyValueFacetConfig, fulltextMatches, mergeFacets, pruneStatsToQueryTerms, partitionsIn, undeclaredFieldOnStrictIndex, fuzzyTermMatches } from './chunk-LMO5TJUS.mjs';
|
|
3
|
+
import { MIN_PATTERN_VALUE_LIMIT, MAX_PATTERN_VALUE_LIMIT, DEFAULT_MAX_PER_GROUP, flattenSchema, DEFAULT_LINEAR_ALPHA, MIN_LINEAR_ALPHA, MAX_LINEAR_ALPHA, DEFAULT_RANK_CONSTANT, MIN_RANK_CONSTANT, DEFAULT_FUZZY_PREFIX_LENGTH, RESULT_WINDOW, isWordIndexedFieldType, isGeopointOrVectorType, MAX_TOLERANCE, MAX_PREFIX_LENGTH } from './chunk-653BNMAF.mjs';
|
|
4
4
|
import { MIN_OVERSAMPLE } from './chunk-ZJ4CSAB2.mjs';
|
|
5
|
-
import { compareCodePoints, compareComparableKeys } from './chunk-
|
|
5
|
+
import { compareCodePoints, compareComparableKeys } from './chunk-OI42GWLR.mjs';
|
|
6
6
|
import { NarsilError, ErrorCodes } from './chunk-USKFU7J5.mjs';
|
|
7
7
|
|
|
8
8
|
// src/search/cursor-binding.ts
|
|
@@ -167,7 +167,7 @@ function listBindingOf(filters) {
|
|
|
167
167
|
function requireBoostableFields(boost, flatSchema) {
|
|
168
168
|
for (const [field, weight] of Object.entries(boost)) {
|
|
169
169
|
const fieldType = flatSchema[field];
|
|
170
|
-
if (fieldType === void 0 || !
|
|
170
|
+
if (fieldType === void 0 || !isWordIndexedFieldType(fieldType)) {
|
|
171
171
|
throw new NarsilError(
|
|
172
172
|
ErrorCodes.SEARCH_INVALID_FIELD,
|
|
173
173
|
fieldType === void 0 ? `The engine boosts a text field that the schema declares, and the schema declares no field "${field}"` : `The engine boosts a text field alone, and the schema declares field "${field}" as "${fieldType}"`,
|
|
@@ -414,6 +414,16 @@ function validatePartitionConfig(partitions) {
|
|
|
414
414
|
});
|
|
415
415
|
}
|
|
416
416
|
}
|
|
417
|
+
function validatePatternValueLimit(limit) {
|
|
418
|
+
if (limit === void 0) return;
|
|
419
|
+
if (typeof limit !== "number" || !Number.isInteger(limit) || limit < MIN_PATTERN_VALUE_LIMIT || limit > MAX_PATTERN_VALUE_LIMIT) {
|
|
420
|
+
throw new NarsilError(
|
|
421
|
+
ErrorCodes.CONFIG_INVALID,
|
|
422
|
+
`patternValueLimit must be a whole number of code points from ${MIN_PATTERN_VALUE_LIMIT} to ${MAX_PATTERN_VALUE_LIMIT}`,
|
|
423
|
+
{ patternValueLimit: typeof limit === "number" ? limit : String(limit) }
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
417
427
|
function requirePositiveSafeInteger(field, value) {
|
|
418
428
|
if (value === void 0) return;
|
|
419
429
|
if (!Number.isSafeInteger(value) || value < 1) {
|
|
@@ -1507,4 +1517,4 @@ function pickDisplaySurface(surfaceOccurrences) {
|
|
|
1507
1517
|
return best;
|
|
1508
1518
|
}
|
|
1509
1519
|
|
|
1510
|
-
export { clampLimit, dedupePinnedEntries, executeListDocuments, executePreflight, executeQuery, executeSuggest, foldGroupReducer, hitsKeptPerGroup, listBindingOf, now, queryBindingOf, resolveHybridFusion, validateBM25Params, validateDocId, validateIndexName, validatePartitionConfig, validateWorkerConfig };
|
|
1520
|
+
export { clampLimit, dedupePinnedEntries, executeListDocuments, executePreflight, executeQuery, executeSuggest, foldGroupReducer, hitsKeptPerGroup, listBindingOf, now, queryBindingOf, resolveHybridFusion, validateBM25Params, validateDocId, validateIndexName, validatePartitionConfig, validatePatternValueLimit, validateWorkerConfig };
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { ReplicationMessageTypes } from './chunk-GCM3JFVA.mjs';
|
|
2
|
-
import { WIRE_BATCH_BUDGET, resolveVectorText, bindEngineCore, collectRequiredFieldFailures, embedChunkDocuments, providedDocId, admitInsert, asBatchInsertError, embedDocumentFields, assertDocumentCarriesMappedVectors } from './chunk-
|
|
3
|
-
import { generateId,
|
|
4
|
-
import { detectRuntime } from './chunk-
|
|
5
|
-
import { validateWorkerConfig, validateIndexName, validateBM25Params, validatePartitionConfig, executeQuery, queryBindingOf, executePreflight, executeSuggest, executeListDocuments, validateDocId } from './chunk-
|
|
6
|
-
import { BATCH_CHUNK_SIZE, STATISTICS_BROADCAST_INTERVAL_MS, MAX_SWEEP_INTERVAL_MS, MIN_SWEEP_INTERVAL_MS, HEAP_PRESSURE_WARNING_FRACTION, FOREIGN_STATS_TTL_MS, MIN_DOCUMENTS_FOR_SEGMENTS, HEAP_PRESSURE_REARM_FRACTION } from './chunk-
|
|
7
|
-
import { getNestedValue, collectQueryTermStats, mergePartitionStats, oversampledFacetConfig, fnv1a, kWayMerge, mergeFacets } from './chunk-
|
|
8
|
-
import { extractVectorFieldsFromSchema, validateSchema, validateVectorPromotion, validateVectorStorage, flattenSchema,
|
|
9
|
-
import { releaseLocksHeldBy } from './chunk-
|
|
2
|
+
import { WIRE_BATCH_BUDGET, resolveVectorText, bindEngineCore, restoredConfigFields, restoredEmbedding, collectRequiredFieldFailures, embedChunkDocuments, providedDocId, admitInsert, asBatchInsertError, embedDocumentFields, assertDocumentCarriesMappedVectors, admitBufferedUpsert, createPendingAdmissions, recordPendingAdmission } from './chunk-FVLQ63B7.mjs';
|
|
3
|
+
import { generateId, splitWorkerBudget, resolveWorkerCount, createDirectExecutor, createPartitionRouter, createCompositePartition, deserializePayloadV2, createSharedFrozenSegment, createPartitionManager, buildSegmentPayload, resolvePartitionInsertOptions, resolveWorkerEntry, missingWorkerEntry, readHeapStatistics, resolveIndexAnalysis, deserializePayloadV1, decodeVectorIndexParts, nodeThreadId, resolveRequestThreadCount, createPartitionIndex, VECTOR_FILE_MAX_VECTORS, deadBytesFor, mergeFrozenSegments, isCompositePartition, workerResourceLimits, deserializeMetadata, isNodeMainThread, spawnNodeWorker, freezeSegmentShared, DEFAULT_BACKPRESSURE_LIMIT, DEFAULT_REQUEST_TIMEOUT_MS, SHUTDOWN_TIMEOUT_MS, serializeMetadata, encodeSegmentState, CONSECUTIVE_TIMEOUTS_BEFORE_DEATH, decodeVectorFilePayload, documentsOfPayloadV2, countDead, decodeVectorGraphPayload, deadBitsWhere, NO_LIVE_VECTOR_AT_POSITION, createFrozenSegment } from './chunk-M76V3OGJ.mjs';
|
|
4
|
+
import { getLanguage, detectRuntime } from './chunk-HWQLTLNG.mjs';
|
|
5
|
+
import { validateWorkerConfig, validateIndexName, validatePatternValueLimit, validateBM25Params, validatePartitionConfig, executeQuery, queryBindingOf, executePreflight, executeSuggest, executeListDocuments, validateDocId } from './chunk-P4DSQ6M4.mjs';
|
|
6
|
+
import { BATCH_CHUNK_SIZE, STATISTICS_BROADCAST_INTERVAL_MS, MAX_SWEEP_INTERVAL_MS, MIN_SWEEP_INTERVAL_MS, HEAP_PRESSURE_WARNING_FRACTION, FOREIGN_STATS_TTL_MS, MIN_DOCUMENTS_FOR_SEGMENTS, HEAP_PRESSURE_REARM_FRACTION } from './chunk-GIVAGD3Q.mjs';
|
|
7
|
+
import { getNestedValue, collectQueryTermStats, mergePartitionStats, oversampledFacetConfig, fnv1a, kWayMerge, mergeFacets } from './chunk-LMO5TJUS.mjs';
|
|
8
|
+
import { extractVectorFieldsFromSchema, validateSchema, validateVectorPromotion, validateVectorStorage, flattenSchema, isSingleStringFieldType, requireValidFieldTypes, validateRequiredFields, validateDocument, validateDocumentStrict } from './chunk-653BNMAF.mjs';
|
|
9
|
+
import { releaseLocksHeldBy } from './chunk-YJDQ7NLA.mjs';
|
|
10
10
|
import { requireSearchBackendSettings } from './chunk-YNVIUGF5.mjs';
|
|
11
11
|
import { crc32, nativeCrc32, crc32Final, crc32Init, crc32Update } from './chunk-3L4U6EJQ.mjs';
|
|
12
12
|
import { CHECKSUM_TIMEOUT_MS, CHECKSUM_YIELD_CHUNK_BYTES } from './chunk-IFBKLBGB.mjs';
|
|
13
|
-
import { compareCodePoints } from './chunk-
|
|
13
|
+
import { compareCodePoints } from './chunk-OI42GWLR.mjs';
|
|
14
14
|
import { createRequestId, isValidWorkerResponse, threadSlotOfWorker } from './chunk-POWOTUKJ.mjs';
|
|
15
|
-
import {
|
|
15
|
+
import { ErrorCodes, NarsilError } from './chunk-USKFU7J5.mjs';
|
|
16
16
|
import { encode, decode } from '@msgpack/msgpack';
|
|
17
17
|
|
|
18
18
|
// src/engine/config-keys.ts
|
|
@@ -356,7 +356,7 @@ function validateEmbeddingConfig(embeddingConfig, schema, instanceAdapter) {
|
|
|
356
356
|
{ field: source, targetField }
|
|
357
357
|
);
|
|
358
358
|
}
|
|
359
|
-
if (!
|
|
359
|
+
if (!isSingleStringFieldType(sourceType)) {
|
|
360
360
|
throw new NarsilError(
|
|
361
361
|
ErrorCodes.EMBEDDING_CONFIG_INVALID,
|
|
362
362
|
`Embedding source field "${source}" must be a string type, got "${sourceType}"`,
|
|
@@ -1574,6 +1574,7 @@ async function decodeSnapshotBundle(data) {
|
|
|
1574
1574
|
if (!raw.schema || typeof raw.schema !== "object") {
|
|
1575
1575
|
throw new NarsilError(ErrorCodes.PERSISTENCE_LOAD_FAILED, "Snapshot bundle missing schema");
|
|
1576
1576
|
}
|
|
1577
|
+
requireValidFieldTypes(raw.schema);
|
|
1577
1578
|
if (typeof raw.language !== "string") {
|
|
1578
1579
|
throw new NarsilError(ErrorCodes.PERSISTENCE_LOAD_FAILED, "Snapshot bundle missing language");
|
|
1579
1580
|
}
|
|
@@ -2533,6 +2534,7 @@ function validateManifestCommon(raw) {
|
|
|
2533
2534
|
if (typeof raw.language !== "string") {
|
|
2534
2535
|
throw new NarsilError(ErrorCodes.PERSISTENCE_LOAD_FAILED, "Segment manifest is missing language");
|
|
2535
2536
|
}
|
|
2537
|
+
requireValidFieldTypes(raw.schema);
|
|
2536
2538
|
return { schema: raw.schema, language: raw.language };
|
|
2537
2539
|
}
|
|
2538
2540
|
function normalizeCheckpoint2(raw) {
|
|
@@ -2953,6 +2955,9 @@ function reconstructSchemaFromMetadata(metadata) {
|
|
|
2953
2955
|
if (metadata.vectorPromotion !== void 0) {
|
|
2954
2956
|
config.vectorPromotion = metadata.vectorPromotion;
|
|
2955
2957
|
}
|
|
2958
|
+
if (metadata.patternValueLimit !== void 0) {
|
|
2959
|
+
config.patternValueLimit = metadata.patternValueLimit;
|
|
2960
|
+
}
|
|
2956
2961
|
return config;
|
|
2957
2962
|
}
|
|
2958
2963
|
function createEntryMessage(entry, sourceId) {
|
|
@@ -5667,6 +5672,9 @@ function buildMetadata(indexName, hooks, documentCount) {
|
|
|
5667
5672
|
if (config.vectorPromotion !== void 0) {
|
|
5668
5673
|
metadata.vectorPromotion = config.vectorPromotion;
|
|
5669
5674
|
}
|
|
5675
|
+
if (config.patternValueLimit !== void 0) {
|
|
5676
|
+
metadata.patternValueLimit = config.patternValueLimit;
|
|
5677
|
+
}
|
|
5670
5678
|
if (config.indexUuid !== void 0) {
|
|
5671
5679
|
metadata.indexUuid = config.indexUuid;
|
|
5672
5680
|
}
|
|
@@ -5780,7 +5788,8 @@ function createDurabilityFromTier(tier, wiring) {
|
|
|
5780
5788
|
...entry.config.trackPositions !== void 0 ? { trackPositions: entry.config.trackPositions } : {},
|
|
5781
5789
|
...entry.config.strict !== void 0 ? { strict: entry.config.strict } : {},
|
|
5782
5790
|
...entry.config.required !== void 0 ? { required: entry.config.required } : {},
|
|
5783
|
-
...entry.config.vectorPromotion !== void 0 ? { vectorPromotion: entry.config.vectorPromotion } : {}
|
|
5791
|
+
...entry.config.vectorPromotion !== void 0 ? { vectorPromotion: entry.config.vectorPromotion } : {},
|
|
5792
|
+
...entry.config.patternValueLimit !== void 0 ? { patternValueLimit: entry.config.patternValueLimit } : {}
|
|
5784
5793
|
};
|
|
5785
5794
|
},
|
|
5786
5795
|
createIndexFromMetadata: wiring.createIndexFromMetadata,
|
|
@@ -5795,6 +5804,11 @@ function getVectorFieldPaths(schema) {
|
|
|
5795
5804
|
}
|
|
5796
5805
|
|
|
5797
5806
|
// src/engine/index-from-metadata.ts
|
|
5807
|
+
var RECOVERY_CONFIG_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
5808
|
+
ErrorCodes.CONFIG_INVALID,
|
|
5809
|
+
ErrorCodes.SCHEMA_INVALID_TYPE,
|
|
5810
|
+
ErrorCodes.SCHEMA_INVALID_VECTOR_DIMENSION
|
|
5811
|
+
]);
|
|
5798
5812
|
function resolveEmbeddingAdapter(deps, metadata, schema) {
|
|
5799
5813
|
const name = metadata.embedding?.adapter ?? null;
|
|
5800
5814
|
if (!metadata.embedding) return { adapter: null, name };
|
|
@@ -5813,6 +5827,15 @@ function resolveEmbeddingAdapter(deps, metadata, schema) {
|
|
|
5813
5827
|
}
|
|
5814
5828
|
return { adapter: candidate, name };
|
|
5815
5829
|
}
|
|
5830
|
+
function recoveryFailure(metadata, err) {
|
|
5831
|
+
if (!(err instanceof NarsilError) || !RECOVERY_CONFIG_ERROR_CODES.has(err.code)) return err;
|
|
5832
|
+
return new NarsilError(err.code, `Recovery of index "${metadata.indexName}" failed: ${err.message}`, {
|
|
5833
|
+
...err.details,
|
|
5834
|
+
indexName: metadata.indexName,
|
|
5835
|
+
tokenizer: metadata.tokenizer,
|
|
5836
|
+
stopWords: metadata.stopWords
|
|
5837
|
+
});
|
|
5838
|
+
}
|
|
5816
5839
|
async function createIndexFromMetadata(deps, metadata, loadData) {
|
|
5817
5840
|
const existing = deps.indexRegistry.get(metadata.indexName);
|
|
5818
5841
|
if (existing !== void 0) {
|
|
@@ -5823,19 +5846,18 @@ async function createIndexFromMetadata(deps, metadata, loadData) {
|
|
|
5823
5846
|
}
|
|
5824
5847
|
const indexConfig = reconstructSchemaFromMetadata(metadata);
|
|
5825
5848
|
const language = getLanguage(indexConfig.language ?? "english");
|
|
5849
|
+
try {
|
|
5850
|
+
indexConfig.schema = validateSchema(indexConfig.schema);
|
|
5851
|
+
validatePatternValueLimit(indexConfig.patternValueLimit);
|
|
5852
|
+
} catch (err) {
|
|
5853
|
+
throw recoveryFailure(metadata, err);
|
|
5854
|
+
}
|
|
5826
5855
|
const embedding = resolveEmbeddingAdapter(deps, metadata, indexConfig.schema);
|
|
5827
5856
|
try {
|
|
5828
5857
|
validateVectorStorage(indexConfig.vectorPromotion, deps.filesystemDurability);
|
|
5829
5858
|
if (loadData) deps.executor.createIndex(metadata.indexName, indexConfig, language);
|
|
5830
5859
|
} catch (err) {
|
|
5831
|
-
|
|
5832
|
-
throw new NarsilError(err.code, `Recovery of index "${metadata.indexName}" failed: ${err.message}`, {
|
|
5833
|
-
indexName: metadata.indexName,
|
|
5834
|
-
tokenizer: metadata.tokenizer,
|
|
5835
|
-
stopWords: metadata.stopWords
|
|
5836
|
-
});
|
|
5837
|
-
}
|
|
5838
|
-
throw err;
|
|
5860
|
+
throw recoveryFailure(metadata, err);
|
|
5839
5861
|
}
|
|
5840
5862
|
deps.indexRegistry.set(metadata.indexName, {
|
|
5841
5863
|
config: indexConfig,
|
|
@@ -6442,21 +6464,10 @@ function createHeapPressureNotifier(deps) {
|
|
|
6442
6464
|
}
|
|
6443
6465
|
|
|
6444
6466
|
// src/engine/watermark.ts
|
|
6445
|
-
function createWatermarkNotifier(deps) {
|
|
6467
|
+
function createWatermarkNotifier(deps, scope = "index") {
|
|
6446
6468
|
const latchedCapacity = /* @__PURE__ */ new Map();
|
|
6447
|
-
|
|
6448
|
-
|
|
6449
|
-
const maxDocs = partitionConfig?.maxDocsPerPartition;
|
|
6450
|
-
const watermark = partitionConfig?.watermark;
|
|
6451
|
-
if (maxDocs === void 0 || watermark === void 0) {
|
|
6452
|
-
latchedCapacity.delete(indexName);
|
|
6453
|
-
return;
|
|
6454
|
-
}
|
|
6455
|
-
const manager = deps.getManager(indexName);
|
|
6456
|
-
if (!manager) {
|
|
6457
|
-
latchedCapacity.delete(indexName);
|
|
6458
|
-
return;
|
|
6459
|
-
}
|
|
6469
|
+
const latchedPartitions = /* @__PURE__ */ new Map();
|
|
6470
|
+
function checkIndex(indexName, manager, maxDocs, watermark) {
|
|
6460
6471
|
const partitionCount = manager.partitionCount;
|
|
6461
6472
|
const capacity = maxDocs * partitionCount;
|
|
6462
6473
|
const documentCount = manager.countDocuments();
|
|
@@ -6469,19 +6480,63 @@ function createWatermarkNotifier(deps) {
|
|
|
6469
6480
|
latchedCapacity.set(indexName, capacity);
|
|
6470
6481
|
deps.emit({ indexName, documentCount, capacity, partitionCount });
|
|
6471
6482
|
}
|
|
6483
|
+
function checkPartitions(indexName, manager, maxDocs, watermark, insertedDocIds) {
|
|
6484
|
+
const threshold = watermark * maxDocs;
|
|
6485
|
+
const latched = latchedPartitions.get(indexName) ?? /* @__PURE__ */ new Set();
|
|
6486
|
+
latchedPartitions.set(indexName, latched);
|
|
6487
|
+
const checked = /* @__PURE__ */ new Set();
|
|
6488
|
+
for (const docId of insertedDocIds) {
|
|
6489
|
+
const partitionId = manager.partitionIdOf(docId) ?? manager.routePartition(docId);
|
|
6490
|
+
if (checked.has(partitionId)) continue;
|
|
6491
|
+
checked.add(partitionId);
|
|
6492
|
+
const documentCount = manager.getPartition(partitionId).count();
|
|
6493
|
+
if (documentCount < threshold) {
|
|
6494
|
+
latched.delete(partitionId);
|
|
6495
|
+
continue;
|
|
6496
|
+
}
|
|
6497
|
+
if (latched.has(partitionId)) continue;
|
|
6498
|
+
latched.add(partitionId);
|
|
6499
|
+
deps.emit({ indexName, documentCount, capacity: maxDocs, partitionCount: manager.partitionCount, partitionId });
|
|
6500
|
+
}
|
|
6501
|
+
}
|
|
6502
|
+
function check(indexName, inserted) {
|
|
6503
|
+
const partitionConfig = deps.getPartitionConfig(indexName);
|
|
6504
|
+
const maxDocs = partitionConfig?.maxDocsPerPartition;
|
|
6505
|
+
const watermark = partitionConfig?.watermark;
|
|
6506
|
+
if (maxDocs === void 0 || watermark === void 0) {
|
|
6507
|
+
forget(indexName);
|
|
6508
|
+
return;
|
|
6509
|
+
}
|
|
6510
|
+
const manager = deps.getManager(indexName);
|
|
6511
|
+
if (manager === void 0) {
|
|
6512
|
+
forget(indexName);
|
|
6513
|
+
return;
|
|
6514
|
+
}
|
|
6515
|
+
if (scope === "index") {
|
|
6516
|
+
checkIndex(indexName, manager, maxDocs, watermark);
|
|
6517
|
+
return;
|
|
6518
|
+
}
|
|
6519
|
+
if (inserted !== void 0) {
|
|
6520
|
+
checkPartitions(indexName, manager, maxDocs, watermark, typeof inserted === "string" ? [inserted] : inserted);
|
|
6521
|
+
}
|
|
6522
|
+
}
|
|
6472
6523
|
function forget(indexName) {
|
|
6473
6524
|
latchedCapacity.delete(indexName);
|
|
6525
|
+
latchedPartitions.delete(indexName);
|
|
6474
6526
|
}
|
|
6475
6527
|
return { check, forget };
|
|
6476
6528
|
}
|
|
6477
6529
|
|
|
6478
6530
|
// src/engine/notifiers.ts
|
|
6479
6531
|
function wireWatermarkNotifier(wiring) {
|
|
6480
|
-
return createWatermarkNotifier(
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6532
|
+
return createWatermarkNotifier(
|
|
6533
|
+
{
|
|
6534
|
+
getManager: wiring.getManager,
|
|
6535
|
+
getPartitionConfig: (indexName) => wiring.indexRegistry.get(indexName)?.config.partitions,
|
|
6536
|
+
emit: (payload) => emitEngineEvent(wiring.eventHandlers, "partitionWatermark", payload)
|
|
6537
|
+
},
|
|
6538
|
+
wiring.capacityScope
|
|
6539
|
+
);
|
|
6485
6540
|
}
|
|
6486
6541
|
function warnUnheardHeapPressure(payload) {
|
|
6487
6542
|
console.warn(
|
|
@@ -8453,7 +8508,7 @@ function createWorkerOrchestrator(config, executor, indexRegistry, callbacks, ve
|
|
|
8453
8508
|
}
|
|
8454
8509
|
|
|
8455
8510
|
// src/engine/core.ts
|
|
8456
|
-
function createEngineCore(config, hooks) {
|
|
8511
|
+
function createEngineCore(config, hooks, capacityScope = "index") {
|
|
8457
8512
|
validateWorkerConfig(config?.workers, config?.lifecycle);
|
|
8458
8513
|
const vectorWorkerCount = splitWorkerBudget(resolveWorkerCount(config?.workers?.count)).vector;
|
|
8459
8514
|
const vectorCopyPolicy = {
|
|
@@ -8601,7 +8656,8 @@ function createEngineCore(config, hooks) {
|
|
|
8601
8656
|
const notifierWiring = {
|
|
8602
8657
|
eventHandlers,
|
|
8603
8658
|
indexRegistry,
|
|
8604
|
-
getManager: (indexName) => executor.getManager(indexName)
|
|
8659
|
+
getManager: (indexName) => executor.getManager(indexName),
|
|
8660
|
+
capacityScope
|
|
8605
8661
|
};
|
|
8606
8662
|
const watermarkNotifier = wireWatermarkNotifier(notifierWiring);
|
|
8607
8663
|
const heapPressureNotifier = wireHeapPressureNotifier(notifierWiring);
|
|
@@ -8645,6 +8701,7 @@ function createEngineCore(config, hooks) {
|
|
|
8645
8701
|
pendingRebalanceWrites: (indexName) => waqMap.get(indexName)?.size ?? 0,
|
|
8646
8702
|
rebalanceTargetPartitionCount: (indexName) => rebalanceTargets.get(indexName),
|
|
8647
8703
|
bufferedDocState: (indexName, docId) => waqMap.get(indexName)?.bufferedDocState(docId),
|
|
8704
|
+
capacityScope,
|
|
8648
8705
|
checkWatermark: watermarkNotifier.check,
|
|
8649
8706
|
checkHeapPressure: heapPressureNotifier.check
|
|
8650
8707
|
};
|
|
@@ -8778,13 +8835,16 @@ async function runLifecycleHook(core, hookName, context) {
|
|
|
8778
8835
|
async function announceIndexCreated(core, name, config) {
|
|
8779
8836
|
await runLifecycleHook(core, "onIndexCreate", { indexName: name, config });
|
|
8780
8837
|
}
|
|
8781
|
-
async function createEngineIndex(core, config, name,
|
|
8838
|
+
async function createEngineIndex(core, config, name, requestedConfig, creation = {}) {
|
|
8839
|
+
const { indexUuid, adapterBinding = "required" } = creation;
|
|
8782
8840
|
core.guardShutdown();
|
|
8783
8841
|
validateIndexName(name);
|
|
8784
8842
|
if (core.indexRegistry.has(name)) {
|
|
8785
8843
|
throw new NarsilError(ErrorCodes.INDEX_ALREADY_EXISTS, `Index "${name}" already exists`, { indexName: name });
|
|
8786
8844
|
}
|
|
8787
|
-
validateSchema(
|
|
8845
|
+
const schema = validateSchema(requestedConfig.schema);
|
|
8846
|
+
const indexConfig = schema === requestedConfig.schema ? requestedConfig : { ...requestedConfig, schema };
|
|
8847
|
+
validatePatternValueLimit(indexConfig.patternValueLimit);
|
|
8788
8848
|
validateVectorPromotion(indexConfig.vectorPromotion);
|
|
8789
8849
|
validateVectorStorage(indexConfig.vectorPromotion, core.filesystemDurability);
|
|
8790
8850
|
validateBM25Params(indexConfig.bm25);
|
|
@@ -8810,24 +8870,31 @@ async function createEngineIndex(core, config, name, indexConfig, indexUuid) {
|
|
|
8810
8870
|
let resolvedEmbeddingAdapter = null;
|
|
8811
8871
|
let embeddingAdapterName = null;
|
|
8812
8872
|
if (indexConfig.embedding) {
|
|
8813
|
-
|
|
8873
|
+
const configuredAdapter = indexConfig.embedding.adapter;
|
|
8874
|
+
const fields = indexConfig.embedding.fields;
|
|
8814
8875
|
if (typeof configuredAdapter === "string") {
|
|
8815
8876
|
embeddingAdapterName = configuredAdapter;
|
|
8816
8877
|
const registered = core.embeddingAdapters.get(configuredAdapter);
|
|
8817
|
-
if (
|
|
8878
|
+
if (registered !== void 0) {
|
|
8879
|
+
resolvedEmbeddingAdapter = validateEmbeddingConfig(
|
|
8880
|
+
{ fields, adapter: registered },
|
|
8881
|
+
indexConfig.schema,
|
|
8882
|
+
config?.embedding
|
|
8883
|
+
);
|
|
8884
|
+
} else if (adapterBinding === "required") {
|
|
8818
8885
|
throw new NarsilError(
|
|
8819
8886
|
ErrorCodes.EMBEDDING_CONFIG_INVALID,
|
|
8820
8887
|
`Embedding adapter "${configuredAdapter}" is not registered on this engine`,
|
|
8821
8888
|
{ adapter: configuredAdapter, available: [...core.embeddingAdapters.keys()] }
|
|
8822
8889
|
);
|
|
8823
8890
|
}
|
|
8824
|
-
|
|
8891
|
+
} else if (adapterBinding === "required" || configuredAdapter !== void 0 || config?.embedding !== void 0) {
|
|
8892
|
+
resolvedEmbeddingAdapter = validateEmbeddingConfig(
|
|
8893
|
+
{ fields, adapter: configuredAdapter },
|
|
8894
|
+
indexConfig.schema,
|
|
8895
|
+
config?.embedding
|
|
8896
|
+
);
|
|
8825
8897
|
}
|
|
8826
|
-
resolvedEmbeddingAdapter = validateEmbeddingConfig(
|
|
8827
|
-
{ fields: indexConfig.embedding.fields, adapter: configuredAdapter },
|
|
8828
|
-
indexConfig.schema,
|
|
8829
|
-
config?.embedding
|
|
8830
|
-
);
|
|
8831
8898
|
}
|
|
8832
8899
|
if (indexConfig.required && indexConfig.required.length > 0) {
|
|
8833
8900
|
validateRequiredFieldsInSchema(indexConfig.required, indexConfig.schema);
|
|
@@ -9042,7 +9109,7 @@ async function insertDocument(ctx, indexName, document, docId, options) {
|
|
|
9042
9109
|
await applyInsert();
|
|
9043
9110
|
}
|
|
9044
9111
|
if (buffered) {
|
|
9045
|
-
ctx.checkWatermark(indexName);
|
|
9112
|
+
ctx.checkWatermark(indexName, resolvedDocId);
|
|
9046
9113
|
ctx.checkHeapPressure(indexName);
|
|
9047
9114
|
if (options?.wait === true) await awaitWriteVisibility(ctx, indexName);
|
|
9048
9115
|
return resolvedDocId;
|
|
@@ -9066,7 +9133,7 @@ async function insertDocument(ctx, indexName, document, docId, options) {
|
|
|
9066
9133
|
vecIndex.scheduleBuild();
|
|
9067
9134
|
}
|
|
9068
9135
|
}
|
|
9069
|
-
ctx.checkWatermark(indexName);
|
|
9136
|
+
ctx.checkWatermark(indexName, resolvedDocId);
|
|
9070
9137
|
ctx.checkHeapPressure(indexName);
|
|
9071
9138
|
await ctx.orchestrator.scaleOutReadyIndexes();
|
|
9072
9139
|
if (options?.wait === true) await awaitWriteVisibility(ctx, indexName);
|
|
@@ -9177,6 +9244,7 @@ async function admitBatchDocuments(ctx, indexName, documents, failed) {
|
|
|
9177
9244
|
const required = entry.config.required;
|
|
9178
9245
|
const admitted = [];
|
|
9179
9246
|
const admittedIds = /* @__PURE__ */ new Set();
|
|
9247
|
+
const pending = createPendingAdmissions();
|
|
9180
9248
|
for (let chunkStart = 0; chunkStart < documents.length; chunkStart += BATCH_CHUNK_SIZE) {
|
|
9181
9249
|
if (ctx.abortController.signal.aborted) break;
|
|
9182
9250
|
const chunkEnd = Math.min(chunkStart + BATCH_CHUNK_SIZE, documents.length);
|
|
@@ -9209,15 +9277,16 @@ async function admitBatchDocuments(ctx, indexName, documents, failed) {
|
|
|
9209
9277
|
if (extractedVectors.size > 0) {
|
|
9210
9278
|
validateVectorDimensions(extractedVectors, vecIndexes);
|
|
9211
9279
|
}
|
|
9212
|
-
admitInsert(ctx, indexName, manager, docId,
|
|
9280
|
+
admitInsert(ctx, indexName, manager, docId, pending);
|
|
9213
9281
|
if (admittedIds.has(docId) || manager.has(docId)) {
|
|
9214
9282
|
throw new NarsilError(ErrorCodes.DOC_ALREADY_EXISTS, `Document "${docId}" already exists`, { docId });
|
|
9215
9283
|
}
|
|
9216
|
-
validateDocument(partitionDoc, entry.config.schema);
|
|
9284
|
+
validateDocument(partitionDoc, entry.config.schema, entry.config.patternValueLimit);
|
|
9217
9285
|
if (strict) {
|
|
9218
9286
|
validateDocumentStrict(partitionDoc, entry.config.schema);
|
|
9219
9287
|
}
|
|
9220
9288
|
admittedIds.add(docId);
|
|
9289
|
+
recordPendingAdmission(ctx, pending, manager, docId);
|
|
9221
9290
|
admitted.push({ docId, document: documents[i], partitionDoc, extractedVectors });
|
|
9222
9291
|
} catch (err) {
|
|
9223
9292
|
failed.push({ docId, error: asBatchInsertError(err) });
|
|
@@ -9616,7 +9685,7 @@ async function insertBatchViaSegments(ctx, indexName, documents, options) {
|
|
|
9616
9685
|
for (const fieldPath of outcome.touchedVectorFields) {
|
|
9617
9686
|
vecIndexes.get(fieldPath)?.scheduleBuild();
|
|
9618
9687
|
}
|
|
9619
|
-
ctx.checkWatermark(indexName);
|
|
9688
|
+
ctx.checkWatermark(indexName, outcome.succeeded);
|
|
9620
9689
|
ctx.checkHeapPressure(indexName);
|
|
9621
9690
|
await ctx.orchestrator.scaleOutReadyIndexes();
|
|
9622
9691
|
if (options?.wait === true) await awaitWriteVisibility(ctx, indexName);
|
|
@@ -9749,7 +9818,7 @@ async function insertDocumentBatch(ctx, indexName, documents, options) {
|
|
|
9749
9818
|
vecIndex.scheduleBuild();
|
|
9750
9819
|
}
|
|
9751
9820
|
}
|
|
9752
|
-
ctx.checkWatermark(indexName);
|
|
9821
|
+
ctx.checkWatermark(indexName, succeeded);
|
|
9753
9822
|
ctx.checkHeapPressure(indexName);
|
|
9754
9823
|
await ctx.orchestrator.scaleOutReadyIndexes();
|
|
9755
9824
|
if (options?.wait === true) await awaitWriteVisibility(ctx, indexName);
|
|
@@ -9982,7 +10051,7 @@ function applyOfUpdate(ctx, indexName, prepared) {
|
|
|
9982
10051
|
const bufferedState = ctx.bufferedDocState(indexName, docId);
|
|
9983
10052
|
const exists = bufferedState !== void 0 ? bufferedState === "present" : manager.has(docId);
|
|
9984
10053
|
if (!exists) {
|
|
9985
|
-
|
|
10054
|
+
admitBufferedUpsert(ctx, indexName, manager, docId);
|
|
9986
10055
|
}
|
|
9987
10056
|
}
|
|
9988
10057
|
if (ctx.bufferIfRebalancing(indexName, { action: "update", docId, document, indexName })) {
|
|
@@ -10341,162 +10410,6 @@ async function executeRebalance(manager, indexName, targetPartitionCount, ctx) {
|
|
|
10341
10410
|
ctx.checkWatermark(indexName);
|
|
10342
10411
|
}
|
|
10343
10412
|
|
|
10344
|
-
// src/engine/snapshot/restore-config.ts
|
|
10345
|
-
function invalid2(message) {
|
|
10346
|
-
throw new NarsilError(ErrorCodes.DOC_VALIDATION_FAILED, `Invalid snapshot: ${message}`);
|
|
10347
|
-
}
|
|
10348
|
-
function isPlainObject(value) {
|
|
10349
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
10350
|
-
}
|
|
10351
|
-
function restoredBm25(raw) {
|
|
10352
|
-
if (raw === void 0) {
|
|
10353
|
-
return void 0;
|
|
10354
|
-
}
|
|
10355
|
-
if (!isPlainObject(raw)) {
|
|
10356
|
-
invalid2("bm25 must be an object");
|
|
10357
|
-
}
|
|
10358
|
-
const { k1, b } = raw;
|
|
10359
|
-
if (k1 !== void 0 && (typeof k1 !== "number" || !Number.isFinite(k1))) {
|
|
10360
|
-
invalid2("bm25 k1 must be a finite number");
|
|
10361
|
-
}
|
|
10362
|
-
if (b !== void 0 && (typeof b !== "number" || !Number.isFinite(b))) {
|
|
10363
|
-
invalid2("bm25 b must be a finite number");
|
|
10364
|
-
}
|
|
10365
|
-
return {
|
|
10366
|
-
...k1 !== void 0 ? { k1 } : {},
|
|
10367
|
-
...b !== void 0 ? { b } : {}
|
|
10368
|
-
};
|
|
10369
|
-
}
|
|
10370
|
-
function restoredStopWords(name, list) {
|
|
10371
|
-
if (name !== void 0 && typeof name !== "string") {
|
|
10372
|
-
invalid2("stopWords must be a name");
|
|
10373
|
-
}
|
|
10374
|
-
if (list !== void 0 && (!Array.isArray(list) || !list.every((word) => typeof word === "string"))) {
|
|
10375
|
-
invalid2("stopWordList must be a list of words");
|
|
10376
|
-
}
|
|
10377
|
-
if (typeof name === "string" && Array.isArray(list)) {
|
|
10378
|
-
invalid2("stopWords and stopWordList cannot both be present");
|
|
10379
|
-
}
|
|
10380
|
-
if (typeof name === "string") {
|
|
10381
|
-
return name;
|
|
10382
|
-
}
|
|
10383
|
-
if (Array.isArray(list)) {
|
|
10384
|
-
return new Set(list);
|
|
10385
|
-
}
|
|
10386
|
-
return void 0;
|
|
10387
|
-
}
|
|
10388
|
-
function restoredPartitionConfig(raw) {
|
|
10389
|
-
if (raw === void 0) {
|
|
10390
|
-
return void 0;
|
|
10391
|
-
}
|
|
10392
|
-
if (!isPlainObject(raw)) {
|
|
10393
|
-
invalid2("partitionConfig must be an object");
|
|
10394
|
-
}
|
|
10395
|
-
const { maxDocsPerPartition, maxPartitions, watermark } = raw;
|
|
10396
|
-
if (maxDocsPerPartition !== void 0 && (typeof maxDocsPerPartition !== "number" || !Number.isInteger(maxDocsPerPartition) || maxDocsPerPartition < 1)) {
|
|
10397
|
-
invalid2("partitionConfig maxDocsPerPartition must be a positive integer");
|
|
10398
|
-
}
|
|
10399
|
-
if (maxPartitions !== void 0 && (typeof maxPartitions !== "number" || !Number.isInteger(maxPartitions) || maxPartitions < 1)) {
|
|
10400
|
-
invalid2("partitionConfig maxPartitions must be a positive integer");
|
|
10401
|
-
}
|
|
10402
|
-
if (watermark !== void 0 && (typeof watermark !== "number" || !(watermark > 0) || watermark > 1)) {
|
|
10403
|
-
invalid2("partitionConfig watermark must be above 0 and at most 1");
|
|
10404
|
-
}
|
|
10405
|
-
return {
|
|
10406
|
-
...typeof maxDocsPerPartition === "number" ? { maxDocsPerPartition } : {},
|
|
10407
|
-
...typeof maxPartitions === "number" ? { maxPartitions } : {},
|
|
10408
|
-
...typeof watermark === "number" ? { watermark } : {}
|
|
10409
|
-
};
|
|
10410
|
-
}
|
|
10411
|
-
function restoredScoring(raw) {
|
|
10412
|
-
if (raw === void 0) {
|
|
10413
|
-
return void 0;
|
|
10414
|
-
}
|
|
10415
|
-
if (raw !== "local" && raw !== "dfs" && raw !== "broadcast") {
|
|
10416
|
-
invalid2("defaultScoring must be 'local', 'dfs', or 'broadcast'");
|
|
10417
|
-
}
|
|
10418
|
-
return raw;
|
|
10419
|
-
}
|
|
10420
|
-
function restoredBoolean(raw, field) {
|
|
10421
|
-
if (raw === void 0) {
|
|
10422
|
-
return void 0;
|
|
10423
|
-
}
|
|
10424
|
-
if (typeof raw !== "boolean") {
|
|
10425
|
-
invalid2(`${field} must be a boolean`);
|
|
10426
|
-
}
|
|
10427
|
-
return raw;
|
|
10428
|
-
}
|
|
10429
|
-
function restoredRequired(raw) {
|
|
10430
|
-
if (raw === void 0) {
|
|
10431
|
-
return void 0;
|
|
10432
|
-
}
|
|
10433
|
-
if (!Array.isArray(raw) || !raw.every((field) => typeof field === "string")) {
|
|
10434
|
-
invalid2("required must be a list of field paths");
|
|
10435
|
-
}
|
|
10436
|
-
return raw;
|
|
10437
|
-
}
|
|
10438
|
-
function restoredVectorPromotion(raw) {
|
|
10439
|
-
if (raw === void 0) {
|
|
10440
|
-
return void 0;
|
|
10441
|
-
}
|
|
10442
|
-
if (!isPlainObject(raw) || raw.hnswConfig !== void 0 && !isPlainObject(raw.hnswConfig)) {
|
|
10443
|
-
invalid2("vectorPromotion must be an object");
|
|
10444
|
-
}
|
|
10445
|
-
return raw;
|
|
10446
|
-
}
|
|
10447
|
-
function restoredEmbedding(raw) {
|
|
10448
|
-
if (raw === void 0) {
|
|
10449
|
-
return void 0;
|
|
10450
|
-
}
|
|
10451
|
-
if (!isPlainObject(raw)) {
|
|
10452
|
-
invalid2("embedding must be an object");
|
|
10453
|
-
}
|
|
10454
|
-
const { fields, adapter } = raw;
|
|
10455
|
-
if (adapter !== void 0 && typeof adapter !== "string") {
|
|
10456
|
-
invalid2("embedding adapter must be a name");
|
|
10457
|
-
}
|
|
10458
|
-
if (!isPlainObject(fields)) {
|
|
10459
|
-
invalid2("embedding fields must be an object");
|
|
10460
|
-
}
|
|
10461
|
-
for (const value of Object.values(fields)) {
|
|
10462
|
-
const isPath = typeof value === "string";
|
|
10463
|
-
const isPathList = Array.isArray(value) && value.every((path) => typeof path === "string");
|
|
10464
|
-
if (!isPath && !isPathList) {
|
|
10465
|
-
invalid2("embedding fields must map vector fields to source paths");
|
|
10466
|
-
}
|
|
10467
|
-
}
|
|
10468
|
-
return {
|
|
10469
|
-
fields,
|
|
10470
|
-
...adapter !== void 0 ? { adapter } : {}
|
|
10471
|
-
};
|
|
10472
|
-
}
|
|
10473
|
-
function restoredConfigFields(envelope) {
|
|
10474
|
-
if (envelope.tokenizer !== void 0 && typeof envelope.tokenizer !== "string") {
|
|
10475
|
-
invalid2("tokenizer must be a name");
|
|
10476
|
-
}
|
|
10477
|
-
const stopWords = restoredStopWords(envelope.stopWords, envelope.stopWordList);
|
|
10478
|
-
const bm25 = restoredBm25(envelope.bm25);
|
|
10479
|
-
const surfaceForms = restoredBoolean(envelope.surfaceForms, "surfaceForms");
|
|
10480
|
-
const partitions = restoredPartitionConfig(envelope.partitionConfig);
|
|
10481
|
-
const defaultScoring = restoredScoring(envelope.defaultScoring);
|
|
10482
|
-
const trackPositions = restoredBoolean(envelope.trackPositions, "trackPositions");
|
|
10483
|
-
const strict = restoredBoolean(envelope.strict, "strict");
|
|
10484
|
-
const required = restoredRequired(envelope.required);
|
|
10485
|
-
const vectorPromotion = restoredVectorPromotion(envelope.vectorPromotion);
|
|
10486
|
-
return {
|
|
10487
|
-
...typeof envelope.tokenizer === "string" ? { tokenizer: envelope.tokenizer } : {},
|
|
10488
|
-
...stopWords !== void 0 ? { stopWords } : {},
|
|
10489
|
-
...bm25 !== void 0 ? { bm25 } : {},
|
|
10490
|
-
...surfaceForms !== void 0 ? { surfaceForms } : {},
|
|
10491
|
-
...partitions !== void 0 ? { partitions } : {},
|
|
10492
|
-
...defaultScoring !== void 0 ? { defaultScoring } : {},
|
|
10493
|
-
...trackPositions !== void 0 ? { trackPositions } : {},
|
|
10494
|
-
...strict !== void 0 ? { strict } : {},
|
|
10495
|
-
...required !== void 0 ? { required } : {},
|
|
10496
|
-
...vectorPromotion !== void 0 ? { vectorPromotion } : {}
|
|
10497
|
-
};
|
|
10498
|
-
}
|
|
10499
|
-
|
|
10500
10413
|
// src/engine/snapshot/index.ts
|
|
10501
10414
|
async function recordRestoredDocuments(durability, indexName, restored) {
|
|
10502
10415
|
if (restored.length === 0) return;
|
|
@@ -10552,6 +10465,7 @@ async function createSnapshot(manager, entry) {
|
|
|
10552
10465
|
...config.strict !== void 0 ? { strict: config.strict } : {},
|
|
10553
10466
|
...config.required !== void 0 ? { required: config.required } : {},
|
|
10554
10467
|
...config.vectorPromotion !== void 0 ? { vectorPromotion: config.vectorPromotion } : {},
|
|
10468
|
+
...config.patternValueLimit !== void 0 ? { patternValueLimit: config.patternValueLimit } : {},
|
|
10555
10469
|
...config.embedding !== void 0 ? {
|
|
10556
10470
|
embedding: {
|
|
10557
10471
|
fields: config.embedding.fields,
|
|
@@ -10604,8 +10518,8 @@ async function restoreFromSnapshot(indexName, data, deps) {
|
|
|
10604
10518
|
const configFields = restoredConfigFields(envelope);
|
|
10605
10519
|
const embedding = restoredEmbedding(envelope.embedding);
|
|
10606
10520
|
const language = getLanguage(envelope.language);
|
|
10607
|
-
const schema = envelope.schema;
|
|
10608
|
-
|
|
10521
|
+
const schema = validateSchema(envelope.schema);
|
|
10522
|
+
validatePatternValueLimit(configFields.patternValueLimit);
|
|
10609
10523
|
validateVectorPromotion(configFields.vectorPromotion);
|
|
10610
10524
|
validateVectorStorage(configFields.vectorPromotion, deps.filesystemDurability);
|
|
10611
10525
|
if (configFields.required !== void 0 && configFields.required.length > 0) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OSQ_STEPS, OSQ_GRID, OSQ_REFINE_ROUNDS, OSQ_REFINE_TOLERANCE, OSQ4_NARROW_DIMENSION_LIMIT, DEFAULT_OSQ4_NARROW_OVERSAMPLE, DEFAULT_OVERSAMPLE_BY_BITS, OSQ_QUERY_BITS, OSQ_LAMBDA } from './chunk-ZJ4CSAB2.mjs';
|
|
2
2
|
import { COMPACTION_TOMBSTONE_RATIO, COMPACTION_ABSOLUTE_THRESHOLD, nativeSearchCoreIsEnabled, loadNativeCore, stopUsingTheNativeSearchCore, noteFallback, MAX_LAYER_CAP, PLACEMENT_ROOM_REQUESTS, INITIAL_LIST_CAPACITY, DEFAULT_EF_SEARCH, INITIAL_UPPER_SLOTS } from './chunk-YNVIUGF5.mjs';
|
|
3
|
-
import { compareCodePoints } from './chunk-
|
|
3
|
+
import { compareCodePoints } from './chunk-OI42GWLR.mjs';
|
|
4
4
|
import { NarsilError, ErrorCodes } from './chunk-USKFU7J5.mjs';
|
|
5
5
|
import { readSync, closeSync, openSync } from 'fs';
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as PartitionConfig, A as AnyDocument, a as InsertOptions, W as WriteOptions } from './schema-
|
|
2
|
-
import { V as VectorMaintenanceResult, B as BatchResult, L as ListParams, g as ListResult, I as IndexInfo, f as IndexStats, P as PartitionStatsResult, Q as QueryParams, e as QueryResult, h as PreflightResult, j as SuggestParams, k as SuggestResult } from './memory-
|
|
3
|
-
import { e as TaskRecord, M as MemoryStatsResponse, b as ImportResult, H as HttpIndexConfig, c as TaskListQuery, T as TaskListPage } from './tasks-
|
|
1
|
+
import { P as PartitionConfig, A as AnyDocument, a as InsertOptions, W as WriteOptions } from './schema-Bgzr4g7b.js';
|
|
2
|
+
import { V as VectorMaintenanceResult, B as BatchResult, L as ListParams, g as ListResult, I as IndexInfo, f as IndexStats, P as PartitionStatsResult, Q as QueryParams, e as QueryResult, h as PreflightResult, j as SuggestParams, k as SuggestResult } from './memory-C7UMCMH3.js';
|
|
3
|
+
import { e as TaskRecord, M as MemoryStatsResponse, b as ImportResult, H as HttpIndexConfig, c as TaskListQuery, T as TaskListPage } from './tasks-BZt_zes6.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* This is the `fetch` implementation the client sends every request through.
|