@lde/search-pipeline 0.63.2 → 0.64.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.
- package/dist/extraction.d.ts +6 -4
- package/dist/extraction.d.ts.map +1 -1
- package/dist/extraction.js +19 -13
- package/dist/search-stages.d.ts.map +1 -1
- package/dist/search-stages.js +21 -9
- package/package.json +3 -3
package/dist/extraction.d.ts
CHANGED
|
@@ -70,11 +70,13 @@ export declare function extractionQueryString(searchType: SearchType, schema: Se
|
|
|
70
70
|
/**
|
|
71
71
|
* The fields a reference reads off a referent of a target it does not expand
|
|
72
72
|
* `local`ly: the target’s key field, where it is keyed; – for a `searchable`
|
|
73
|
-
* reference
|
|
74
|
-
* the reference’s presence leaves, whose
|
|
75
|
-
* holds one. Each field once, though it
|
|
73
|
+
* reference, or a root document’s reference whose facet is searched by label
|
|
74
|
+
* – its label field; and each of the reference’s presence leaves, whose
|
|
75
|
+
* companions say whether any referent holds one. Each field once, though it
|
|
76
|
+
* plays several of these parts. `root` says whether the field is the root
|
|
77
|
+
* type’s own, the only place the label-match companion is written.
|
|
76
78
|
*/
|
|
77
|
-
export declare function referentHopFields(field: SearchField, target: RootType): PathField[];
|
|
79
|
+
export declare function referentHopFields(field: SearchField, target: RootType, schema: SearchSchema, root: boolean): PathField[];
|
|
78
80
|
/** A field the extraction reads off a referent: path-bearing. */
|
|
79
81
|
type PathField = SearchField & {
|
|
80
82
|
readonly path: string;
|
package/dist/extraction.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extraction.d.ts","sourceRoot":"","sources":["../src/extraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,cAAc,EAKpB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"extraction.d.ts","sourceRoot":"","sources":["../src/extraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,cAAc,EAKpB,MAAM,2BAA2B,CAAC;AAenC,OAAO,KAAK,EACV,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,UAAU,EACX,MAAM,aAAa,CAAC;AAQrB,2CAA2C;AAC3C,MAAM,WAAW,iBAAiB;IAChC;;;;;;;OAOG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,iBAAsB,GAC9B,cAAc,CA2BhB;AAED,+EAA+E;AAC/E,wBAAgB,qBAAqB,CACnC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,YAAY,EACpB,OAAO,CAAC,EAAE,iBAAiB,GAC1B,MAAM,CAER;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,QAAQ,EAChB,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,OAAO,GACZ,SAAS,EAAE,CAeb;AA0YD,iEAAiE;AACjE,KAAK,SAAS,GAAG,WAAW,GAAG;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
package/dist/extraction.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AstFactory, } from '@traqula/rules-sparql-1-1';
|
|
2
2
|
import { Parser } from '@traqula/parser-sparql-1-1';
|
|
3
3
|
import { Generator } from '@traqula/generator-sparql-1-1';
|
|
4
|
-
import { endpointFieldOf, fieldNamed, irAlias, isInlineReference, labelFieldOf, localLookupTargetsOf, physicalFields, referencedTargetsOf, referenceTypeNamed, } from '@lde/search/adapter';
|
|
4
|
+
import { endpointFieldOf, facetMatchesLabels, fieldNamed, irAlias, isInlineReference, labelFieldOf, localLookupTargetsOf, physicalFields, referencedTargetsOf, referenceTypeNamed, } from '@lde/search/adapter';
|
|
5
5
|
const factory = new AstFactory();
|
|
6
6
|
const parser = new Parser();
|
|
7
7
|
const generator = new Generator();
|
|
@@ -78,17 +78,21 @@ export function extractionQueryString(searchType, schema, options) {
|
|
|
78
78
|
/**
|
|
79
79
|
* The fields a reference reads off a referent of a target it does not expand
|
|
80
80
|
* `local`ly: the target’s key field, where it is keyed; – for a `searchable`
|
|
81
|
-
* reference
|
|
82
|
-
* the reference’s presence leaves, whose
|
|
83
|
-
* holds one. Each field once, though it
|
|
81
|
+
* reference, or a root document’s reference whose facet is searched by label
|
|
82
|
+
* – its label field; and each of the reference’s presence leaves, whose
|
|
83
|
+
* companions say whether any referent holds one. Each field once, though it
|
|
84
|
+
* plays several of these parts. `root` says whether the field is the root
|
|
85
|
+
* type’s own, the only place the label-match companion is written.
|
|
84
86
|
*/
|
|
85
|
-
export function referentHopFields(field, target) {
|
|
87
|
+
export function referentHopFields(field, target, schema, root) {
|
|
86
88
|
const hopFields = [
|
|
87
89
|
keyedFieldOf(target),
|
|
88
|
-
// `searchSchema` guarantees a searchable reference’s label a path
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
90
|
+
// `searchSchema` guarantees a searchable reference’s label a path, and
|
|
91
|
+
// `facetMatchesLabels` admits only labels with one.
|
|
92
|
+
field.searchable !== undefined ||
|
|
93
|
+
(root && facetMatchesLabels(field, schema))
|
|
94
|
+
? labelFieldOf(target)
|
|
95
|
+
: undefined,
|
|
92
96
|
// …and a lookup’s target each presence leaf, with a path.
|
|
93
97
|
...physicalFields(field).leafExists.map(({ leaf }) => fieldNamed(target, leaf)),
|
|
94
98
|
].filter((hopField) => hopField !== undefined);
|
|
@@ -113,6 +117,8 @@ function buildFor(searchType, subject, schema, counter, visiting) {
|
|
|
113
117
|
const template = [];
|
|
114
118
|
const branches = [];
|
|
115
119
|
const onPath = new Set(visiting).add(searchType.name);
|
|
120
|
+
// The root type’s own fields, at the top of the recursion.
|
|
121
|
+
const root = visiting.size === 0;
|
|
116
122
|
for (const field of searchType.fields) {
|
|
117
123
|
if (field.path === undefined) {
|
|
118
124
|
continue;
|
|
@@ -140,7 +146,7 @@ function buildFor(searchType, subject, schema, counter, visiting) {
|
|
|
140
146
|
const typeHop = buildTypeHop(referent, counter);
|
|
141
147
|
template.push(typeHop.triple);
|
|
142
148
|
nestedBranches.push(typeHop.pattern);
|
|
143
|
-
const hops = buildReferentHops(endpointField, referent, schema, counter, onPath);
|
|
149
|
+
const hops = buildReferentHops(endpointField, referent, schema, counter, onPath, false);
|
|
144
150
|
template.push(...hops.template);
|
|
145
151
|
nestedBranches.push(...hops.expansions);
|
|
146
152
|
}
|
|
@@ -175,7 +181,7 @@ function buildFor(searchType, subject, schema, counter, visiting) {
|
|
|
175
181
|
template.push(typeHop.triple);
|
|
176
182
|
expansions.push(typeHop.pattern);
|
|
177
183
|
}
|
|
178
|
-
const hops = buildReferentHops(field, value, schema, counter, onPath);
|
|
184
|
+
const hops = buildReferentHops(field, value, schema, counter, onPath, root);
|
|
179
185
|
template.push(...hops.template);
|
|
180
186
|
expansions.push(...hops.expansions);
|
|
181
187
|
// `OPTIONAL`, unlike an inline reference’s conjoined nesting: this
|
|
@@ -302,7 +308,7 @@ function plainReadOf(branch, template) {
|
|
|
302
308
|
* {@link mergePlainReads} has folded the plain ones into a `VALUES` table, whose
|
|
303
309
|
* rows each bind one read too.
|
|
304
310
|
*/
|
|
305
|
-
function buildReferentHops(field, referent, schema, counter, onPath) {
|
|
311
|
+
function buildReferentHops(field, referent, schema, counter, onPath, root) {
|
|
306
312
|
const template = [];
|
|
307
313
|
const expansions = [];
|
|
308
314
|
const targets = referencedTargetsOf(field, schema);
|
|
@@ -314,7 +320,7 @@ function buildReferentHops(field, referent, schema, counter, onPath) {
|
|
|
314
320
|
// is one of them, so emitting the hop as well would state it twice.
|
|
315
321
|
// A searchable reference is searched by its referents’ labels, so it
|
|
316
322
|
// reads them off the referent beside the key.
|
|
317
|
-
for (const hopField of referentHopFields(field, target)) {
|
|
323
|
+
for (const hopField of referentHopFields(field, target, schema, root)) {
|
|
318
324
|
const built = buildFieldHop(target, hopField, referent, counter);
|
|
319
325
|
template.push(built.triple);
|
|
320
326
|
expansions.push(built.pattern);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-stages.d.ts","sourceRoot":"","sources":["../src/search-stages.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,EAEL,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,KAAK,QAAQ,EAGb,KAAK,YAAY,EAElB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"search-stages.d.ts","sourceRoot":"","sources":["../src/search-stages.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,EAEL,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAGL,KAAK,QAAQ,EAGb,KAAK,YAAY,EAElB,MAAM,aAAa,CAAC;AAYrB,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,kDAAkD;AAClD,MAAM,WAAW,eAAe;IAC9B;;;;;;OAMG;IACH,UAAU,EAAE,QAAQ,CAAC;IACrB;;;;;OAKG;IACH,YAAY,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,YAAY,EAAE,YAAY,CAAC;IAC3B;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,SAAS,CAAC,EAAE,aAAa,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC,aAAa,CAAC,EAAE,CAAC;IAC1E;;;;;OAKG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC,mBAAmB,CAAC,CAAC,WAAW,CAAC,CAAC;IAC3D;;;;;;;;;;;OAWG;IACH,SAAS,CAAC,EAAE,YAAY,CAAC,mBAAmB,CAAC,CAAC,WAAW,CAAC,CAAC;IAC3D,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,wCAAwC;AACxC,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,MAAM,EAAE,YAAY,CAAC;IACrB,4DAA4D;IAC5D,KAAK,EAAE,SAAS,eAAe,EAAE,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,mBAAmB,GAC3B,KAAK,CAAC,mBAAmB,CAAC,EAAE,CAyH9B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,wBAAgB,aAAa,CAC3B,UAAU,EAAE,QAAQ,EACpB,YAAY,SAAS,EACrB,OAAO,CAAC,EAAE,MAAM,GACf,YAAY,CAWd;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,GAAG,GACZ,WAAW,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAK3C;AAED,iEAAiE;AACjE,eAAO,MAAM,gBAAgB;;;CAA2C,CAAC"}
|
package/dist/search-stages.js
CHANGED
|
@@ -2,7 +2,7 @@ import { DataFactory } from 'n3';
|
|
|
2
2
|
import { Distribution } from '@lde/dataset';
|
|
3
3
|
import { SparqlConstructReader, SparqlItemSelector, Stage, } from '@lde/pipeline';
|
|
4
4
|
import { projectRoots, } from '@lde/search';
|
|
5
|
-
import { endpointFieldOf, irAlias, physicalFields, isInlineReference, referencedTargetsOf, referenceTypeNamed, } from '@lde/search/adapter';
|
|
5
|
+
import { endpointFieldOf, facetMatchesLabels, irAlias, localLookupTargetsOf, physicalFields, isInlineReference, referencedTargetsOf, referenceTypeNamed, } from '@lde/search/adapter';
|
|
6
6
|
import { extractionQueryString, referentHopFields } from './extraction.js';
|
|
7
7
|
/**
|
|
8
8
|
* Compose one projecting {@link Stage} per root type – the source side of a
|
|
@@ -256,7 +256,7 @@ function referentTransforms(searchType, schema, transformsByClass) {
|
|
|
256
256
|
// Per reference counting presence leaves: the one target (`searchSchema`
|
|
257
257
|
// refuses several) its referents named by IRI alone are seeded through.
|
|
258
258
|
const countedTargetByField = new Map();
|
|
259
|
-
for (const { alias, field } of describedReferences(searchType, schema)) {
|
|
259
|
+
for (const { alias, field, root } of describedReferences(searchType, schema, true)) {
|
|
260
260
|
for (const target of referencedTargetsOf(field, schema)) {
|
|
261
261
|
if (transformsByClass.get(target.class) === undefined) {
|
|
262
262
|
continue;
|
|
@@ -274,7 +274,7 @@ function referentTransforms(searchType, schema, transformsByClass) {
|
|
|
274
274
|
aliases: new Set(),
|
|
275
275
|
};
|
|
276
276
|
route.fields.add(alias);
|
|
277
|
-
for (const hopField of referentHopFields(field, target)) {
|
|
277
|
+
for (const hopField of referentHopFields(field, target, schema, root)) {
|
|
278
278
|
route.aliases.add(irAlias(target, hopField));
|
|
279
279
|
}
|
|
280
280
|
routes.set(target, route);
|
|
@@ -375,30 +375,42 @@ function referentTransforms(searchType, schema, transformsByClass) {
|
|
|
375
375
|
const factory = DataFactory;
|
|
376
376
|
const RDF_TYPE = factory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type');
|
|
377
377
|
/** The type’s reference fields whose referents are described – `searchable`
|
|
378
|
-
* ones,
|
|
378
|
+
* ones, a root type’s own whose facet is searched by label (not a `local` lookup’s, which
|
|
379
|
+
* reads its referents through the target’s whole declaration), and lookups
|
|
380
|
+
* declaring presence leaves – each with the IR Alias whose
|
|
379
381
|
* objects are its referents: its own, and those of the inline referents it
|
|
380
382
|
* nests. A graph that leaves an edge out points at the endpoint through the
|
|
381
383
|
* inline field itself, so an endpoint field is reached through both.
|
|
382
384
|
* `searchSchema` refuses an inline cycle, so the descent ends. */
|
|
383
|
-
function describedReferences(owner, schema) {
|
|
385
|
+
function describedReferences(owner, schema, root) {
|
|
384
386
|
return owner.fields.flatMap((field) => {
|
|
385
387
|
if (isInlineReference(field)) {
|
|
386
388
|
// Guaranteed declared: `searchSchema` resolves every inline `typeName`.
|
|
387
389
|
const referenceType = referenceTypeNamed(schema, field.ref.typeName);
|
|
388
390
|
const endpointField = endpointFieldOf(referenceType, field.ref.identity);
|
|
389
391
|
return [
|
|
390
|
-
...describedReferences(referenceType, schema),
|
|
392
|
+
...describedReferences(referenceType, schema, false),
|
|
391
393
|
...(endpointField?.searchable === undefined
|
|
392
394
|
? []
|
|
393
|
-
: [
|
|
395
|
+
: [
|
|
396
|
+
{
|
|
397
|
+
alias: irAlias(owner, field),
|
|
398
|
+
field: endpointField,
|
|
399
|
+
root: false,
|
|
400
|
+
},
|
|
401
|
+
]),
|
|
394
402
|
];
|
|
395
403
|
}
|
|
396
404
|
// A reference’s referents are described when it is searched by their
|
|
397
|
-
// labels, or counted for a presence
|
|
405
|
+
// labels, a root document’s facet is, or they are counted for a presence
|
|
406
|
+
// leaf.
|
|
398
407
|
return field.kind === 'reference' &&
|
|
399
408
|
(field.searchable !== undefined ||
|
|
409
|
+
(root &&
|
|
410
|
+
facetMatchesLabels(field, schema) &&
|
|
411
|
+
localLookupTargetsOf(field, schema).length === 0) ||
|
|
400
412
|
physicalFields(field).leafExists.length > 0)
|
|
401
|
-
? [{ alias: irAlias(owner, field), field }]
|
|
413
|
+
? [{ alias: irAlias(owner, field), field, root }]
|
|
402
414
|
: [];
|
|
403
415
|
});
|
|
404
416
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lde/search-pipeline",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.64.1",
|
|
4
4
|
"description": "Search indexing as an @lde/pipeline instance: a Writer<Quad> that applies the @lde/search projection to extracted RDF and fans each document out to the transactional engine writer for its type's collection. Glue between the pipeline quad world and the search-engine document world; owns no projection or engine logic itself.",
|
|
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.
|
|
28
|
+
"@lde/search": "^0.50.1",
|
|
29
29
|
"@rdfjs/types": "^2.0.1",
|
|
30
30
|
"@traqula/generator-sparql-1-1": "^1.3.1",
|
|
31
31
|
"@traqula/parser-sparql-1-1": "^1.3.1",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"tslib": "^2.3.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@lde/search-typesense": "^0.
|
|
37
|
+
"@lde/search-typesense": "^0.66.1",
|
|
38
38
|
"testcontainers": "^12.1.0",
|
|
39
39
|
"typesense": "^3.2.0"
|
|
40
40
|
},
|