@lde/search-pipeline 0.55.0 → 0.57.0
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 +3 -0
- package/dist/extraction.d.ts.map +1 -1
- package/dist/extraction.js +30 -16
- package/package.json +3 -3
package/dist/extraction.d.ts
CHANGED
|
@@ -51,6 +51,9 @@ export interface ExtractionOptions {
|
|
|
51
51
|
* `OPTIONAL`, so a referent with no key candidate keeps its row. The root side
|
|
52
52
|
* needs nothing: a key field is a declared field, so its own read and
|
|
53
53
|
* template triple are already there.
|
|
54
|
+
* - **searchable references**: a `searchable` reference naming a target reads
|
|
55
|
+
* the referent’s label field the same way, in a hop of its own, so the
|
|
56
|
+
* projection can fold the labels into the referrer’s search companion.
|
|
54
57
|
* - **references naming several targets**: the referent may be of any of them,
|
|
55
58
|
* so its branch also reads the referent’s `rdf:type` (`OPTIONAL`, emitted
|
|
56
59
|
* as is – framing carries it as `@type`), which is what the projection
|
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;AAanC,OAAO,KAAK,EAGV,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"}
|
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, localLookupTargetsOf, referencedTargetsOf, referenceTypeNamed, } from '@lde/search/adapter';
|
|
4
|
+
import { endpointFieldOf, fieldNamed, irAlias, isInlineReference, labelFieldOf, localLookupTargetsOf, referencedTargetsOf, referenceTypeNamed, } from '@lde/search/adapter';
|
|
5
5
|
const factory = new AstFactory();
|
|
6
6
|
const parser = new Parser();
|
|
7
7
|
const generator = new Generator();
|
|
@@ -45,6 +45,9 @@ const RDF_TYPE = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type';
|
|
|
45
45
|
* `OPTIONAL`, so a referent with no key candidate keeps its row. The root side
|
|
46
46
|
* needs nothing: a key field is a declared field, so its own read and
|
|
47
47
|
* template triple are already there.
|
|
48
|
+
* - **searchable references**: a `searchable` reference naming a target reads
|
|
49
|
+
* the referent’s label field the same way, in a hop of its own, so the
|
|
50
|
+
* projection can fold the labels into the referrer’s search companion.
|
|
48
51
|
* - **references naming several targets**: the referent may be of any of them,
|
|
49
52
|
* so its branch also reads the referent’s `rdf:type` (`OPTIONAL`, emitted
|
|
50
53
|
* as is – framing carries it as `@type`), which is what the projection
|
|
@@ -290,11 +293,21 @@ function buildReferentHops(field, referent, schema, counter, onPath) {
|
|
|
290
293
|
// Only where no local expansion follows: a `local` lookup reads the
|
|
291
294
|
// target’s every path-bearing field, and a keyed target’s key field
|
|
292
295
|
// is one of them, so emitting the hop as well would state it twice.
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
296
|
+
// A searchable reference is searched by its referents’ labels, so it
|
|
297
|
+
// reads them off the referent beside the key.
|
|
298
|
+
const hopFields = [
|
|
299
|
+
keyedFieldOf(target),
|
|
300
|
+
// `searchSchema` guarantees a searchable reference’s label a path.
|
|
301
|
+
field.searchable === undefined
|
|
302
|
+
? undefined
|
|
303
|
+
: labelFieldOf(target),
|
|
304
|
+
];
|
|
305
|
+
for (const hopField of hopFields) {
|
|
306
|
+
if (hopField !== undefined) {
|
|
307
|
+
const built = buildFieldHop(target, hopField, referent, counter);
|
|
308
|
+
template.push(built.triple);
|
|
309
|
+
expansions.push(built.pattern);
|
|
310
|
+
}
|
|
298
311
|
}
|
|
299
312
|
continue;
|
|
300
313
|
}
|
|
@@ -345,22 +358,23 @@ function buildTypeHop(referent, counter) {
|
|
|
345
358
|
};
|
|
346
359
|
}
|
|
347
360
|
/**
|
|
348
|
-
* The one-field hop that reads a referent’s key: a template triple
|
|
349
|
-
*
|
|
350
|
-
* referent recursion an inline reference already performs, for a single
|
|
351
|
-
* bound by the caller inside the reference’s `OPTIONAL` union rather
|
|
352
|
-
* conjoined, so a referent with no key candidate keeps its row
|
|
353
|
-
* its own IRI, instead of the whole reference dropping out of
|
|
361
|
+
* The one-field hop that reads a referent’s key or label: a template triple
|
|
362
|
+
* emitting the field under the **target’s** IR Alias, and a branch binding it.
|
|
363
|
+
* The referent recursion an inline reference already performs, for a single
|
|
364
|
+
* field – bound by the caller inside the reference’s `OPTIONAL` union rather
|
|
365
|
+
* than conjoined, so a referent with no key candidate or label keeps its row
|
|
366
|
+
* and still stores its own IRI, instead of the whole reference dropping out of
|
|
367
|
+
* the CONSTRUCT.
|
|
354
368
|
*
|
|
355
369
|
* It is a branch of its own in that union, or a row of its merged plain reads,
|
|
356
370
|
* so it multiplies against nothing.
|
|
357
371
|
*/
|
|
358
|
-
function
|
|
359
|
-
const
|
|
372
|
+
function buildFieldHop(target, hopField, referent, counter) {
|
|
373
|
+
const value = factory.termVariable(`h${counter.next++}`, factory.gen());
|
|
360
374
|
return {
|
|
361
|
-
triple: factory.triple(referent, factory.termNamed(factory.gen(), irAlias(target,
|
|
375
|
+
triple: factory.triple(referent, factory.termNamed(factory.gen(), irAlias(target, hopField)), value),
|
|
362
376
|
pattern: factory.patternGroup([
|
|
363
|
-
factory.patternBgp([factory.triple(referent, liftPath(
|
|
377
|
+
factory.patternBgp([factory.triple(referent, liftPath(hopField.path), value)], factory.gen()),
|
|
364
378
|
], factory.gen()),
|
|
365
379
|
};
|
|
366
380
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lde/search-pipeline",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.57.0",
|
|
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,14 +25,14 @@
|
|
|
25
25
|
"!**/*.tsbuildinfo"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@lde/search": "^0.
|
|
28
|
+
"@lde/search": "^0.45.0",
|
|
29
29
|
"@traqula/generator-sparql-1-1": "^1.3.1",
|
|
30
30
|
"@traqula/parser-sparql-1-1": "^1.3.1",
|
|
31
31
|
"@traqula/rules-sparql-1-1": "^1.2.0",
|
|
32
32
|
"tslib": "^2.3.0"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@lde/search-typesense": "^0.
|
|
35
|
+
"@lde/search-typesense": "^0.60.0",
|
|
36
36
|
"@rdfjs/types": "^2.0.1",
|
|
37
37
|
"n3": "^2.13.12",
|
|
38
38
|
"testcontainers": "^12.1.0",
|