@lde/search-pipeline 0.40.2 → 0.40.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/extraction.d.ts.map +1 -1
- package/dist/extraction.js +57 -29
- package/package.json +3 -3
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,EAIpB,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"extraction.d.ts","sourceRoot":"","sources":["../src/extraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,cAAc,EAIpB,MAAM,2BAA2B,CAAC;AAYnC,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,iBAAsB,GAC9B,cAAc,CAqBhB;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 { fieldNamed, irAlias, isInlineReference, localLookupTargetsOf, referencedTargetsOf, referenceTypeNamed, } from '@lde/search/adapter';
|
|
4
|
+
import { endpointFieldOf, fieldNamed, irAlias, isInlineReference, 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();
|
|
@@ -101,13 +101,29 @@ function buildFor(searchType, subject, schema, counter, visiting) {
|
|
|
101
101
|
template.push(factory.triple(subject, alias, referent));
|
|
102
102
|
const nested = buildFor(referenceType, referent, schema, counter, onPath);
|
|
103
103
|
template.push(...nested.template);
|
|
104
|
+
const nestedBranches = [...nested.branches];
|
|
105
|
+
// A graph that may leave the edge out: the node the work points at may be
|
|
106
|
+
// the endpoint itself, so its type – which tells the two apart – and the
|
|
107
|
+
// endpoint’s own selection are read right here, beside the edge’s fields.
|
|
108
|
+
const endpointField = endpointFieldOf(referenceType, field.ref.identity);
|
|
109
|
+
if (endpointField !== undefined) {
|
|
110
|
+
// An empty branch: an endpoint the graph says nothing else about keeps
|
|
111
|
+
// its row, and so its id, as it would inside an edge.
|
|
112
|
+
nestedBranches.push(factory.patternGroup([], factory.gen()));
|
|
113
|
+
const typeHop = buildTypeHop(referent, counter);
|
|
114
|
+
template.push(typeHop.triple);
|
|
115
|
+
nestedBranches.push(typeHop.pattern);
|
|
116
|
+
const hops = buildReferentHops(endpointField, referent, schema, counter, onPath);
|
|
117
|
+
template.push(...hops.template);
|
|
118
|
+
nestedBranches.push(...hops.expansions);
|
|
119
|
+
}
|
|
104
120
|
const patterns = [
|
|
105
121
|
factory.patternBgp([factory.triple(subject, sourcePath, referent)], factory.gen()),
|
|
106
122
|
];
|
|
107
123
|
// A single-branch union serialises to just its group, so only add the
|
|
108
124
|
// nested union when the reference type has fields of its own.
|
|
109
|
-
if (
|
|
110
|
-
patterns.push(factory.patternUnion(
|
|
125
|
+
if (nestedBranches.length > 0) {
|
|
126
|
+
patterns.push(factory.patternUnion(nestedBranches, factory.gen()));
|
|
111
127
|
}
|
|
112
128
|
branches.push(factory.patternGroup(patterns, factory.gen()));
|
|
113
129
|
}
|
|
@@ -117,34 +133,16 @@ function buildFor(searchType, subject, schema, counter, visiting) {
|
|
|
117
133
|
const patterns = [
|
|
118
134
|
factory.patternBgp([factory.triple(subject, sourcePath, value)], factory.gen()),
|
|
119
135
|
];
|
|
120
|
-
|
|
121
|
-
// Every hop off the referent – its type, each key, each expansion – is
|
|
122
|
-
// its own branch of ONE optional union: each binds only its own
|
|
123
|
-
// variables, so a multi-valued type or key multiplies against nothing.
|
|
136
|
+
// The type tells several targets apart; one target needs none.
|
|
124
137
|
const expansions = [];
|
|
125
|
-
if (
|
|
126
|
-
const
|
|
127
|
-
template.push(
|
|
128
|
-
expansions.push(
|
|
129
|
-
}
|
|
130
|
-
const local = localTargetsOf(field, schema, onPath);
|
|
131
|
-
for (const target of targets) {
|
|
132
|
-
if (!local.includes(target)) {
|
|
133
|
-
// Only where no local expansion follows: a `local` lookup reads the
|
|
134
|
-
// target’s every path-bearing field, and a keyed target’s key field
|
|
135
|
-
// is one of them, so emitting the hop as well would state it twice.
|
|
136
|
-
const keyed = keyedFieldOf(target);
|
|
137
|
-
if (keyed !== undefined) {
|
|
138
|
-
const built = buildKeyHop(target, keyed, value, counter);
|
|
139
|
-
template.push(built.triple);
|
|
140
|
-
expansions.push(built.pattern);
|
|
141
|
-
}
|
|
142
|
-
continue;
|
|
143
|
-
}
|
|
144
|
-
const nested = buildFor(target, value, schema, counter, onPath);
|
|
145
|
-
template.push(...nested.template);
|
|
146
|
-
expansions.push(...nested.branches);
|
|
138
|
+
if (referencedTargetsOf(field, schema).length > 1) {
|
|
139
|
+
const typeHop = buildTypeHop(value, counter);
|
|
140
|
+
template.push(typeHop.triple);
|
|
141
|
+
expansions.push(typeHop.pattern);
|
|
147
142
|
}
|
|
143
|
+
const hops = buildReferentHops(field, value, schema, counter, onPath);
|
|
144
|
+
template.push(...hops.template);
|
|
145
|
+
expansions.push(...hops.expansions);
|
|
148
146
|
// `OPTIONAL`, unlike an inline reference’s conjoined nesting: this
|
|
149
147
|
// referent is stored by id whether or not the referring document says
|
|
150
148
|
// anything about it, and conjoining would drop both together. Several
|
|
@@ -159,6 +157,36 @@ function buildFor(searchType, subject, schema, counter, visiting) {
|
|
|
159
157
|
}
|
|
160
158
|
return { template, branches };
|
|
161
159
|
}
|
|
160
|
+
/**
|
|
161
|
+
* The hops a reference reads off its referent besides its type: each keyed
|
|
162
|
+
* target’s key and each `local` target’s own fields. Each is its own branch,
|
|
163
|
+
* so the caller binds them in ONE union where each binds only its own
|
|
164
|
+
* variables, and a multi-valued key multiplies against nothing.
|
|
165
|
+
*/
|
|
166
|
+
function buildReferentHops(field, referent, schema, counter, onPath) {
|
|
167
|
+
const template = [];
|
|
168
|
+
const expansions = [];
|
|
169
|
+
const targets = referencedTargetsOf(field, schema);
|
|
170
|
+
const local = localTargetsOf(field, schema, onPath);
|
|
171
|
+
for (const target of targets) {
|
|
172
|
+
if (!local.includes(target)) {
|
|
173
|
+
// Only where no local expansion follows: a `local` lookup reads the
|
|
174
|
+
// target’s every path-bearing field, and a keyed target’s key field
|
|
175
|
+
// is one of them, so emitting the hop as well would state it twice.
|
|
176
|
+
const keyed = keyedFieldOf(target);
|
|
177
|
+
if (keyed !== undefined) {
|
|
178
|
+
const built = buildKeyHop(target, keyed, referent, counter);
|
|
179
|
+
template.push(built.triple);
|
|
180
|
+
expansions.push(built.pattern);
|
|
181
|
+
}
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
const nested = buildFor(target, referent, schema, counter, onPath);
|
|
185
|
+
template.push(...nested.template);
|
|
186
|
+
expansions.push(...nested.branches);
|
|
187
|
+
}
|
|
188
|
+
return { template, expansions };
|
|
189
|
+
}
|
|
162
190
|
/**
|
|
163
191
|
* The Root Types a {@link ReferenceStrategy.local} lookup expands into here:
|
|
164
192
|
* none where the field declares none, and never one already on this path,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lde/search-pipeline",
|
|
3
|
-
"version": "0.40.
|
|
3
|
+
"version": "0.40.3",
|
|
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.36.
|
|
28
|
+
"@lde/search": "^0.36.3",
|
|
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.43.
|
|
35
|
+
"@lde/search-typesense": "^0.43.3",
|
|
36
36
|
"@rdfjs/types": "^2.0.1",
|
|
37
37
|
"n3": "^2.13.12",
|
|
38
38
|
"testcontainers": "^12.1.0",
|