@delali/narsil 0.3.1-next.86 → 0.3.1-next.88
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/browser/chunk-3GZQKGVQ.mjs +2719 -0
- package/dist/browser/chunk-3ZRMZIH4.mjs +3959 -0
- package/dist/browser/chunk-FHFFWLEK.mjs +669 -0
- package/dist/browser/chunk-HOZW3PKP.mjs +9 -0
- package/dist/browser/chunk-JACCR3BJ.mjs +602 -0
- package/dist/browser/chunk-NQW2YXEX.mjs +346 -0
- package/dist/browser/chunk-RAHUQOJL.mjs +24103 -0
- package/dist/browser/durability-wiring-VSUBLUDK.mjs +3250 -0
- package/dist/browser/module-E25UDADM.mjs +2766 -0
- package/dist/browser/snapshot-5MXBEDXF.mjs +888 -0
- package/dist/browser/write-6SBYTS62.mjs +206 -0
- package/dist/{capabilities-CAdkp2P-.d.ts → capabilities-SJPttcgQ.d.ts} +2 -2
- package/dist/chunk-37CD3OKS.mjs +87 -0
- package/dist/{chunk-4VBG6PEH.mjs → chunk-A3UB2MXL.mjs} +175 -124
- package/dist/{chunk-OLXM65YH.mjs → chunk-AV4IJKD2.mjs} +1 -18
- package/dist/{chunk-LS5IRM23.mjs → chunk-BVOJIYRV.mjs} +2 -25
- package/dist/chunk-C7SLA6CM.mjs +19 -0
- package/dist/chunk-CL4OM7GB.mjs +522 -0
- package/dist/{chunk-KJ7LB3TR.mjs → chunk-CVQWQVFX.mjs} +3 -22
- package/dist/{chunk-4D6OH4EF.mjs → chunk-DCK4P5BI.mjs} +32 -32
- package/dist/chunk-DJHHF2L5.mjs +17 -0
- package/dist/{chunk-XPK3GB2P.mjs → chunk-EMXAYPTQ.mjs} +1776 -3336
- package/dist/chunk-FGMGUDHX.mjs +21 -0
- package/dist/{chunk-2453RJYK.mjs → chunk-J2BPXTD7.mjs} +167 -176
- package/dist/chunk-L5ORED7V.mjs +25 -0
- package/dist/chunk-MWJIAREY.mjs +614 -0
- package/dist/chunk-MXS5HWIH.mjs +515 -0
- package/dist/chunk-P36MUFEJ.mjs +10 -0
- package/dist/chunk-PR4O7CAP.mjs +18 -0
- package/dist/{chunk-ZCKPRCYI.mjs → chunk-Q5DC6WAB.mjs} +1 -1
- package/dist/chunk-QAMUC2BJ.mjs +1730 -0
- package/dist/{chunk-NFF5TDRG.mjs → chunk-QZN3MIJ3.mjs} +1 -16
- package/dist/chunk-R6BMMQXH.mjs +7316 -0
- package/dist/chunk-R7OSDAFK.mjs +44 -0
- package/dist/chunk-RVM7AODE.mjs +73 -0
- package/dist/chunk-S4LQDSUL.mjs +462 -0
- package/dist/{chunk-SREPGC6O.mjs → chunk-T6CNO72J.mjs} +1 -1
- package/dist/chunk-UKSUENHK.mjs +997 -0
- package/dist/{chunk-B3F7LZXM.mjs → chunk-ULRPNYAG.mjs} +1220 -2318
- package/dist/{chunk-GNYXCLJS.mjs → chunk-URGLSNKR.mjs} +4 -3
- package/dist/chunk-V7YUSKKZ.mjs +703 -0
- package/dist/chunk-VY4DXZ5P.mjs +631 -0
- package/dist/{chunk-XYDP7CCJ.mjs → chunk-X4SEXL4U.mjs} +54 -14
- package/dist/{chunk-RM6FRYEC.mjs → chunk-XSZVS4S3.mjs} +3 -2
- package/dist/chunk-Y2F66IQJ.mjs +74 -0
- package/dist/chunk-YCJLVNWR.mjs +262 -0
- package/dist/{client-CKUtkLz3.d.ts → client-BMK53IR2.d.ts} +3 -3
- package/dist/client.d.ts +8 -8
- package/dist/{config-CSDEPraV.d.ts → config-BUR-7eVQ.d.ts} +2 -2
- package/dist/{config-BuIkeM5C.d.ts → config-UJx1dyX1.d.ts} +2 -2
- package/dist/direct-executor-EGESD26S.mjs +18 -0
- package/dist/distribution/coordinator/etcd.d.ts +2 -2
- package/dist/distribution/coordinator/in-memory.d.ts +2 -2
- package/dist/distribution.d.ts +8 -8
- package/dist/distribution.mjs +35 -33
- package/dist/durability-wiring-ZLRQU6FG.mjs +2797 -0
- package/dist/{engine-DMNZJAUq.d.ts → engine-9X6W5naj.d.ts} +2 -2
- package/dist/{index-DzONZUKE.d.ts → index-vCMu8OeQ.d.ts} +1 -1
- package/dist/index.browser.mjs +2 -38128
- package/dist/index.d.ts +23 -9
- package/dist/index.mjs +18 -14
- package/dist/{memory-BPKNx9Tl.d.ts → memory-CV9NAxLY.d.ts} +1 -1
- package/dist/module-WIDYIJLY.mjs +1819 -0
- package/dist/partial-words.mjs +5 -3
- package/dist/pattern.mjs +3 -2
- package/dist/persistence/durability/checkpoint-worker.d.ts +1 -1
- package/dist/persistence/durability/checkpoint-worker.mjs +23 -13
- package/dist/react.d.ts +7 -7
- package/dist/{schema-DgyDijhf.d.ts → schema-DtsgmNfU.d.ts} +1 -1
- package/dist/server.d.ts +10 -10
- package/dist/server.mjs +14 -9
- package/dist/snapshot-22CUEYYW.mjs +469 -0
- package/dist/{tasks-DGyz586z.d.ts → tasks-BGaZJyoY.d.ts} +1 -1
- package/dist/{thread-EUUNJNKU.mjs → thread-ZP3UMIZT.mjs} +12 -9
- package/dist/vector/search-worker.d.ts +30 -3
- package/dist/vector/search-worker.mjs +6 -2
- package/dist/workers/entry.mjs +5 -3
- package/dist/write-PXDKPG2R.mjs +233 -0
- package/package.json +17 -8
- package/dist/chunk-IDLP54FH.mjs +0 -15198
- package/dist/direct-executor-SI2QV4YI.mjs +0 -19
- package/dist/simd-DW5AtJ6B.d.ts +0 -41
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { clampRowCount, sortSignatureOf, requireSortableFields, decodePageCursor, requireMatchingCursor,
|
|
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 { clampRowCount, sortSignatureOf, requireSortableFields, resolveProjection, decodePageCursor, requireMatchingCursor, encodePageCursor, requireWithinResultWindow, normalizeSort, fanOutQuery, sortModesOf, applySorting, applyPagination, projectionKeepsField, countsWithoutScores, fanOutMatchCount, fnv1aBytes, validatedFilterOf, createPatternWorkMeter, everyValueFacetConfig, fulltextMatches, mergeFacets, pruneStatsToQueryTerms, partitionsIn, partialWordsToHighlight, partialWordHighlighter, undeclaredFieldOnStrictIndex } from './chunk-X4SEXL4U.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-Q5DC6WAB.mjs';
|
|
3
3
|
import { MIN_OVERSAMPLE } from './chunk-ZJ4CSAB2.mjs';
|
|
4
|
-
import { tokenize } from './chunk-
|
|
5
|
-
import { partialFieldsOf,
|
|
4
|
+
import { tokenize } from './chunk-A3UB2MXL.mjs';
|
|
5
|
+
import { partialFieldsOf, flattenSchema } from './chunk-CVQWQVFX.mjs';
|
|
6
|
+
import { DEFAULT_MAX_PER_GROUP, DEFAULT_LINEAR_ALPHA, MIN_LINEAR_ALPHA, MAX_LINEAR_ALPHA, DEFAULT_RANK_CONSTANT, MIN_RANK_CONSTANT, DEFAULT_FUZZY_PREFIX_LENGTH, RESULT_WINDOW, MAX_TOLERANCE, MAX_PREFIX_LENGTH } from './chunk-FGMGUDHX.mjs';
|
|
6
7
|
import { fuzzyTermMatches } from './chunk-GES7U2PM.mjs';
|
|
7
|
-
import {
|
|
8
|
+
import { isWordIndexedFieldType } from './chunk-BVOJIYRV.mjs';
|
|
8
9
|
import { compareComparableKeys } from './chunk-R6A773WK.mjs';
|
|
9
10
|
import { holdsUnpairedSurrogate, compareCodePoints } from './chunk-YTJCGKM4.mjs';
|
|
11
|
+
import { MIN_PATTERN_VALUE_LIMIT, MAX_PATTERN_VALUE_LIMIT, isGeopointOrVectorType, VECTOR_PATTERN } from './chunk-L5ORED7V.mjs';
|
|
10
12
|
import { NarsilError, ErrorCodes } from './chunk-TPJU7NDJ.mjs';
|
|
11
13
|
|
|
12
14
|
// src/search/cursor-binding.ts
|
|
@@ -218,18 +220,27 @@ function requireFacetableFields(facets, flatSchema, strict) {
|
|
|
218
220
|
}
|
|
219
221
|
}
|
|
220
222
|
}
|
|
221
|
-
function
|
|
223
|
+
function requireGroupableFields(fields, flatSchema, strict) {
|
|
222
224
|
for (const field of fields) {
|
|
223
|
-
|
|
225
|
+
const fieldType = flatSchema[field];
|
|
226
|
+
if (strict && fieldType === void 0) throw undeclaredFieldOnStrictIndex(field, "group");
|
|
227
|
+
if (fieldType !== void 0 && VECTOR_PATTERN.test(fieldType)) {
|
|
228
|
+
throw new NarsilError(
|
|
229
|
+
ErrorCodes.SEARCH_INVALID_FIELD,
|
|
230
|
+
`The engine groups hits by a text, number, boolean, enum, or geopoint field, and the schema declares field "${field}" as "${fieldType}"`,
|
|
231
|
+
{ field, fieldType }
|
|
232
|
+
);
|
|
233
|
+
}
|
|
224
234
|
}
|
|
225
235
|
}
|
|
226
236
|
function requireUsableQueryFields(params, schema, strict = false) {
|
|
227
|
-
const
|
|
237
|
+
const groupFields = params.group?.fields;
|
|
238
|
+
const checksGroup = Array.isArray(groupFields) && groupFields.length > 0;
|
|
228
239
|
if (params.boost === void 0 && params.facets === void 0 && !checksGroup) return;
|
|
229
240
|
const flatSchema = flattenSchema(schema);
|
|
230
241
|
if (params.boost !== void 0) requireBoostableFields(params.boost, flatSchema);
|
|
231
242
|
if (params.facets !== void 0) requireFacetableFields(params.facets, flatSchema, strict);
|
|
232
|
-
if (checksGroup
|
|
243
|
+
if (checksGroup) requireGroupableFields(groupFields, flatSchema, strict);
|
|
233
244
|
}
|
|
234
245
|
|
|
235
246
|
// src/search/typo-tolerance.ts
|
|
@@ -628,6 +639,7 @@ function executeListDocuments(params, context) {
|
|
|
628
639
|
const signature = sortSignatureOf(params.sort);
|
|
629
640
|
requireSortableFields(params.sort, schema, context.strict === true);
|
|
630
641
|
const filters = validQueryFilter(params.filters, schema);
|
|
642
|
+
const projection = resolveProjection(params.document);
|
|
631
643
|
const binding = listBindingOf(params.filters);
|
|
632
644
|
let cursor = null;
|
|
633
645
|
if (params.cursor !== void 0) {
|
|
@@ -638,7 +650,6 @@ function executeListDocuments(params, context) {
|
|
|
638
650
|
const filtered = filters === void 0 ? null : collectFilterMatches(partitions, filters, schema, context.patternWorkCap);
|
|
639
651
|
const total = filtered === null ? countAcrossPartitions(manager, context.partitionIds, partitions) : filtered.total;
|
|
640
652
|
const page = params.sort === void 0 || signature === null ? pageInIdOrder(partitions, cursor, filtered, limit, binding) : pageInSortOrder(partitions, cursor, filtered, limit, params.sort, signature, schema, binding);
|
|
641
|
-
const projection = resolveProjection(params.document);
|
|
642
653
|
const documents = [];
|
|
643
654
|
for (const docId of page.ids) {
|
|
644
655
|
if (projection.kind === "none") {
|
|
@@ -661,37 +672,23 @@ function executeListDocuments(params, context) {
|
|
|
661
672
|
}
|
|
662
673
|
|
|
663
674
|
// src/search/grouping.ts
|
|
664
|
-
function getNestedValue(obj, path) {
|
|
665
|
-
const segments = path.split(".");
|
|
666
|
-
let current = obj;
|
|
667
|
-
for (const segment of segments) {
|
|
668
|
-
if (current === null || current === void 0 || typeof current !== "object") {
|
|
669
|
-
return void 0;
|
|
670
|
-
}
|
|
671
|
-
if (!Object.hasOwn(current, segment)) {
|
|
672
|
-
return void 0;
|
|
673
|
-
}
|
|
674
|
-
current = current[segment];
|
|
675
|
-
}
|
|
676
|
-
return current;
|
|
677
|
-
}
|
|
678
675
|
function hitsKeptPerGroup(maxPerGroup) {
|
|
679
676
|
if (maxPerGroup === void 0 || !Number.isFinite(maxPerGroup) || maxPerGroup < 1) return DEFAULT_MAX_PER_GROUP;
|
|
680
677
|
return Math.floor(maxPerGroup);
|
|
681
678
|
}
|
|
682
|
-
function applyGrouping(hits, group,
|
|
679
|
+
function applyGrouping(hits, group, documents) {
|
|
683
680
|
if (!group.fields || group.fields.length === 0) {
|
|
684
681
|
return [{ values: {}, hits }];
|
|
685
682
|
}
|
|
686
683
|
const groupMap = /* @__PURE__ */ new Map();
|
|
687
684
|
for (const hit of hits) {
|
|
688
|
-
const
|
|
685
|
+
const stored = documents.fieldValues(hit.id, group.fields);
|
|
689
686
|
const fieldValues = [];
|
|
690
687
|
const valuesRecord = {};
|
|
691
|
-
for (
|
|
692
|
-
const value =
|
|
688
|
+
for (let at = 0; at < group.fields.length; at++) {
|
|
689
|
+
const value = stored?.[at];
|
|
693
690
|
fieldValues.push(value);
|
|
694
|
-
valuesRecord[
|
|
691
|
+
valuesRecord[group.fields[at]] = value;
|
|
695
692
|
}
|
|
696
693
|
const compositeKey = JSON.stringify(fieldValues);
|
|
697
694
|
const existing = groupMap.get(compositeKey);
|
|
@@ -709,7 +706,7 @@ function applyGrouping(hits, group, getDocument) {
|
|
|
709
706
|
if (group.reduce) {
|
|
710
707
|
const folded = foldGroupReducer(
|
|
711
708
|
group.reduce,
|
|
712
|
-
everyHit.map((hit) => ({ document:
|
|
709
|
+
everyHit.map((hit) => ({ document: documents.document(hit.id), score: hit.score ?? 0 }))
|
|
713
710
|
);
|
|
714
711
|
if (folded.reducerError !== void 0) {
|
|
715
712
|
result.reducerError = folded.reducerError;
|
|
@@ -1357,6 +1354,7 @@ async function executeQuery(request, callerContext) {
|
|
|
1357
1354
|
}
|
|
1358
1355
|
const params = validQueryParams(request, config);
|
|
1359
1356
|
requireVectorSearchable(params, context, isVectorOnly || isHybridMode);
|
|
1357
|
+
const projection = resolveProjection(params.document);
|
|
1360
1358
|
let paginated;
|
|
1361
1359
|
let nextCursor;
|
|
1362
1360
|
let count;
|
|
@@ -1440,7 +1438,10 @@ async function executeQuery(request, callerContext) {
|
|
|
1440
1438
|
hits = applySorting(hits, params.sort, sortKeyOf);
|
|
1441
1439
|
}
|
|
1442
1440
|
if (params.group) {
|
|
1443
|
-
groups = applyGrouping(hits, params.group,
|
|
1441
|
+
groups = applyGrouping(hits, params.group, {
|
|
1442
|
+
fieldValues: (docId, fieldPaths) => manager.fieldValues(docId, fieldPaths),
|
|
1443
|
+
document: (docId) => manager.getRef(docId)
|
|
1444
|
+
});
|
|
1444
1445
|
}
|
|
1445
1446
|
let pinsFromOutside = 0;
|
|
1446
1447
|
if (params.pinned && params.searchAfter === void 0 && context.partitionIds === void 0) {
|
|
@@ -1480,7 +1481,6 @@ async function executeQuery(request, callerContext) {
|
|
|
1480
1481
|
for (const hit of hits) hit.score = void 0;
|
|
1481
1482
|
}
|
|
1482
1483
|
}
|
|
1483
|
-
const projection = resolveProjection(params.document);
|
|
1484
1484
|
if (projection.kind === "none") {
|
|
1485
1485
|
for (const hit of paginated) {
|
|
1486
1486
|
hit.document = {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/vector/native/backend.ts
|
|
2
|
+
var nativeSearchCoreEnabled = true;
|
|
3
|
+
function nativeSearchCoreIsEnabled() {
|
|
4
|
+
return nativeSearchCoreEnabled;
|
|
5
|
+
}
|
|
6
|
+
function stopUsingTheNativeSearchCore(error) {
|
|
7
|
+
if (!nativeSearchCoreEnabled) return;
|
|
8
|
+
nativeSearchCoreEnabled = false;
|
|
9
|
+
console.warn(
|
|
10
|
+
"The native search core raised an error, so this thread searches through WebAssembly from now on:",
|
|
11
|
+
error instanceof Error ? error.message : String(error)
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
function noteFallback(operation) {
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { nativeSearchCoreIsEnabled, noteFallback, stopUsingTheNativeSearchCore };
|