@lde/search-pipeline 0.43.0 → 0.44.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.
|
@@ -54,6 +54,14 @@ export interface SearchIndexerPipelineOptions {
|
|
|
54
54
|
/** {@link SearchType.name}s of the root types to source from it. */
|
|
55
55
|
names: readonly string[];
|
|
56
56
|
};
|
|
57
|
+
/**
|
|
58
|
+
* The {@link SearchType.name} of the root type that describes the dataset
|
|
59
|
+
* being indexed, so a `derive` can copy a field of the dataset onto each
|
|
60
|
+
* document through `ProjectionContext.datasetDocument` – see
|
|
61
|
+
* `searchStages`’ `datasetType`. An unknown name throws here, at
|
|
62
|
+
* wiring time.
|
|
63
|
+
*/
|
|
64
|
+
datasetType?: string;
|
|
57
65
|
/**
|
|
58
66
|
* {@link QuadTransform}(s) attached to a root type’s reader, keyed by
|
|
59
67
|
* {@link SearchType.name} – the extension point a deployment reaches for
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-indexer-pipeline.d.ts","sourceRoot":"","sources":["../src/search-indexer-pipeline.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAEL,QAAQ,EACR,KAAK,eAAe,EACpB,KAAK,oBAAoB,EAEzB,KAAK,gBAAgB,EACrB,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,MAAM,EACZ,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAO1E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,iDAAiD;AACjD,MAAM,WAAW,4BAA4B;IAC3C;;;;OAIG;IACH,MAAM,EAAE,YAAY,CAAC;IACrB;;;;OAIG;IACH,QAAQ,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC;IACt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;;GAoCG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,4BAA4B,GACpC,QAAQ,CAAC,mBAAmB,CAAC,CAuC/B"}
|
|
@@ -60,6 +60,7 @@ export function searchIndexerPipeline(options) {
|
|
|
60
60
|
sourceFor: fromRegistry.has(searchType.name) ? sourceFor : undefined,
|
|
61
61
|
transform: transforms?.[searchType.name],
|
|
62
62
|
})),
|
|
63
|
+
datasetType: options.datasetType,
|
|
63
64
|
}),
|
|
64
65
|
writers: searchIndexWriter({ schema, writerFor: options.writerFor }),
|
|
65
66
|
provenanceStore: options.provenanceStore,
|
package/dist/search-stages.d.ts
CHANGED
|
@@ -82,6 +82,15 @@ export interface SearchStagesOptions {
|
|
|
82
82
|
schema: SearchSchema;
|
|
83
83
|
/** One entry per root type to index, each its own stage. */
|
|
84
84
|
types: readonly SearchStageType[];
|
|
85
|
+
/**
|
|
86
|
+
* The {@link SearchType.name} of the root type that describes the dataset
|
|
87
|
+
* being indexed. Its stage then runs first, and the document it projects
|
|
88
|
+
* for the dataset itself – the one whose `id` is the dataset IRI – reaches
|
|
89
|
+
* every other stage’s projection as `ProjectionContext.datasetDocument`, so
|
|
90
|
+
* a `derive` can copy a field of the dataset onto each document. Must name
|
|
91
|
+
* one of {@link types}.
|
|
92
|
+
*/
|
|
93
|
+
datasetType?: string;
|
|
85
94
|
}
|
|
86
95
|
/**
|
|
87
96
|
* Compose one projecting {@link Stage} per root type – the source side of a
|
|
@@ -93,6 +102,9 @@ export interface SearchStagesOptions {
|
|
|
93
102
|
* by the dataset
|
|
94
103
|
* ([ADR 13](https://github.com/ldelements/lde/blob/main/docs/decisions/0013-project-inside-the-batch-per-root-type.md)).
|
|
95
104
|
*
|
|
105
|
+
* With {@link SearchStagesOptions.datasetType}, that type’s stage runs first
|
|
106
|
+
* and hands the dataset’s own document to every other stage’s projection.
|
|
107
|
+
*
|
|
96
108
|
* Wire the result as `new Pipeline<TypedSearchDocument>({ datasetSelector,
|
|
97
109
|
* stages: searchStages(...), writers: searchIndexWriter(...) })` – one terminal,
|
|
98
110
|
* N stages.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search-stages.d.ts","sourceRoot":"","sources":["../src/search-stages.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,EAEL,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,
|
|
1
|
+
{"version":3,"file":"search-stages.d.ts","sourceRoot":"","sources":["../src/search-stages.ts"],"names":[],"mappings":"AACA,OAAO,EAGL,KAAK,EAEL,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EAEL,KAAK,QAAQ,EAEb,KAAK,YAAY,EAClB,MAAM,aAAa,CAAC;AAErB,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;;;;;;;;;;;;;;;OAeG;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;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,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;IAClC;;;;;;;OAOG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,mBAAmB,GAC3B,KAAK,CAAC,mBAAmB,CAAC,EAAE,CAiH9B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;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"}
|
package/dist/search-stages.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Distribution } from '@lde/dataset';
|
|
2
2
|
import { SparqlConstructReader, SparqlItemSelector, Stage, } from '@lde/pipeline';
|
|
3
|
-
import { projectRoots } from '@lde/search';
|
|
3
|
+
import { projectRoots, } from '@lde/search';
|
|
4
4
|
import { extractionQueryString } from './extraction.js';
|
|
5
5
|
/**
|
|
6
6
|
* Compose one projecting {@link Stage} per root type – the source side of a
|
|
@@ -12,13 +12,33 @@ import { extractionQueryString } from './extraction.js';
|
|
|
12
12
|
* by the dataset
|
|
13
13
|
* ([ADR 13](https://github.com/ldelements/lde/blob/main/docs/decisions/0013-project-inside-the-batch-per-root-type.md)).
|
|
14
14
|
*
|
|
15
|
+
* With {@link SearchStagesOptions.datasetType}, that type’s stage runs first
|
|
16
|
+
* and hands the dataset’s own document to every other stage’s projection.
|
|
17
|
+
*
|
|
15
18
|
* Wire the result as `new Pipeline<TypedSearchDocument>({ datasetSelector,
|
|
16
19
|
* stages: searchStages(...), writers: searchIndexWriter(...) })` – one terminal,
|
|
17
20
|
* N stages.
|
|
18
21
|
*/
|
|
19
22
|
export function searchStages(options) {
|
|
20
|
-
const { schema, types } = options;
|
|
21
|
-
|
|
23
|
+
const { schema, types, datasetType } = options;
|
|
24
|
+
const isDatasetType = (type) => type.searchType.name === datasetType;
|
|
25
|
+
if (datasetType !== undefined && !types.some(isDatasetType)) {
|
|
26
|
+
// Without its stage the document is never projected, and every copy of a
|
|
27
|
+
// dataset field would be silently absent.
|
|
28
|
+
throw new Error(`Dataset type “${datasetType}” has no stage; name one of the types searchStages projects.`);
|
|
29
|
+
}
|
|
30
|
+
// The dataset being indexed and its own projected document, for the stages
|
|
31
|
+
// that run after its type’s. The pipeline processes datasets one at a time,
|
|
32
|
+
// so one slot holds one document, never one per dataset; it is read only for
|
|
33
|
+
// the dataset object it was written for.
|
|
34
|
+
let current;
|
|
35
|
+
// A dataset’s stages run one after another, in this order: the dataset
|
|
36
|
+
// type’s stage first, so its document is there for every other stage.
|
|
37
|
+
const ordered = [
|
|
38
|
+
...types.filter(isDatasetType),
|
|
39
|
+
...types.filter((type) => !isDatasetType(type)),
|
|
40
|
+
];
|
|
41
|
+
return ordered.map((type) => {
|
|
22
42
|
// Project with the schema’s OWN declaration object, whatever the caller
|
|
23
43
|
// passed: `assertTypeInSchema` (inside `projectRoots`) is an identity check,
|
|
24
44
|
// and re-resolving here makes a class-equal lookalike work too.
|
|
@@ -27,6 +47,7 @@ export function searchStages(options) {
|
|
|
27
47
|
throw new Error(`Search type “${type.searchType.name}” (class ${type.searchType.class}) is not in the schema; searchStages projects only types the schema declares.`);
|
|
28
48
|
}
|
|
29
49
|
const { rootVariable } = type;
|
|
50
|
+
const isDatasetStage = isDatasetType(type);
|
|
30
51
|
if (type.readers !== undefined && type.transform !== undefined) {
|
|
31
52
|
// Which of the caller’s readers the transform belongs to is knowable only
|
|
32
53
|
// to that caller, so guessing (all of them? the first?) would be a silent
|
|
@@ -71,15 +92,23 @@ export function searchStages(options) {
|
|
|
71
92
|
// declared over, and what a `derive` reads to relate a projected value
|
|
72
93
|
// to its provenance. The stage is where it is known: the writer sees it
|
|
73
94
|
// only after projection, which is too late for either.
|
|
74
|
-
for await (const document of projectRoots(quads, roots, schema, searchType,
|
|
75
95
|
// The same `iri.toString()` the writer’s provenance bookkeeping and
|
|
76
96
|
// `selectedSources()` use, so a declared field, the membership sweep
|
|
77
97
|
// and the selection all compare one spelling of the IRI.
|
|
78
|
-
|
|
79
|
-
|
|
98
|
+
const datasetIri = context.dataset.iri.toString();
|
|
99
|
+
for await (const document of projectRoots(quads, roots, schema, searchType, {
|
|
100
|
+
dataset: datasetIri,
|
|
101
|
+
// Only for other types: the dataset type’s own batches would
|
|
102
|
+
// otherwise see it or not depending on which batch ran first.
|
|
103
|
+
datasetDocument: !isDatasetStage && current?.dataset === context.dataset
|
|
104
|
+
? current.document
|
|
105
|
+
: undefined,
|
|
80
106
|
// Tallied by the pipeline and reported when the dataset completes.
|
|
81
107
|
onUnreadable: ({ field, id, value }) => context.valueUnread(searchType.name, field, { id, value }),
|
|
82
108
|
})) {
|
|
109
|
+
if (isDatasetStage && document.id === datasetIri) {
|
|
110
|
+
current = { dataset: context.dataset, document };
|
|
111
|
+
}
|
|
83
112
|
yield { searchType, document };
|
|
84
113
|
}
|
|
85
114
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lde/search-pipeline",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.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,14 +25,14 @@
|
|
|
25
25
|
"!**/*.tsbuildinfo"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@lde/search": "^0.
|
|
28
|
+
"@lde/search": "^0.39.1",
|
|
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.47.1",
|
|
36
36
|
"@rdfjs/types": "^2.0.1",
|
|
37
37
|
"n3": "^2.13.12",
|
|
38
38
|
"testcontainers": "^12.1.0",
|