@lde/search-typesense 0.29.1 → 0.29.3
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/search.js +13 -11
- package/package.json +2 -2
package/dist/search.js
CHANGED
|
@@ -694,31 +694,33 @@ function nestedValue(raw, field, referenceType, labels, schema, children) {
|
|
|
694
694
|
}
|
|
695
695
|
/**
|
|
696
696
|
* Rebuild a {@link ReferenceStrategy.local local} lookup: the endpoint’s own
|
|
697
|
-
* document as this document stated it,
|
|
697
|
+
* document as this document stated it, **replaced** by the resolved document
|
|
698
698
|
* where the lookup found one.
|
|
699
699
|
*
|
|
700
|
-
*
|
|
701
|
-
*
|
|
702
|
-
*
|
|
703
|
-
*
|
|
700
|
+
* Replaced rather than merged, because both sides are the target type’s flat
|
|
701
|
+
* physical shape and a logical field fans out into several physical ones: a
|
|
702
|
+
* name this document stated in one language would survive beside the target’s
|
|
703
|
+
* name in another, and a field the target’s record does not carry would
|
|
704
|
+
* survive after the target dropped it. The resolved document carries what the
|
|
705
|
+
* projection asked for, and a resolved entry says exactly that – what a plain
|
|
706
|
+
* lookup says too. Three cases fall out of one expression, which is the point
|
|
707
|
+
* of storing local fields unconditionally:
|
|
704
708
|
*
|
|
705
|
-
* - identified and indexed → the target’s own record
|
|
709
|
+
* - identified and indexed → the target’s own record;
|
|
706
710
|
* - identified but not indexed → what was stated here, plus the `id`, rather
|
|
707
711
|
* than a bare IRI;
|
|
708
712
|
* - not identified → what was stated here, with no `id` at all.
|
|
709
713
|
*/
|
|
710
714
|
function localLookupValue(raw, field, target, resolved, labels, schema) {
|
|
711
715
|
const fetched = resolved?.via === 'lookup' ? resolved.documents : new Map();
|
|
712
|
-
const
|
|
716
|
+
const entries = (Array.isArray(raw) ? raw : [raw])
|
|
713
717
|
.filter((entry) => typeof entry === 'object' && entry !== null)
|
|
714
718
|
.map((entry) => {
|
|
715
719
|
const id = typeof entry.id === 'string' ? entry.id : undefined;
|
|
716
720
|
const authoritative = id === undefined ? undefined : fetched.get(id);
|
|
717
|
-
return authoritative
|
|
718
|
-
? entry
|
|
719
|
-
: { ...entry, ...authoritative };
|
|
721
|
+
return authoritative ?? entry;
|
|
720
722
|
});
|
|
721
|
-
return nestedValue(
|
|
723
|
+
return nestedValue(entries, field, target, labels, schema, resolved?.children);
|
|
722
724
|
}
|
|
723
725
|
/**
|
|
724
726
|
* Rebuild a resolved `lookup` reference: each stored IRI becomes the referent’s
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lde/search-typesense",
|
|
3
|
-
"version": "0.29.
|
|
3
|
+
"version": "0.29.3",
|
|
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,7 +25,7 @@
|
|
|
25
25
|
"!**/*.tsbuildinfo"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@lde/search": "^0.24.
|
|
28
|
+
"@lde/search": "^0.24.3",
|
|
29
29
|
"@lde/text-normalization": "^0.1.2",
|
|
30
30
|
"tslib": "^2.3.0",
|
|
31
31
|
"typesense": "^3.0.6"
|