@lde/search-typesense 0.32.4 → 0.33.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-compiler.d.ts","sourceRoot":"","sources":["../src/query-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEzE,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,QAAQ,EAEb,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,UAAU,EAIhB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"query-compiler.d.ts","sourceRoot":"","sources":["../src/query-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEzE,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,QAAQ,EAEb,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,UAAU,EAIhB,MAAM,aAAa,CAAC;AAoBrB;mDACmD;AACnD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,CACvB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,SAAS,MAAM,EAAE,KACpB,UAAU,GAAG,SAAS,CAAC;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC;;;;;;;;OAQG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAC/B;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACrD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,WAAW,EAClB,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,wBAA6B,GACrC,YAAY,CAAC,MAAM,CAAC,CAkCtB;AAggBD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD"}
|
package/dist/query-compiler.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fold } from '@lde/text-normalization';
|
|
2
|
-
import { fieldNamed, filterOperator, filterOperatorFor, ID_FIELD, isoToUnixSeconds, isInternalField, isRangeFacet, isWelded, joinGraph, localLookupTypeOf, pageForOffset, physicalFields, nestedReferenceType, resolvePath, searchableFields, } from '@lde/search/adapter';
|
|
2
|
+
import { fieldNamed, filterOperator, filterOperatorFor, ID_FIELD, isoToUnixSeconds, isInternalField, isRangeFacet, isWelded, joinGraph, localLookupTypeOf, matchLanguage, pageForOffset, physicalFields, nestedReferenceType, resolvePath, searchableFields, } from '@lde/search/adapter';
|
|
3
3
|
/**
|
|
4
4
|
* Compile the engine-neutral {@link SearchQuery} into Typesense search
|
|
5
5
|
* parameters – the query half of the engine adapter. Pure (no client, no env),
|
|
@@ -110,12 +110,13 @@ function collectSearchable(searchType, locale, schema, prefix, onPath, names, we
|
|
|
110
110
|
const baseWeight = field.searchable.weight;
|
|
111
111
|
if (field.kind === 'text') {
|
|
112
112
|
const locales = field.locales;
|
|
113
|
+
const activeLocale = matchLanguage(locale, locales)[0];
|
|
113
114
|
search.forEach((name, index) => {
|
|
114
115
|
names.push(qualify(prefix, name));
|
|
115
116
|
// The active locale keeps full weight; `und` is language-neutral, so
|
|
116
117
|
// it is never demoted (an untagged-only field would otherwise always
|
|
117
118
|
// rank below its declared weight).
|
|
118
|
-
weights.push(locales[index] ===
|
|
119
|
+
weights.push(locales[index] === activeLocale || locales[index] === 'und'
|
|
119
120
|
? baseWeight
|
|
120
121
|
: Math.max(1, baseWeight - 1));
|
|
121
122
|
});
|
|
@@ -444,9 +445,11 @@ function compileSort(sort, searchType, locale) {
|
|
|
444
445
|
}
|
|
445
446
|
const field = fieldNamed(searchType, sort.field);
|
|
446
447
|
if (field !== undefined && field.kind === 'text') {
|
|
447
|
-
// Sort on the
|
|
448
|
-
//
|
|
449
|
-
|
|
448
|
+
// Sort on the key of the declared locale the active one best matches as a
|
|
449
|
+
// language range (`nl-NL` sorts on `nl`), falling back to the first
|
|
450
|
+
// declared locale (e.g. an und-only field sorted by a user in any language).
|
|
451
|
+
const activeLocale = matchLanguage(locale, field.locales)[0];
|
|
452
|
+
const index = activeLocale === undefined ? -1 : field.locales.indexOf(activeLocale);
|
|
450
453
|
const sortName = physicalFields(field).sort[index === -1 ? 0 : index];
|
|
451
454
|
if (sortName !== undefined) {
|
|
452
455
|
return `${sortName}:${sort.direction}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lde/search-typesense",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.33.1",
|
|
4
4
|
"description": "Typesense implementation of the @lde/search SearchEngine port: collection-schema builder, query compiler, label-resolving result reconstruction, and blue/green index lifecycle. Engine-specific (Typesense) but domain-agnostic.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"url": "git+https://github.com/ldelements/lde.git",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"!**/*.tsbuildinfo"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@lde/search": "^0.
|
|
29
|
-
"@lde/text-normalization": "^0.
|
|
28
|
+
"@lde/search": "^0.28.1",
|
|
29
|
+
"@lde/text-normalization": "^0.2.0",
|
|
30
30
|
"tslib": "^2.3.0",
|
|
31
31
|
"typesense": "^3.1.1"
|
|
32
32
|
},
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"testcontainers": "^12.1.0"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@lde/dataset": "^0.
|
|
39
|
-
"@lde/pipeline": "^0.
|
|
38
|
+
"@lde/dataset": "^0.8.0",
|
|
39
|
+
"@lde/pipeline": "^0.37.0"
|
|
40
40
|
}
|
|
41
41
|
}
|