typesense-instantsearch-adapter 2.8.0 → 2.9.0-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.
- package/README.md +34 -1
- package/dist/typesense-instantsearch-adapter.js +14 -1
- package/dist/typesense-instantsearch-adapter.js.map +1 -1
- package/dist/typesense-instantsearch-adapter.min.js +1 -1
- package/dist/typesense-instantsearch-adapter.min.js.map +1 -1
- package/index.d.ts +4 -0
- package/lib/Configuration.js +5 -1
- package/lib/Configuration.js.map +1 -1
- package/lib/SearchRequestAdapter.js +9 -0
- package/lib/SearchRequestAdapter.js.map +1 -1
- package/package.json +1 -1
- package/src/Configuration.js +2 -0
- package/src/SearchRequestAdapter.js +8 -0
package/README.md
CHANGED
|
@@ -506,7 +506,7 @@ const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
|
|
|
506
506
|
brand: { exactMatch: false }, // <========== Add this to do non-exact word-level filtering
|
|
507
507
|
category: { exactMatch: false },
|
|
508
508
|
},
|
|
509
|
-
|
|
509
|
+
collectionSpecificFilterByOptions: {
|
|
510
510
|
collection1: {
|
|
511
511
|
brand: { exactMatch: false },
|
|
512
512
|
},
|
|
@@ -515,6 +515,39 @@ const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
|
|
|
515
515
|
});
|
|
516
516
|
```
|
|
517
517
|
|
|
518
|
+
### Disabling overrides for certain sorts
|
|
519
|
+
|
|
520
|
+
> Available as of typesense-instantsearch-adapter `2.9.0-0`
|
|
521
|
+
|
|
522
|
+
Here's a way to disable overrides / curation rules, when users select a particular sort order:
|
|
523
|
+
|
|
524
|
+
```js
|
|
525
|
+
const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
|
|
526
|
+
server: {
|
|
527
|
+
apiKey: "xyz",
|
|
528
|
+
nodes: [
|
|
529
|
+
{
|
|
530
|
+
host: "localhost",
|
|
531
|
+
port: "8108",
|
|
532
|
+
path: "/",
|
|
533
|
+
protocol: "http",
|
|
534
|
+
},
|
|
535
|
+
],
|
|
536
|
+
},
|
|
537
|
+
sortByOptions: {
|
|
538
|
+
"field1:desc,field2:desc": { enable_overrides: false }, // <========== Add this to disable sorting when this particular Typesense `sort_by` string is generated by the sortBy widget
|
|
539
|
+
},
|
|
540
|
+
collectionSpecificSortByOptions: {
|
|
541
|
+
collection2: {
|
|
542
|
+
"field1:desc,field2:desc": { enable_overrides: false },
|
|
543
|
+
},
|
|
544
|
+
}, // <======= Use this parameter if multiple collections share the same field names, and you want to use different options for each field. This will override sortByOptions for that particular collection.
|
|
545
|
+
additionalSearchParameters,
|
|
546
|
+
});
|
|
547
|
+
```
|
|
548
|
+
|
|
549
|
+
If you have a sortBy widgets configured with an indexName value of `products/sort/price:asc` for eg, then the key inside `sortByOptions` should be `price:asc`.
|
|
550
|
+
|
|
518
551
|
### Grouped Hits
|
|
519
552
|
|
|
520
553
|
> Available as of typesense-instantsearch-adapter `2.7.1-4`
|
|
@@ -2209,8 +2209,10 @@ var Configuration = /*#__PURE__*/function () {
|
|
|
2209
2209
|
_options$flattenGroup,
|
|
2210
2210
|
_options$facetByOptio,
|
|
2211
2211
|
_options$filterByOpti,
|
|
2212
|
+
_options$sortByOption,
|
|
2212
2213
|
_options$collectionSp2,
|
|
2213
|
-
_options$collectionSp3
|
|
2214
|
+
_options$collectionSp3,
|
|
2215
|
+
_options$collectionSp4;
|
|
2214
2216
|
|
|
2215
2217
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
2216
2218
|
|
|
@@ -2250,8 +2252,10 @@ var Configuration = /*#__PURE__*/function () {
|
|
|
2250
2252
|
this.flattenGroupedHits = (_options$flattenGroup = options.flattenGroupedHits) !== null && _options$flattenGroup !== void 0 ? _options$flattenGroup : true;
|
|
2251
2253
|
this.facetByOptions = (_options$facetByOptio = options.facetByOptions) !== null && _options$facetByOptio !== void 0 ? _options$facetByOptio : {};
|
|
2252
2254
|
this.filterByOptions = (_options$filterByOpti = options.filterByOptions) !== null && _options$filterByOpti !== void 0 ? _options$filterByOpti : {};
|
|
2255
|
+
this.sortByOptions = (_options$sortByOption = options.sortByOptions) !== null && _options$sortByOption !== void 0 ? _options$sortByOption : {};
|
|
2253
2256
|
this.collectionSpecificFacetByOptions = (_options$collectionSp2 = options.collectionSpecificFacetByOptions) !== null && _options$collectionSp2 !== void 0 ? _options$collectionSp2 : {};
|
|
2254
2257
|
this.collectionSpecificFilterByOptions = (_options$collectionSp3 = options.collectionSpecificFilterByOptions) !== null && _options$collectionSp3 !== void 0 ? _options$collectionSp3 : {};
|
|
2258
|
+
this.collectionSpecificSortByOptions = (_options$collectionSp4 = options.collectionSpecificSortByOptions) !== null && _options$collectionSp4 !== void 0 ? _options$collectionSp4 : {};
|
|
2255
2259
|
}
|
|
2256
2260
|
|
|
2257
2261
|
(0,_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1__["default"])(Configuration, [{
|
|
@@ -2794,6 +2798,8 @@ var SearchRequestAdapter = /*#__PURE__*/function () {
|
|
|
2794
2798
|
}, {
|
|
2795
2799
|
key: "_buildSearchParameters",
|
|
2796
2800
|
value: function _buildSearchParameters(instantsearchRequest) {
|
|
2801
|
+
var _this$configuration$c2, _this$configuration$s;
|
|
2802
|
+
|
|
2797
2803
|
var params = instantsearchRequest.params;
|
|
2798
2804
|
var indexName = instantsearchRequest.indexName;
|
|
2799
2805
|
|
|
@@ -2847,6 +2853,13 @@ var SearchRequestAdapter = /*#__PURE__*/function () {
|
|
|
2847
2853
|
|
|
2848
2854
|
if (params.typesenseVectorQuery) {
|
|
2849
2855
|
typesenseSearchParams.vector_query = params.typesenseVectorQuery;
|
|
2856
|
+
} // Allow for conditional disabling of overrides, for particular sort orders
|
|
2857
|
+
|
|
2858
|
+
|
|
2859
|
+
var sortByOption = ((_this$configuration$c2 = this.configuration.collectionSpecificSortByOptions) === null || _this$configuration$c2 === void 0 || (_this$configuration$c2 = _this$configuration$c2[adaptedCollectionName]) === null || _this$configuration$c2 === void 0 ? void 0 : _this$configuration$c2[typesenseSearchParams["sort_by"]]) || ((_this$configuration$s = this.configuration.sortByOptions) === null || _this$configuration$s === void 0 ? void 0 : _this$configuration$s[typesenseSearchParams["sort_by"]]);
|
|
2860
|
+
|
|
2861
|
+
if ((sortByOption === null || sortByOption === void 0 ? void 0 : sortByOption["enable_overrides"]) != null) {
|
|
2862
|
+
typesenseSearchParams["enable_overrides"] = sortByOption["enable_overrides"];
|
|
2850
2863
|
} // console.log(params);
|
|
2851
2864
|
// console.log(typesenseSearchParams);
|
|
2852
2865
|
// Filter out empty or null values, so we don't accidentally override values set in presets
|