@lde/search-typesense 0.49.0 → 0.50.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.
@@ -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;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
+ {"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,CA4BxB"}
@@ -62,6 +62,7 @@ export function buildCollectionDefinition(searchType, options = {}) {
62
62
  collection.enable_nested_fields = true;
63
63
  }
64
64
  if (options.defaultSortingField !== undefined) {
65
+ assertSortableByDefault(searchType, options.defaultSortingField);
65
66
  collection.default_sorting_field = options.defaultSortingField;
66
67
  }
67
68
  if (options.synonymSets !== undefined) {
@@ -133,6 +134,15 @@ function referenceDeclaration(searchType, field, schema, collectionNameFor) {
133
134
  cascade_delete: false,
134
135
  };
135
136
  }
137
+ /** Refuse a default sorting field that stores periods: Typesense sorts a
138
+ * collection by default on one stored number, and a period is stored as two
139
+ * bounds. */
140
+ function assertSortableByDefault(searchType, name) {
141
+ const field = searchType.fields.find((declared) => declared.name === name);
142
+ if (field !== undefined && physicalFields(field).period !== undefined) {
143
+ throw new Error(`The default sorting field “${name}” of “${searchType.name}” stores periods, which Typesense cannot sort a collection on by default: a period is stored as two bounds, not one number. Name a numeric field instead.`);
144
+ }
145
+ }
136
146
  /** The physical Typesense fields one declaration produces. */
137
147
  function typesenseFields(searchType, field, defaultLocale, defaultSortingField, schema, collectionNameFor) {
138
148
  // An internal field (no role) is projected as a reading device for the
@@ -259,7 +269,7 @@ function typesenseFields(searchType, field, defaultLocale, defaultSortingField,
259
269
  }
260
270
  /**
261
271
  * A `period` field – or the periods a lookup reads its literals as: its values
262
- * verbatim, stored for output but never indexed –
272
+ * as stated, stored for output but never indexed –
263
273
  * nothing filters or sorts on the text – and the two int64 bound companions
264
274
  * ({@link physicalFields}) that filters and sorts read instead. The bounds are
265
275
  * indexed for sorting whatever the field declares: a deployment may sort on a
@@ -566,14 +576,16 @@ function nestedLeafFields(prefix, field, defaultLocale, flattensToArray) {
566
576
  return fields;
567
577
  }
568
578
  if (names.period !== undefined) {
569
- // No filter reaches a nested period, so its value and its bounds are
570
- // stored for output and never indexed.
571
- return periodFields(field, names).map(({ name, type }) => ({
572
- name: nestedFieldName(prefix, name),
573
- type,
574
- index: false,
575
- optional: true,
576
- }));
579
+ // No filter or sort reaches a nested period, so an entry stores its values
580
+ // alone, for output, and no bounds (`storePeriods`).
581
+ return [
582
+ {
583
+ name: nestedFieldName(prefix, names.period.values),
584
+ type: typesenseValueType(field),
585
+ index: false,
586
+ optional: true,
587
+ },
588
+ ];
577
589
  }
578
590
  // A nested field can be `filterable` or `searchable`, never `facetable` or
579
591
  // `sortable` (`searchSchema`), so `filterable` is what indexes the value
@@ -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;AAqBrB;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;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C;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;AA2hBD;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD"}
@@ -435,8 +435,10 @@ function compileRange(field, range, prefix = '') {
435
435
  if (period !== undefined) {
436
436
  // Overlap: the period starts no later than the range ends, and ends no
437
437
  // earlier than it starts – so `1935/1955` matches 1940–1950.
438
- const startsBefore = max === undefined ? undefined : `${period.start}:<=${max}`;
439
- const endsAfter = min === undefined ? undefined : `${period.end}:>=${min}`;
438
+ const startsBefore = max === undefined
439
+ ? undefined
440
+ : `${qualify(prefix, period.start)}:<=${max}`;
441
+ const endsAfter = min === undefined ? undefined : `${qualify(prefix, period.end)}:>=${min}`;
440
442
  // Parenthesised, because the clause may stand beside others in an `||`.
441
443
  return startsBefore !== undefined && endsAfter !== undefined
442
444
  ? `(${startsBefore} && ${endsAfter})`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lde/search-typesense",
3
- "version": "0.49.0",
3
+ "version": "0.50.1",
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.40.0",
28
+ "@lde/search": "^0.41.1",
29
29
  "@lde/text-normalization": "^0.3.0",
30
30
  "tslib": "^2.3.0",
31
31
  "typesense": "^3.2.0"