@lde/search-typesense 0.41.0 → 0.43.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.
@@ -240,8 +240,17 @@ function typesenseFields(searchType, field, defaultLocale, defaultSortingField,
240
240
  optional: true,
241
241
  });
242
242
  }
243
+ if (names.precision !== undefined) {
244
+ fields.push(precisionField(names.precision));
245
+ }
243
246
  return fields;
244
247
  }
248
+ /** A `date` field’s precision companion ({@link physicalFields}): read back
249
+ * with the hit to format the value, never queried, so stored but not
250
+ * indexed – it costs disk, not RAM. */
251
+ function precisionField(name) {
252
+ return { name, type: 'string', index: false, optional: true };
253
+ }
245
254
  /**
246
255
  * The nested object one inline reference stores, plus one nested Physical Field
247
256
  * per field of the type it nests – recursing for a nested field that itself
@@ -546,6 +555,9 @@ function nestedLeafFields(prefix, field, defaultLocale, flattensToArray) {
546
555
  optional: true,
547
556
  });
548
557
  }
558
+ if (names.precision !== undefined) {
559
+ fields.push(precisionField(nestedFieldName(prefix, names.precision)));
560
+ }
549
561
  return fields;
550
562
  }
551
563
  /** The Typesense field type for a non-localized field, from its `kind`. 64-bit
@@ -1 +1 @@
1
- {"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../src/lookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EACL,KAAK,mBAAmB,EACxB,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AAUrB;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,iBAAiB,GACzB;IACE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC;IACvB;wCACoC;IACpC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC1D;4DACwD;IACxD,QAAQ,CAAC,gBAAgB,EAAE,WAAW,CACpC,MAAM,EACN,WAAW,CAAC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AAC;IACvB;wCACoC;IACpC,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAC1D;4DACwD;IACxD,QAAQ,CAAC,gBAAgB,EAAE,WAAW,CACpC,MAAM,EACN,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,CACvC,CAAC;CACH,GACD;IACE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAC3D,CAAC;AAEN,2CAA2C;AAC3C,MAAM,WAAW,gBAAgB;IAC/B;;6CAEyC;IACzC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC3C,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAC3D;AAKD;;;;;;;;GAQG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,aAAa,CAAC,EACnC,UAAU,EAAE,mBAAmB,GAAG,SAAS,EAC3C,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,YAAY,EACpB,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EACxC,OAAO,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC3C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GACjC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAmHjD"}
package/dist/lookup.js CHANGED
@@ -1,4 +1,4 @@
1
- import { displayFieldName, fieldNamed, labelFieldOf, nestedReferenceType, referencedTargetsOf, } from '@lde/search/adapter';
1
+ import { displayFieldName, fieldNamed, labelFieldOf, nestedReferenceType, physicalFields, referencedTargetsOf, } from '@lde/search/adapter';
2
2
  import { escapeFilterValue } from './query-compiler.js';
3
3
  /** Typesense caps a filter list; the same batch size the label lookup uses. */
4
4
  const BATCH_SIZE = 200;
@@ -161,6 +161,11 @@ function includeFields(target, wanted, below) {
161
161
  }
162
162
  else {
163
163
  physical.add(field.name);
164
+ // A date is served at the precision its source gave, kept beside it.
165
+ const precision = physicalFields(field).precision;
166
+ if (precision !== undefined) {
167
+ physical.add(precision);
168
+ }
164
169
  }
165
170
  }
166
171
  // With several targets the level below merges every target’s selection,
@@ -1 +1 @@
1
- {"version":3,"file":"query-compiler.d.ts","sourceRoot":"","sources":["../src/query-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAEzE,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,QAAQ,EAEb,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,UAAU,EAIhB,MAAM,aAAa,CAAC;AAoBrB;mDACmD;AACnD,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,CACvB,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,SAAS,MAAM,EAAE,KACpB,UAAU,GAAG,SAAS,CAAC;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;IACjC;;;;;;;;OAQG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAC/B;;;;;;;;;;;OAWG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;CACrD;AAED;;;;;;;;;;;GAWG;AACH,wBAA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wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD"}
@@ -1,5 +1,5 @@
1
1
  import { fold } from '@lde/text-normalization';
2
- import { fieldNamed, filterOperator, filterOperatorFor, ID_FIELD, isoToUnixSeconds, isInternalField, isBinnedRangeFacet, isWelded, joinGraph, localLookupTargetsOf, matchLanguage, pageForOffset, physicalFields, nestedReferenceType, resolvePath, searchableFields, } from '@lde/search/adapter';
2
+ import { fieldNamed, filterOperator, filterOperatorFor, ID_FIELD, isoToUnixSeconds, lastSecondOf, storedFacetRanges, isInternalField, isBinnedRangeFacet, isWelded, joinGraph, localLookupTargetsOf, matchLanguage, pageForOffset, physicalFields, nestedReferenceType, resolvePath, searchableFields, } from '@lde/search/adapter';
3
3
  /**
4
4
  * Compile the engine-neutral {@link SearchQuery} into Typesense search
5
5
  * parameters – the query half of the engine adapter. Pure (no client, no env),
@@ -61,7 +61,7 @@ function compileFacetBy(facets, searchType, schema) {
61
61
  return name;
62
62
  }
63
63
  return isBinnedRangeFacet(field)
64
- ? compileRangeFacet(field.name, field.facetRanges)
64
+ ? compileRangeFacet(field.name, storedFacetRanges(field))
65
65
  : (physicalFields(field, schema).facet ?? name);
66
66
  })
67
67
  .join(',');
@@ -424,8 +424,8 @@ function compileRange(field, range, prefix = '') {
424
424
  // the surface passes through – is a bound NOT SET, not a bound of `null`.
425
425
  // Read literally it reaches the engine as `datePosted:[null..…]`, which
426
426
  // Typesense rejects outright.
427
- const min = storedBound(field, range.min ?? undefined);
428
- const max = storedBound(field, range.max ?? undefined);
427
+ const min = storedBound(field, range.min ?? undefined, 'min');
428
+ const max = storedBound(field, range.max ?? undefined, 'max');
429
429
  if (min !== undefined && max !== undefined) {
430
430
  return `${name}:[${min}..${max}]`;
431
431
  }
@@ -438,11 +438,18 @@ function compileRange(field, range, prefix = '') {
438
438
  return undefined;
439
439
  }
440
440
  /** A range bound as stored: a `date` field’s ISO 8601 bound becomes the indexed
441
- * Unix seconds ({@link isoToUnixSeconds}); an unparseable bound is dropped. */
442
- function storedBound(field, bound) {
443
- return field.kind === 'date' && typeof bound === 'string'
444
- ? isoToUnixSeconds(bound)
445
- : bound;
441
+ * Unix seconds ({@link isoToUnixSeconds}) – a `min` its period’s first second,
442
+ * a `max` its last ({@link lastSecondOf}), so the inclusive clause takes in the
443
+ * whole period each names. An unparseable bound is dropped. */
444
+ function storedBound(field, bound, side) {
445
+ if (field.kind !== 'date' || typeof bound !== 'string') {
446
+ return bound;
447
+ }
448
+ const stored = isoToUnixSeconds(bound);
449
+ if (stored === undefined) {
450
+ return undefined;
451
+ }
452
+ return side === 'min' ? stored.seconds : lastSecondOf(stored);
446
453
  }
447
454
  /**
448
455
  * One `sort_by` term. `relevance` maps to Typesense’s `_text_match`; a localized
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../src/search.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAIL,KAAK,cAAc,EAMnB,KAAK,UAAU,EAGf,KAAK,YAAY,EAEjB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,UAAU,EAEf,KAAK,SAAS,EACf,MAAM,aAAa,CAAC;AA0BrB,OAAO,EAGL,KAAK,wBAAwB,EAC9B,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAGL,KAAK,iBAAiB,EACvB,MAAM,aAAa,CAAC;AAErB;;;;sDAIsD;AACtD,MAAM,WAAW,4BAA4B,CAC3C,QAAQ,SAAS,MAAM,GAAG,MAAM,CAIhC,SAAQ,IAAI,CAAC,wBAAwB,EAAE,eAAe,CAAC;IACvD;;;;;;;;OAQG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;IACnE;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,KAAK,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AAE,KAAK,CAAA;SAAE,CAAC;KACpD,EAAE,CAAC;CACL;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,uBAAuB,EACjC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,cAAc,CAAC,EAC3C,MAAM,EAAE,YAAY,EACpB,SAAS,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,GACjD,YAAY,CAuDd"}
package/dist/search.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { NESTED_DOCUMENT_TYPE, } from '@lde/search';
2
- import { assertTypeInSchema, assertValidQuery, displayLangOf, facetableFields, facetSearches, fieldNamed, filterOn, inheritedFacetPolicies, isInlineReference, isBinnedRangeFacet, isUnsatisfiable, joinGraph, labelFieldOf, labelSourceNamesOf, labelTargetNamesOf, localLookupTargetsOf, nestedReferenceType, outputFields, physicalFields, referencedTargetsOf, referenceFields, storedTargetOf, } from '@lde/search/adapter';
2
+ import { assertTypeInSchema, assertValidQuery, displayLangOf, facetableFields, facetSearches, fieldNamed, filterOn, inheritedFacetPolicies, isDatePrecision, isInlineReference, isBinnedRangeFacet, isUnsatisfiable, joinGraph, labelFieldOf, labelSourceNamesOf, labelTargetNamesOf, localLookupTargetsOf, nestedReferenceType, outputFields, physicalFields, referencedTargetsOf, referenceFields, storedFacetRanges, storedTargetOf, } from '@lde/search/adapter';
3
3
  import { buildSearchParams, escapeFilterValue, } from './query-compiler.js';
4
4
  import { deriveCollectionName } from './collection-name.js';
5
5
  import { resolveProjection, } from './lookup.js';
@@ -764,11 +764,11 @@ export function parseSearchResponse(response, searchType, labels, schema, refere
764
764
  for (const facet of response.facet_counts ?? []) {
765
765
  const labelled = referenceFacets.has(facet.field_name);
766
766
  // A binned facet echoes the declared range key as the bucket value; look
767
- // the bin’s half-open bounds back up by key so the bucket is
768
- // self-describing.
767
+ // the bin’s half-open bounds back up by key, in stored terms, so the
768
+ // bucket is self-describing.
769
769
  const field = fieldNamed(searchType, facet.field_name);
770
770
  const rangesByKey = field !== undefined && isBinnedRangeFacet(field)
771
- ? new Map(field.facetRanges.map((range) => [range.key, range]))
771
+ ? new Map(storedFacetRanges(field).map((range) => [range.key, range]))
772
772
  : undefined;
773
773
  // A boolean facet is reported with the values stringified; recover the
774
774
  // boolean so the bucket carries the term the `is` filter expects.
@@ -853,11 +853,23 @@ function logicalValue(flat, field, labels, schema, referents) {
853
853
  : undefined;
854
854
  }
855
855
  case 'integer':
856
- case 'number':
857
- case 'date': {
856
+ case 'number': {
858
857
  const value = flat[field.name];
859
858
  return typeof value === 'number' ? value : undefined;
860
859
  }
860
+ case 'date': {
861
+ const seconds = flat[field.name];
862
+ if (typeof seconds !== 'number') {
863
+ return undefined;
864
+ }
865
+ // An index built before the precision companion existed has none; the
866
+ // seconds alone can always be read as a date-time.
867
+ const precision = flat[physicalFields(field).precision];
868
+ return {
869
+ seconds,
870
+ precision: isDatePrecision(precision) ? precision : 'dateTime',
871
+ };
872
+ }
861
873
  case 'boolean':
862
874
  // A boolean is always present; an absent value means false.
863
875
  return flat[field.name] === true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lde/search-typesense",
3
- "version": "0.41.0",
3
+ "version": "0.43.0",
4
4
  "description": "Typesense implementation of the @lde/search SearchEngine port: collection-schema builder, query compiler, label-resolving result reconstruction, and blue/green index lifecycle. Engine-specific (Typesense) but domain-agnostic.",
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.34.0",
28
+ "@lde/search": "^0.36.0",
29
29
  "@lde/text-normalization": "^0.3.0",
30
30
  "tslib": "^2.3.0",
31
31
  "typesense": "^3.1.1"