@lde/search-typesense 0.34.0 → 0.36.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.
@@ -1 +1 @@
1
- {"version":3,"file":"collection-definition.d.ts","sourceRoot":"","sources":["../src/collection-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAExD,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AAerB,0EAA0E;AAC1E,MAAM,WAAW,2BAA2B;IAC1C;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,MAAM,CAAC;IAChE;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAC/B;;;4BAGwB;IACxB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,kEAAkE;IAClE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC,kEAAkE;IAClE,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,2BAAgC,GACxC,sBAAsB,CA2BxB"}
1
+ {"version":3,"file":"collection-definition.d.ts","sourceRoot":"","sources":["../src/collection-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAExD,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,UAAU,EAChB,MAAM,aAAa,CAAC;AAgBrB,0EAA0E;AAC1E,MAAM,WAAW,2BAA2B;IAC1C;;;;;;;;;;;;;;OAcG;IACH,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,MAAM,CAAC;IAChE;;;;;;;;;;;;;;;;OAgBG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAC/B;;;4BAGwB;IACxB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAChC,kEAAkE;IAClE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC;IACtC,kEAAkE;IAClE,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiDG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,2BAAgC,GACxC,sBAAsB,CA2BxB"}
@@ -1,4 +1,4 @@
1
- import { displayFieldPattern, ID_FIELD, isInlineReference, isInternalField, joinGraph, localLookupTargetsOf, TARGET_FIELD, nestedFieldName, nestedReferenceType, physicalFields, } from '@lde/search/adapter';
1
+ import { displayFieldPattern, ID_FIELD, isInlineReference, isInternalField, isBinnedRangeFacet, joinGraph, localLookupTargetsOf, TARGET_FIELD, nestedFieldName, nestedReferenceType, physicalFields, } from '@lde/search/adapter';
2
2
  import { deriveCollectionName } from './collection-name.js';
3
3
  /**
4
4
  * Build a Typesense collection definition from the unified {@link SearchType}, so
@@ -205,7 +205,10 @@ function typesenseFields(searchType, field, defaultLocale, defaultSortingField,
205
205
  // the field itself stays a plain stored value – which is also what keeps
206
206
  // a membership filter on it exact (`compileMembership`).
207
207
  facet: names.facet === field.name,
208
- sort: field.sortable ?? false,
208
+ // Typesense answers a binned facet only on a field indexed for
209
+ // sorting, so a field declaring bins is, sortable or not.
210
+ sort: field.sortable === true ||
211
+ (field.facetable === true && isBinnedRangeFacet(field)),
209
212
  // A `required` field is non-optional; so is the `default_sorting_field`,
210
213
  // which Typesense requires to be present. Everything else may be absent.
211
214
  optional: field.required !== true && field.name !== defaultSortingField,
@@ -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,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,WAAW,EAClB,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,wBAA6B,GACrC,YAAY,CAAC,MAAM,CAAC,CAkCtB;AAwgBD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD"}
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,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,WAAW,EAClB,UAAU,EAAE,UAAU,EACtB,OAAO,GAAE,wBAA6B,GACrC,YAAY,CAAC,MAAM,CAAC,CAkCtB;AA0gBD;;;;GAIG;AACH,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, isRangeFacet, isWelded, joinGraph, localLookupTargetsOf, matchLanguage, pageForOffset, physicalFields, nestedReferenceType, resolvePath, searchableFields, } from '@lde/search/adapter';
2
+ import { fieldNamed, filterOperator, filterOperatorFor, ID_FIELD, isoToUnixSeconds, 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),
@@ -45,11 +45,13 @@ export function buildSearchParams(query, searchType, options = {}) {
45
45
  /**
46
46
  * The `facet_by` clause. A facet on a numeric field that declares
47
47
  * {@link SearchField.facetRanges} faceted into those fixed half-open `[min, max)`
48
- * bins (a histogram); every other facet is a plain per-value facet on the
48
+ * bins; every other facet is a plain per-value facet on the
49
49
  * field the declaration facets ({@link physicalFields} – the field itself, or
50
50
  * the `${name}_facet` companion of a reference inheriting a facet policy).
51
51
  * Typesense range syntax is already start-inclusive/end-exclusive, so the
52
- * declared bounds pass straight through with no boundary fix-up.
52
+ * declared bounds pass straight through with no boundary fix-up. A numeric
53
+ * facet, binned or not, comes back with `stats` over every matching value,
54
+ * which carry its extent.
53
55
  */
54
56
  function compileFacetBy(facets, searchType, schema) {
55
57
  return facets
@@ -58,7 +60,7 @@ function compileFacetBy(facets, searchType, schema) {
58
60
  if (field === undefined) {
59
61
  return name;
60
62
  }
61
- return isRangeFacet(field)
63
+ return isBinnedRangeFacet(field)
62
64
  ? compileRangeFacet(field.name, field.facetRanges)
63
65
  : (physicalFields(field, schema).facet ?? name);
64
66
  })
package/dist/search.d.ts CHANGED
@@ -116,6 +116,16 @@ export interface TypesenseSearchResponse {
116
116
  readonly value: string;
117
117
  readonly count: number;
118
118
  }[];
119
+ /** A numeric facet’s value statistics over the matching documents, binned
120
+ * or not and whatever the bucket cap; `min`/`max` are absent when none
121
+ * holds a value. (Its `sum` and `avg` overflow on large values; unused.) */
122
+ readonly stats?: {
123
+ readonly min: number;
124
+ readonly max: number;
125
+ } | {
126
+ readonly min?: never;
127
+ readonly max?: never;
128
+ };
119
129
  }[];
120
130
  }
121
131
  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E,CAAC;IAC1E,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS;QAC/B;;2EAEmE;QACnE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;QAC5B,QAAQ,CAAC,MAAM,EAAE,SAAS;YACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;YACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;SACxB,EAAE,CAAC;QACJ;;qFAE6E;QAC7E,QAAQ,CAAC,KAAK,CAAC,EACX;YAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;YAAC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;SAAE,GAC9C;YAAE,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC;YAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,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, fieldNamed, isInlineReference, isRangeFacet, isUnsatisfiable, joinGraph, labelFieldOf, labelSourceNamesOf, labelTargetNamesOf, localLookupTargetsOf, nestedReferenceType, outputFields, physicalFields, referencedTargetsOf, referenceFields, storedTargetOf, } from '@lde/search/adapter';
2
+ import { assertTypeInSchema, assertValidQuery, displayLangOf, facetableFields, fieldNamed, isInlineReference, isBinnedRangeFacet, isUnsatisfiable, joinGraph, labelFieldOf, labelSourceNamesOf, labelTargetNamesOf, localLookupTargetsOf, nestedReferenceType, outputFields, physicalFields, referencedTargetsOf, referenceFields, 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';
@@ -579,16 +579,17 @@ export function parseSearchResponse(response, searchType, labels, schema, refere
579
579
  const facets = {};
580
580
  for (const facet of response.facet_counts ?? []) {
581
581
  const labelled = referenceFacets.has(facet.field_name);
582
- // A range facet echoes the declared range key as the bucket value; look the
583
- // bin's half-open bounds back up by key so the bucket is self-describing.
582
+ // A binned facet echoes the declared range key as the bucket value; look
583
+ // the bin’s half-open bounds back up by key so the bucket is
584
+ // self-describing.
584
585
  const field = fieldNamed(searchType, facet.field_name);
585
- const rangesByKey = field !== undefined && isRangeFacet(field)
586
+ const rangesByKey = field !== undefined && isBinnedRangeFacet(field)
586
587
  ? new Map(field.facetRanges.map((range) => [range.key, range]))
587
588
  : undefined;
588
589
  // A boolean facet is reported with the values stringified; recover the
589
590
  // boolean so the bucket carries the term the `is` filter expects.
590
591
  const booleanFacet = field?.kind === 'boolean';
591
- facets[facet.field_name] = facet.counts.map((bucket) => {
592
+ const buckets = facet.counts.map((bucket) => {
592
593
  const label = labelled ? labels.get(bucket.value) : undefined;
593
594
  const range = rangesByKey?.get(bucket.value);
594
595
  return {
@@ -600,6 +601,12 @@ export function parseSearchResponse(response, searchType, labels, schema, refere
600
601
  ...(booleanFacet ? { is: bucket.value === 'true' } : {}),
601
602
  };
602
603
  });
604
+ // Only a numeric facet’s stats carry a min and max.
605
+ const stats = facet.stats;
606
+ facets[facet.field_name] =
607
+ stats?.min === undefined
608
+ ? { buckets }
609
+ : { buckets, extent: { min: stats.min, max: stats.max } };
603
610
  }
604
611
  return { hits, total: response.found, facets };
605
612
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lde/search-typesense",
3
- "version": "0.34.0",
3
+ "version": "0.36.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,17 +25,17 @@
25
25
  "!**/*.tsbuildinfo"
26
26
  ],
27
27
  "dependencies": {
28
- "@lde/search": "^0.29.0",
28
+ "@lde/search": "^0.30.0",
29
29
  "@lde/text-normalization": "^0.2.0",
30
30
  "tslib": "^2.3.0",
31
31
  "typesense": "^3.1.1"
32
32
  },
33
33
  "devDependencies": {
34
- "n3": "^2.7.12",
34
+ "n3": "^2.13.12",
35
35
  "testcontainers": "^12.1.0"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "@lde/dataset": "^0.8.0",
39
- "@lde/pipeline": "^0.37.0"
39
+ "@lde/pipeline": "^0.38.0"
40
40
  }
41
41
  }