typesense-instantsearch-adapter 2.6.0-1 → 2.6.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 +0 -35
- package/dist/typesense-instantsearch-adapter.js +2 -25
- 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/lib/Configuration.js +0 -1
- package/lib/Configuration.js.map +1 -1
- package/lib/SearchResponseAdapter.js +2 -24
- package/lib/SearchResponseAdapter.js.map +1 -1
- package/package.json +3 -3
- package/src/Configuration.js +0 -2
- package/src/SearchResponseAdapter.js +0 -15
package/README.md
CHANGED
|
@@ -365,45 +365,10 @@ const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
|
|
|
365
365
|
});
|
|
366
366
|
```
|
|
367
367
|
|
|
368
|
-
### `dynamicWidgets`
|
|
369
|
-
|
|
370
|
-
> Available as of Typesense Server `v0.25.0.rc12`
|
|
371
|
-
|
|
372
|
-
This [`dynamicWidgets`](https://www.algolia.com/doc/api-reference/widgets/dynamic-facets/js/) widget works out of the box with no additional changes,
|
|
373
|
-
but if you want to control the order in which these facets are displayed in the UI
|
|
374
|
-
Instantsearch expects a parameter called [`renderingContent`](https://www.algolia.com/doc/api-reference/api-parameters/renderingContent/) to be set.
|
|
375
|
-
|
|
376
|
-
```js
|
|
377
|
-
const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
|
|
378
|
-
server: {
|
|
379
|
-
apiKey: "xyz",
|
|
380
|
-
nodes: [
|
|
381
|
-
{
|
|
382
|
-
host: "localhost",
|
|
383
|
-
port: "8108",
|
|
384
|
-
path: "/",
|
|
385
|
-
protocol: "http",
|
|
386
|
-
},
|
|
387
|
-
],
|
|
388
|
-
},
|
|
389
|
-
renderingContent: { // <<===== Add this, only if you want to control the order of the widgets displayed by dynamicWidgets
|
|
390
|
-
facetOrdering: {
|
|
391
|
-
facets: {
|
|
392
|
-
order: ["size", "brand"], // <<===== Change this as needed
|
|
393
|
-
},
|
|
394
|
-
},
|
|
395
|
-
},
|
|
396
|
-
additionalSearchParameters,
|
|
397
|
-
});
|
|
398
|
-
```
|
|
399
|
-
|
|
400
|
-
Read more about all available options for `renderingContent` in [Algolia's documentation here](https://www.algolia.com/doc/api-reference/api-parameters/renderingContent/?client=javascript#examples).
|
|
401
|
-
|
|
402
368
|
## Compatibility
|
|
403
369
|
|
|
404
370
|
| Typesense Server | typesense-instantsearch-adapter | instantsearch.js | react-instantsearch | vue-instantsearch | angular-instantsearch |
|
|
405
371
|
| ---------------- | ------------------------------- | ---------------- | ------------------- | ----------------- | --------------------- |
|
|
406
|
-
| \>= v0.25.0.rc12 | \>= v2.6.0 | \>= 4.51 | \>= 6.39 | \>= 4.8 | \>= 4.4 |
|
|
407
372
|
| \>= v0.24 | \>= v2.5.0 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |
|
|
408
373
|
| \>= v0.21 | \>= v2.0.0 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |
|
|
409
374
|
| \>= v0.19 | \>= v1.0.0 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |
|
|
@@ -2250,7 +2250,6 @@ var Configuration = /*#__PURE__*/function () {
|
|
|
2250
2250
|
return params[key] === undefined ? delete params[key] : {};
|
|
2251
2251
|
});
|
|
2252
2252
|
});
|
|
2253
|
-
this.renderingContent = options.renderingContent;
|
|
2254
2253
|
}
|
|
2255
2254
|
|
|
2256
2255
|
(0,_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1__["default"])(Configuration, [{
|
|
@@ -3073,28 +3072,9 @@ var SearchResponseAdapter = /*#__PURE__*/function () {
|
|
|
3073
3072
|
return adaptedResult;
|
|
3074
3073
|
}
|
|
3075
3074
|
}, {
|
|
3076
|
-
key: "_adaptRenderingContent",
|
|
3077
|
-
value: function _adaptRenderingContent(typesenseFacetCounts) {
|
|
3078
|
-
var _adaptedResult$facetO, _adaptedResult$facetO2;
|
|
3079
|
-
|
|
3080
|
-
var adaptedResult = Object.assign({}, this.configuration.renderingContent); // Only set facet ordering if the user has not set one
|
|
3081
|
-
|
|
3082
|
-
if (((_adaptedResult$facetO = adaptedResult.facetOrdering) === null || _adaptedResult$facetO === void 0 ? void 0 : (_adaptedResult$facetO2 = _adaptedResult$facetO.facets) === null || _adaptedResult$facetO2 === void 0 ? void 0 : _adaptedResult$facetO2.order) == null) {
|
|
3083
|
-
adaptedResult.facetOrdering = adaptedResult.facetOrdering || {};
|
|
3084
|
-
adaptedResult.facetOrdering.facets = adaptedResult.facetOrdering.facets || {};
|
|
3085
|
-
adaptedResult.facetOrdering.facets.order = typesenseFacetCounts.map(function (fc) {
|
|
3086
|
-
return fc["field_name"];
|
|
3087
|
-
});
|
|
3088
|
-
}
|
|
3089
|
-
|
|
3090
|
-
return adaptedResult;
|
|
3091
|
-
}
|
|
3092
|
-
}, {
|
|
3093
3075
|
key: "adapt",
|
|
3094
3076
|
value: function adapt() {
|
|
3095
|
-
var
|
|
3096
|
-
|
|
3097
|
-
var adaptedResult = _objectSpread({
|
|
3077
|
+
var adaptedResult = {
|
|
3098
3078
|
hits: this.typesenseResponse.grouped_hits ? this._adaptGroupedHits(this.typesenseResponse.grouped_hits) : this._adaptHits(this.typesenseResponse.hits),
|
|
3099
3079
|
nbHits: this.typesenseResponse.found,
|
|
3100
3080
|
page: this.typesenseResponse.page - 1,
|
|
@@ -3104,10 +3084,7 @@ var SearchResponseAdapter = /*#__PURE__*/function () {
|
|
|
3104
3084
|
facets_stats: this._adaptFacetStats(this.typesenseResponse.facet_counts || {}),
|
|
3105
3085
|
query: this.typesenseResponse.request_params.q,
|
|
3106
3086
|
processingTimeMS: this.typesenseResponse.search_time_ms
|
|
3107
|
-
}
|
|
3108
|
-
renderingContent: adaptedRenderingContent
|
|
3109
|
-
} : null); // console.log(adaptedResult);
|
|
3110
|
-
|
|
3087
|
+
}; // console.log(adaptedResult);
|
|
3111
3088
|
|
|
3112
3089
|
return adaptedResult;
|
|
3113
3090
|
}
|