@lde/search 0.23.1 → 0.23.2

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/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { projectRoots } from './project.js';
2
2
  export type { ProjectedNode, ProjectionContext, SearchDocument, } from './project.js';
3
3
  export { defineSearchType, searchSchema, validateSearchType, assertValidSearchType, ID_FIELD, AND_KEY, OR_KEY, isoToUnixSeconds, unixSecondsToIso, } from './schema.js';
4
- export type { FieldKind, SearchField, SearchFieldBase, TextField, KeywordField, ReferenceField, ReferenceStrategy, NumericField, BooleanField, SearchType, SearchTypeBase, RootType, ReferenceType, RootTypeOf, SearchTypeIssue, KeyField, SearchSchema, FacetRange, ProjectionValue, } from './schema.js';
4
+ export type { FieldKind, SearchField, SearchFieldBase, TextField, KeywordField, ReferenceField, ReferenceStrategy, NumericField, BooleanField, SearchType, SearchTypeBase, RootType, ReferenceType, RootTypeOf, SearchTypeIssue, KeyField, FacetKeys, SearchSchema, FacetRange, ProjectionValue, } from './schema.js';
5
5
  export { joinGraph, MAX_JOIN_DEPTH } from './join-graph.js';
6
6
  export type { JoinGraph } from './join-graph.js';
7
7
  export { filterOn } from './query.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,cAAc,GACf,MAAM,cAAc,CAAC;AAKtB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,QAAQ,EACR,OAAO,EACP,MAAM,EAMN,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,SAAS,EACT,WAAW,EACX,eAAe,EACf,SAAS,EACT,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,cAAc,EACd,QAAQ,EACR,aAAa,EACb,UAAU,EACV,eAAe,EACf,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,eAAe,GAChB,MAAM,aAAa,CAAC;AAKrB,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5D,YAAY,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAOjD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,YAAY,EACV,WAAW,EACX,mBAAmB,EACnB,MAAM,EACN,SAAS,EACT,aAAa,EACb,IAAI,GACL,MAAM,YAAY,CAAC;AAIpB,YAAY,EACV,YAAY,EACZ,YAAY,EACZ,SAAS,EACT,cAAc,EACd,WAAW,EACX,cAAc,EACd,SAAS,EACT,cAAc,EACd,WAAW,EACX,QAAQ,EACR,aAAa,EACb,aAAa,EACb,cAAc,GACf,MAAM,aAAa,CAAC;AAErB,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,YAAY,EACV,aAAa,EACb,iBAAiB,EACjB,cAAc,GACf,MAAM,cAAc,CAAC;AAKtB,OAAO,EACL,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,qBAAqB,EACrB,QAAQ,EACR,OAAO,EACP,MAAM,EAMN,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,aAAa,CAAC;AACrB,YAAY,EACV,SAAS,EACT,WAAW,EACX,eAAe,EACf,SAAS,EACT,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,cAAc,EACd,QAAQ,EACR,aAAa,EACb,UAAU,EACV,eAAe,EACf,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,UAAU,EACV,eAAe,GACh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yC,GACjD,cAAc,CAgBhB;AAmHD;;;;;;;;;;;;GAYG;AACH,wBAAuB,YAAY,CACjC,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,EACrB,KAAK,EAAE,SAAS,MAAM,EAAE,EACxB,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,QAAQ,EACpB,OAAO,GAAE,iBAAyC,GACjD,aAAa,CAAC,cAAc,CAAC,CAc/B"}
package/dist/project.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { fold } from '@lde/text-normalization';
2
2
  import { buildSubjectIndex, frameSubjects, } from './frame-by-type.js';
3
- import { assertTypeInSchema, displayFieldName, documentKeyOf, fieldNamed, inlineFramingDepth, irAlias, isAbsoluteIri, isInternalField, isInlineReference, isoToUnixSeconds, labelSourceNameOf, physicalFields, referenceTypeNamed, rootTypeNamed, } from './schema.js';
3
+ import { assertTypeInSchema, displayFieldName, documentKeyOf, fieldNamed, inheritedFacetKeys, inlineFramingDepth, irAlias, isAbsoluteIri, isInternalField, isInlineReference, isoToUnixSeconds, labelSourceNameOf, physicalFields, referenceTypeNamed, rootTypeNamed, } from './schema.js';
4
4
  /** The context a projection runs with when its caller supplied none. */
5
5
  const NO_PROJECTION_CONTEXT = {};
6
6
  /**
@@ -148,7 +148,7 @@ function applyField(document, node, field, searchType, schema, context) {
148
148
  // (`validateSearchType`): a projection value, a computed value, a graph path.
149
149
  if ((field.kind === 'keyword' || field.kind === 'reference') &&
150
150
  field.from !== undefined) {
151
- return applyProjectionValue(document, field, field.from, context);
151
+ return applyProjectionValue(document, field, field.from, context, schema);
152
152
  }
153
153
  if (field.derive !== undefined) {
154
154
  const derived = field.derive(document, context);
@@ -207,9 +207,9 @@ function applyField(document, node, field, searchType, schema, context) {
207
207
  case 'text':
208
208
  return applyText(document, langValuesOf(node, alias), field);
209
209
  case 'keyword':
210
- return applyFacet(document, literalsOf(node, alias), field);
210
+ return applyFacet(document, literalsOf(node, alias), field, schema);
211
211
  case 'reference':
212
- return applyFacet(document, referenceValues(node, alias, field, schema), field);
212
+ return applyFacet(document, referenceValues(node, alias, field, schema), field, schema);
213
213
  case 'integer':
214
214
  return setNumber(document, field.name, toInteger(firstLiteralOf(node, alias)));
215
215
  case 'number':
@@ -327,6 +327,16 @@ function foldedSearchValue(values) {
327
327
  * `keyword` reads literals; `reference` reads IRIs (the caller passes the
328
328
  * already-read raw values).
329
329
  *
330
+ * A reference inheriting a {@link FacetKeys facet policy} from the type it
331
+ * names ({@link inheritedFacetKeys}) also writes the `${name}_facet` companion
332
+ * the engine facets instead of the field: the subset of **what the field
333
+ * stores** that the policy admits. So it is written after the field’s own
334
+ * `transform` and the IRI filter, from the same `values` – for a keyed target
335
+ * those are already keys ({@link referenceValues}), which is what makes a
336
+ * predicate over document keys the right shape. The field itself keeps every
337
+ * value; only the facet narrows. An empty subset writes nothing, exactly as a
338
+ * path that matched nothing does.
339
+ *
330
340
  * **`array` decides the shape**, as it does for every other kind: a declared
331
341
  * `array` field stores a list, and a single-valued one stores the first value –
332
342
  * the graph may still carry several, exactly as it may carry several literals
@@ -337,7 +347,7 @@ function foldedSearchValue(values) {
337
347
  * engine rejects, or – where it does not type-check, as inside a nested
338
348
  * document – a value the API cannot serialize.
339
349
  */
340
- function applyFacet(document, raw, field) {
350
+ function applyFacet(document, raw, field, schema) {
341
351
  // A `reference` stores identity, so what it stores must be an IRI whatever
342
352
  // route the value arrived by. {@link iriString} guards the graph path, but a
343
353
  // `transform` runs after it and a `from` projection value never passes it at
@@ -347,18 +357,34 @@ function applyFacet(document, raw, field) {
347
357
  const transformed = field.transform ? raw.map(field.transform) : raw;
348
358
  const values = dedupe(referenced ? transformed.filter(isAbsoluteIri) : transformed);
349
359
  const folded = dedupe(values.map((value) => fold(value)));
350
- const searchField = physicalFields(field).search[0];
360
+ const names = physicalFields(field, schema);
361
+ const searchField = names.search[0];
362
+ const policy = inheritedFacetKeys(field, schema);
363
+ // `names.facet` is the companion exactly when a policy is inherited –
364
+ // physicalFields reads the same `inheritedFacetKeys`.
365
+ const facetField = names.facet;
366
+ // The companion is a subset of what the field STORES – for a single-valued
367
+ // field its first value, not the first admitted of all of them, or the facet
368
+ // would count a value no filter on the field can reproduce.
369
+ const stored = field.array === true ? values : values.slice(0, 1);
370
+ const admitted = policy === undefined ? [] : stored.filter(policy.only);
351
371
  if (field.array === true) {
352
- setArray(document, field.name, values);
372
+ setArray(document, field.name, stored);
353
373
  if (field.searchable) {
354
374
  setArray(document, searchField, folded);
355
375
  }
376
+ if (policy !== undefined) {
377
+ setArray(document, facetField, admitted);
378
+ }
356
379
  return;
357
380
  }
358
- setString(document, field.name, values[0]);
381
+ setString(document, field.name, stored[0]);
359
382
  if (field.searchable) {
360
383
  setString(document, searchField, folded[0]);
361
384
  }
385
+ if (policy !== undefined) {
386
+ setString(document, facetField, admitted[0]);
387
+ }
362
388
  }
363
389
  /**
364
390
  * Project a field declared over a {@link ProjectionContext} value: read the
@@ -371,13 +397,13 @@ function applyFacet(document, raw, field) {
371
397
  * pipeline (a test, a one-off) leaves the field absent rather than inventing a
372
398
  * placeholder, the same as a `path` that matched nothing.
373
399
  */
374
- function applyProjectionValue(document, field, from, context) {
400
+ function applyProjectionValue(document, field, from, context, schema) {
375
401
  // `ProjectionContext` is keyed by `ProjectionValue`, so the declaration reads
376
402
  // the context directly: a projection value that has no context key, or a
377
403
  // context key no declaration can name, is a compile error rather than a
378
404
  // silently unpopulated field.
379
405
  const value = context[from];
380
- applyFacet(document, value === undefined ? [] : [value], field);
406
+ applyFacet(document, value === undefined ? [] : [value], field, schema);
381
407
  }
382
408
  /**
383
409
  * Project an inline reference: the referent node(s) embedded under the field’s
package/dist/schema.d.ts CHANGED
@@ -371,6 +371,40 @@ export interface KeyField {
371
371
  */
372
372
  readonly pick?: (candidates: readonly string[]) => string | undefined;
373
373
  }
374
+ /**
375
+ * A {@link RootType}’s **facet policy**: which of its documents get a facet
376
+ * bucket, as a predicate over the document key. Declared once, on the type,
377
+ * and inherited by every facetable reference that *names* the type – a
378
+ * `lookup`’s `target`, an `idOnly`’s `labelSource` ({@link labelSourceNameOf})
379
+ * – because *which of a type’s ids deserve a bucket* is a fact about the type,
380
+ * not about each field that points at it. A per-field policy would be one rule
381
+ * declared N times, and forgetting one would silently reintroduce the buckets
382
+ * on that facet alone.
383
+ *
384
+ * Only the facet narrows. The referring field keeps **every** value: a
385
+ * document still displays the excluded referent, and a `where` filter on its
386
+ * IRI still matches exactly. *Facets are discovery, filters are exact.*
387
+ *
388
+ * The mechanism is a second physical field per inheriting facet –
389
+ * `${name}_facet`, holding the admitted subset ({@link physicalFields}) – which
390
+ * the engine facets instead of the field itself, so the facet is exact under
391
+ * any bucket cap: the engine never sees an excluded value. Declaring a policy
392
+ * therefore changes the collection definition of every type that references
393
+ * this one; an engine adapter that reuses a live collection must notice.
394
+ *
395
+ * **The failure mode is silence.** A predicate that admits none of a type’s
396
+ * keys – a type whose alignments are not what it tests for, or stored values
397
+ * that are still node IRIs because the type was keyed after its references
398
+ * were indexed – empties every facet referencing the type without an error.
399
+ * Give each type its own predicate rather than reuse another’s, and key a type
400
+ * ({@link RootType.key}) before declaring a policy over its keys.
401
+ */
402
+ export interface FacetKeys {
403
+ /** Whether a document key gets a bucket. Must be **pure**: it is applied per
404
+ * document at projection time, so an impure one would bucket one document
405
+ * and not its twin. */
406
+ readonly only: (id: string) => boolean;
407
+ }
374
408
  /**
375
409
  * A **Root Type**: a {@link SearchType} that is indexed. It declares a `class`,
376
410
  * roots are selected for it, a Writer owns a collection for it, and the
@@ -386,6 +420,10 @@ export interface RootType extends SearchTypeBase {
386
420
  /** Which declared field holds this type’s document key, when it is not the
387
421
  * node’s own IRI ({@link KeyField}, {@link documentKeyOf}). */
388
422
  readonly key?: KeyField;
423
+ /** Which of this type’s documents get a facet bucket, on every facetable
424
+ * reference that names this type ({@link FacetKeys}). Unset, every
425
+ * document does. */
426
+ readonly facetKeys?: FacetKeys;
389
427
  }
390
428
  /**
391
429
  * A **Reference Type**: a {@link SearchType} reached only through an
@@ -407,6 +445,9 @@ export interface ReferenceType extends SearchTypeBase {
407
445
  * referrer rather than keyed in a collection of its own. `never` for the
408
446
  * same reason `class` is. */
409
447
  readonly key?: never;
448
+ /** Nothing references a Reference Type by id, so there is no facet for a
449
+ * policy to narrow. `never` for the same reason `key` is. */
450
+ readonly facetKeys?: never;
410
451
  }
411
452
  /**
412
453
  * One type’s complete search declaration: its logical API `name`, the queryable
@@ -565,7 +606,7 @@ export declare function labelSourceNameOf(field: ReferenceField): string | undef
565
606
  */
566
607
  export interface SearchTypeIssue {
567
608
  readonly field: string;
568
- readonly reason: 'duplicate-field-name' | 'invalid-field-name' | 'unknown-kind' | 'invalid-locale' | 'missing-ref' | 'missing-ref-type-name' | 'ref-not-allowed' | 'text-requires-locales' | 'locales-not-allowed' | 'facet-ranges-not-allowed' | 'searchable-not-allowed' | 'transform-not-allowed' | 'derive-with-path' | 'from-not-allowed' | 'from-with-path' | 'from-with-derive' | 'from-with-inline-ref' | 'unknown-projection-value' | 'duplicate-projection-value' | 'text-not-filterable' | 'text-not-facetable' | 'joinable-not-allowed' | 'joinable-without-label-source' | 'joinable-with-inline-ref' | 'reserved-field-name' | 'key-field-unknown' | 'key-field-not-reference' | 'key-field-without-path' | 'key-field-not-array' | 'key-field-inline' | 'key-pick-not-a-function' | 'key-not-allowed';
609
+ readonly reason: 'duplicate-field-name' | 'invalid-field-name' | 'unknown-kind' | 'invalid-locale' | 'missing-ref' | 'missing-ref-type-name' | 'ref-not-allowed' | 'text-requires-locales' | 'locales-not-allowed' | 'facet-ranges-not-allowed' | 'searchable-not-allowed' | 'transform-not-allowed' | 'derive-with-path' | 'from-not-allowed' | 'from-with-path' | 'from-with-derive' | 'from-with-inline-ref' | 'unknown-projection-value' | 'duplicate-projection-value' | 'text-not-filterable' | 'text-not-facetable' | 'joinable-not-allowed' | 'joinable-without-label-source' | 'joinable-with-inline-ref' | 'reserved-field-name' | 'key-field-unknown' | 'key-field-not-reference' | 'key-field-without-path' | 'key-field-not-array' | 'key-field-inline' | 'key-pick-not-a-function' | 'key-not-allowed' | 'facet-keys-only-not-a-function' | 'facet-keys-not-allowed';
569
610
  }
570
611
  /**
571
612
  * The reserved logical name of a document’s IRI – the one field every indexed
@@ -638,7 +679,10 @@ export declare const OR_KEY = "or";
638
679
  * the dataset off a declaration no rule picks between;
639
680
  * - a {@link RootType.key} names a declared, `path`-bearing, `array`,
640
681
  * non-`inline` `reference` field of this type, and its `pick` is a function
641
- * ({@link keyIssues}); a {@link ReferenceType} declares no key at all.
682
+ * ({@link keyIssues}); a {@link ReferenceType} declares no key at all;
683
+ * - a {@link RootType.facetKeys} policy’s `only` is a function
684
+ * ({@link facetKeysIssues}); a {@link ReferenceType} declares no policy at
685
+ * all.
642
686
  *
643
687
  * Pure and total: returns every issue rather than throwing;
644
688
  * {@link assertValidSearchType} is the throwing entry point.
@@ -667,6 +711,11 @@ export interface PhysicalFields {
667
711
  /** Per-locale folded sort keys `${name}_sort_${locale}` (localized text,
668
712
  * `sortable`); a non-localized field sorts on its own `name` field. */
669
713
  readonly sort: readonly string[];
714
+ /** The field a facet on this field reads, when `facetable`: the field’s own
715
+ * `name`, or the `${name}_facet` companion holding the subset its target’s
716
+ * {@link FacetKeys facet policy} admits. `undefined` for a field that is
717
+ * not facetable. */
718
+ readonly facet: string | undefined;
670
719
  }
671
720
  /**
672
721
  * The display fields of a localized `text` field are pattern-based, not
@@ -851,9 +900,28 @@ export declare function isoToUnixSeconds(iso: string): number | undefined;
851
900
  export declare function unixSecondsToIso(seconds: number): string;
852
901
  /**
853
902
  * Derive the **indexed** physical engine field names a declaration produces:
854
- * the per-locale `search`/`sort` fanout. A localized `text` field’s display
855
- * fields are pattern-based and not enumerated here – see {@link displayFieldName}
856
- * and its siblings.
857
- */
858
- export declare function physicalFields(field: SearchField): PhysicalFields;
903
+ * the per-locale `search`/`sort` fanout, and the field a `facet` reads. A
904
+ * localized `text` field’s display fields are pattern-based and not enumerated
905
+ * here – see {@link displayFieldName} and its siblings.
906
+ *
907
+ * The facet is the one member that depends on more than the declaration: a
908
+ * facetable reference whose target declares a {@link FacetKeys facet policy}
909
+ * facets a `${name}_facet` companion rather than itself, and only the `schema`
910
+ * can resolve that target ({@link inheritedFacetKeys}). Without one the field
911
+ * facets on its own name – the same reading the projection makes without a
912
+ * schema, where it cannot re-key a reference either.
913
+ */
914
+ export declare function physicalFields(field: SearchField, schema?: SearchSchema): PhysicalFields;
915
+ /**
916
+ * The {@link FacetKeys facet policy} a field inherits: the `facetKeys` of the
917
+ * Root Type it names ({@link labelSourceNameOf}), when the field is a facetable
918
+ * reference and the schema resolves that type. The boundary is *naming the
919
+ * target* – the same line along which a reference is re-keyed and a join is
920
+ * drawn – so a reference that names no type inherits nothing, whatever type
921
+ * its values happen to point at; and a `derive`d reference, which produces its
922
+ * own values rather than reading a referent, is re-keyed by nothing and so
923
+ * narrowed by nothing either. The one reading the projection (which writes the
924
+ * companion) and {@link physicalFields} (which names it) share.
925
+ */
926
+ export declare function inheritedFacetKeys(field: SearchField, schema: SearchSchema | undefined): FacetKeys | undefined;
859
927
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../src/schema.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGrE;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GACnB,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,CAAC;AAE/E;oEACoE;AACpE,MAAM,MAAM,cAAc,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,CAAC;AAcnD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,SAAS,GAAG,cAAc,GAAG,SAAS,CAE7E;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,MAAM,MAAM,WAAW,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,WAAW,GAAG,MAAM,CAE1E;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,WAAW,GACjB,KAAK,IAAI,YAAY,GAAG;IAAE,QAAQ,CAAC,WAAW,EAAE,SAAS,UAAU,EAAE,CAAA;CAAE,CAEzE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEpD;AAOD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAQhE;AAyBD,+EAA+E;AAC/E,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAExD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,WAAW,EAClB,MAAM,CAAC,EAAE,YAAY,GACpB,cAAc,CAwBhB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,YAAY,GAAG,SAAS,GAC/B,SAAS,GAAG,SAAS,CAavB"}
package/dist/schema.js CHANGED
@@ -488,7 +488,10 @@ const LOCALE_PATTERN = /^[A-Za-z0-9]+(-[A-Za-z0-9]+)*$/;
488
488
  * the dataset off a declaration no rule picks between;
489
489
  * - a {@link RootType.key} names a declared, `path`-bearing, `array`,
490
490
  * non-`inline` `reference` field of this type, and its `pick` is a function
491
- * ({@link keyIssues}); a {@link ReferenceType} declares no key at all.
491
+ * ({@link keyIssues}); a {@link ReferenceType} declares no key at all;
492
+ * - a {@link RootType.facetKeys} policy’s `only` is a function
493
+ * ({@link facetKeysIssues}); a {@link ReferenceType} declares no policy at
494
+ * all.
492
495
  *
493
496
  * Pure and total: returns every issue rather than throwing;
494
497
  * {@link assertValidSearchType} is the throwing entry point.
@@ -635,7 +638,7 @@ export function validateSearchType(searchType) {
635
638
  }
636
639
  }
637
640
  }
638
- issues.push(...keyIssues(searchType));
641
+ issues.push(...keyIssues(searchType), ...facetKeysIssues(searchType));
639
642
  return issues;
640
643
  }
641
644
  /**
@@ -689,6 +692,30 @@ function keyIssues(searchType) {
689
692
  }
690
693
  return issues;
691
694
  }
695
+ /**
696
+ * The issues a type’s {@link RootType.facetKeys} declaration carries, filed
697
+ * under the member’s name: the policy names no field – it is a rule about the
698
+ * type’s own keys, applied through other types’ fields – so there is no field
699
+ * name to file it under.
700
+ */
701
+ function facetKeysIssues(searchType) {
702
+ const facetKeys = searchType.facetKeys;
703
+ if (facetKeys === undefined) {
704
+ return [];
705
+ }
706
+ const issue = (reason) => ({
707
+ field: 'facetKeys',
708
+ reason,
709
+ });
710
+ // Nothing references a Reference Type by id, so a policy on one narrows no
711
+ // facet – it states a rule nothing could apply.
712
+ if (searchType.class === undefined) {
713
+ return [issue('facet-keys-not-allowed')];
714
+ }
715
+ return typeof facetKeys.only === 'function'
716
+ ? []
717
+ : [issue('facet-keys-only-not-a-function')];
718
+ }
692
719
  /**
693
720
  * Throw when `searchType` is not a member of `schema` – the port membership
694
721
  * guard every engine adapter applies before searching, so a query can never
@@ -999,11 +1026,18 @@ export function unixSecondsToIso(seconds) {
999
1026
  }
1000
1027
  /**
1001
1028
  * Derive the **indexed** physical engine field names a declaration produces:
1002
- * the per-locale `search`/`sort` fanout. A localized `text` field’s display
1003
- * fields are pattern-based and not enumerated here – see {@link displayFieldName}
1004
- * and its siblings.
1029
+ * the per-locale `search`/`sort` fanout, and the field a `facet` reads. A
1030
+ * localized `text` field’s display fields are pattern-based and not enumerated
1031
+ * here – see {@link displayFieldName} and its siblings.
1032
+ *
1033
+ * The facet is the one member that depends on more than the declaration: a
1034
+ * facetable reference whose target declares a {@link FacetKeys facet policy}
1035
+ * facets a `${name}_facet` companion rather than itself, and only the `schema`
1036
+ * can resolve that target ({@link inheritedFacetKeys}). Without one the field
1037
+ * facets on its own name – the same reading the projection makes without a
1038
+ * schema, where it cannot re-key a reference either.
1005
1039
  */
1006
- export function physicalFields(field) {
1040
+ export function physicalFields(field, schema) {
1007
1041
  if (field.kind === 'text') {
1008
1042
  const locales = field.locales;
1009
1043
  return {
@@ -1013,10 +1047,40 @@ export function physicalFields(field) {
1013
1047
  sort: field.sortable
1014
1048
  ? locales.map((locale) => `${field.name}_sort_${locale}`)
1015
1049
  : [],
1050
+ // Text is never facetable (`validateSearchType`).
1051
+ facet: undefined,
1016
1052
  };
1017
1053
  }
1018
1054
  return {
1019
1055
  search: field.searchable !== undefined ? [`${field.name}_search`] : [],
1020
1056
  sort: [],
1057
+ facet: field.facetable !== true
1058
+ ? undefined
1059
+ : inheritedFacetKeys(field, schema) === undefined
1060
+ ? field.name
1061
+ : `${field.name}_facet`,
1021
1062
  };
1022
1063
  }
1064
+ /**
1065
+ * The {@link FacetKeys facet policy} a field inherits: the `facetKeys` of the
1066
+ * Root Type it names ({@link labelSourceNameOf}), when the field is a facetable
1067
+ * reference and the schema resolves that type. The boundary is *naming the
1068
+ * target* – the same line along which a reference is re-keyed and a join is
1069
+ * drawn – so a reference that names no type inherits nothing, whatever type
1070
+ * its values happen to point at; and a `derive`d reference, which produces its
1071
+ * own values rather than reading a referent, is re-keyed by nothing and so
1072
+ * narrowed by nothing either. The one reading the projection (which writes the
1073
+ * companion) and {@link physicalFields} (which names it) share.
1074
+ */
1075
+ export function inheritedFacetKeys(field, schema) {
1076
+ if (schema === undefined ||
1077
+ field.kind !== 'reference' ||
1078
+ field.facetable !== true ||
1079
+ field.derive !== undefined) {
1080
+ return undefined;
1081
+ }
1082
+ const targetName = labelSourceNameOf(field);
1083
+ return targetName === undefined
1084
+ ? undefined
1085
+ : rootTypeNamed(schema, targetName)?.facetKeys;
1086
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAmBhD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,YAAY,GACzB,IAAI,CAuON"}
1
+ {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAoBhD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,YAAY,GACzB,IAAI,CAuRN"}
package/dist/testing.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
  import { filterOn, filterOperatorFor, } from './query.js';
3
- import { facetableFields, filterableFields, ID_FIELD, nestedReferenceType, outputFields, } from './schema.js';
3
+ import { facetableFields, filterableFields, ID_FIELD, inheritedFacetKeys, nestedReferenceType, outputFields, } from './schema.js';
4
4
  /**
5
5
  * The executable {@link SearchEngine} port contract (import from
6
6
  * `@lde/search/testing`): a vitest suite every engine adapter runs against a
@@ -200,6 +200,53 @@ export function describeSearchEngineContract(name, engine) {
200
200
  }
201
201
  }
202
202
  });
203
+ it('buckets a facet inheriting a policy on admitted keys only, labelled, while filtering stays exact', async () => {
204
+ // A facet policy (`RootType.facetKeys`) narrows the FACET and nothing
205
+ // else. Two things an adapter can get wrong, each silently: facet the
206
+ // companion field but report its buckets under the engine’s name, which
207
+ // loses every label and files the counts under a key no consumer asked
208
+ // for; and pick the filter operator off the declaration, so a `where`
209
+ // on an excluded value – still `facetable` in the schema, no longer a
210
+ // facet in the engine – partial-matches on a shared path prefix. The
211
+ // adapter’s fixture should carry two IRIs sharing a prefix so the
212
+ // second assertion bites.
213
+ for (const searchType of types()) {
214
+ for (const field of facetableFields(searchType)) {
215
+ const policy = inheritedFacetKeys(field, engine().schema);
216
+ if (policy === undefined) {
217
+ continue;
218
+ }
219
+ const result = await engine().search(searchType, {
220
+ ...browse(searchType),
221
+ limit: 20,
222
+ facets: [field.name],
223
+ });
224
+ const buckets = result.facets[field.name] ?? [];
225
+ for (const bucket of buckets) {
226
+ expect(policy.only(bucket.value)).toBe(true);
227
+ expect(bucket.label).toBeDefined();
228
+ }
229
+ if (field.output !== true || field.filterable !== true) {
230
+ continue; // Nothing to read the stored values back from.
231
+ }
232
+ const excluded = result.hits
233
+ .flatMap((hit) => referenceIds(hit.document[field.name]))
234
+ .find((id) => !policy.only(id));
235
+ if (excluded === undefined) {
236
+ continue;
237
+ }
238
+ const filtered = await engine().search(searchType, {
239
+ ...browse(searchType),
240
+ limit: 20,
241
+ where: [filterOn({ field: field.name, in: [excluded] })],
242
+ });
243
+ expect(filtered.total).toBeGreaterThan(0);
244
+ for (const hit of filtered.hits) {
245
+ expect(referenceIds(hit.document[field.name])).toContain(excluded);
246
+ }
247
+ }
248
+ }
249
+ });
203
250
  it('answers a browse query with hits, a total and facets', async () => {
204
251
  for (const searchType of types()) {
205
252
  const result = await engine().search(searchType, browse(searchType));
@@ -220,6 +267,16 @@ function mismatchedFilter(field, operator) {
220
267
  ? filterOn({ field, range: { min: 0 } })
221
268
  : filterOn({ field, in: ['x'] });
222
269
  }
270
+ /** The ids a reconstructed reference value carries – one labelled reference
271
+ * or a list of them – read the way a consumer reads them. */
272
+ function referenceIds(value) {
273
+ const references = Array.isArray(value) ? value : [value];
274
+ return references
275
+ .map((reference) => typeof reference === 'object' && reference !== null && 'id' in reference
276
+ ? String(reference.id)
277
+ : undefined)
278
+ .filter((id) => id !== undefined);
279
+ }
223
280
  /** The locale a query against this type may select (any is contract-valid). */
224
281
  function firstLocale(searchType) {
225
282
  for (const field of searchType.fields) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lde/search",
3
- "version": "0.23.1",
3
+ "version": "0.23.2",
4
4
  "description": "Engine- and domain-agnostic core for RDF-backed search: a unified declarative field model (SearchField/SearchType/SearchSchema), a neutral query IR, the SearchEngine port with logical result types, and a streaming CONSTRUCT-to-document projection. Bakes in no engine, protocol, or domain.",
5
5
  "repository": {
6
6
  "url": "git+https://github.com/ldelements/lde.git",