typesense-instantsearch-adapter 2.5.1 → 2.6.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 +40 -0
- package/dist/typesense-instantsearch-adapter.js +6 -2
- 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 +1 -0
- package/lib/Configuration.js.map +1 -1
- package/lib/SearchResponseAdapter.js +5 -2
- package/lib/SearchResponseAdapter.js.map +1 -1
- package/package.json +2 -2
- package/src/Configuration.js +2 -0
- package/src/SearchResponseAdapter.js +1 -0
package/README.md
CHANGED
|
@@ -365,10 +365,50 @@ 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
|
+
In order to use [`dynamicWidgets`](https://www.algolia.com/doc/api-reference/widgets/dynamic-facets/js/),
|
|
373
|
+
Instantsearch expects a parameter called [`renderingContent`](https://www.algolia.com/doc/api-reference/api-parameters/renderingContent/) to be set
|
|
374
|
+
which controls the display logic for this widget.
|
|
375
|
+
|
|
376
|
+
In Algolia, this configuration can be set via the dashboard or via the API.
|
|
377
|
+
But when using Typesense and this adapter, this setting has to be configured when instantiating the adapter like this:
|
|
378
|
+
|
|
379
|
+
```js
|
|
380
|
+
const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
|
|
381
|
+
server: {
|
|
382
|
+
apiKey: "xyz",
|
|
383
|
+
nodes: [
|
|
384
|
+
{
|
|
385
|
+
host: "localhost",
|
|
386
|
+
port: "8108",
|
|
387
|
+
path: "/",
|
|
388
|
+
protocol: "http",
|
|
389
|
+
},
|
|
390
|
+
],
|
|
391
|
+
},
|
|
392
|
+
renderingContent: {
|
|
393
|
+
// <<====== Required
|
|
394
|
+
facetOrdering: {
|
|
395
|
+
// <<====== Required: this controls the order in which the dynamic facets are displayed, and is *required* for the dynamicWidget to render
|
|
396
|
+
facets: {
|
|
397
|
+
order: ["size", "brand"], // <<===== Change this as needed
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
},
|
|
401
|
+
additionalSearchParameters,
|
|
402
|
+
});
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
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).
|
|
406
|
+
|
|
368
407
|
## Compatibility
|
|
369
408
|
|
|
370
409
|
| Typesense Server | typesense-instantsearch-adapter | instantsearch.js | react-instantsearch | vue-instantsearch | angular-instantsearch |
|
|
371
410
|
| ---------------- | ------------------------------- | ---------------- | ------------------- | ----------------- | --------------------- |
|
|
411
|
+
| \>= v0.25.0.rc12 | \>= v2.6.0 | \>= 4.51 | \>= 6.39 | \>= 4.8 | \>= 4.4 |
|
|
372
412
|
| \>= v0.24 | \>= v2.5.0 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |
|
|
373
413
|
| \>= v0.21 | \>= v2.0.0 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |
|
|
374
414
|
| \>= v0.19 | \>= v1.0.0 | \>= 4.2.0 | \>= 6.0.0 | \>= 2.2.1 | \>= 3.0.0 |
|
|
@@ -2250,6 +2250,7 @@ var Configuration = /*#__PURE__*/function () {
|
|
|
2250
2250
|
return params[key] === undefined ? delete params[key] : {};
|
|
2251
2251
|
});
|
|
2252
2252
|
});
|
|
2253
|
+
this.renderingContent = options.renderingContent;
|
|
2253
2254
|
}
|
|
2254
2255
|
|
|
2255
2256
|
(0,_babel_runtime_helpers_createClass__WEBPACK_IMPORTED_MODULE_1__["default"])(Configuration, [{
|
|
@@ -3074,7 +3075,7 @@ var SearchResponseAdapter = /*#__PURE__*/function () {
|
|
|
3074
3075
|
}, {
|
|
3075
3076
|
key: "adapt",
|
|
3076
3077
|
value: function adapt() {
|
|
3077
|
-
var adaptedResult = {
|
|
3078
|
+
var adaptedResult = _objectSpread({
|
|
3078
3079
|
hits: this.typesenseResponse.grouped_hits ? this._adaptGroupedHits(this.typesenseResponse.grouped_hits) : this._adaptHits(this.typesenseResponse.hits),
|
|
3079
3080
|
nbHits: this.typesenseResponse.found,
|
|
3080
3081
|
page: this.typesenseResponse.page - 1,
|
|
@@ -3084,7 +3085,10 @@ var SearchResponseAdapter = /*#__PURE__*/function () {
|
|
|
3084
3085
|
facets_stats: this._adaptFacetStats(this.typesenseResponse.facet_counts || {}),
|
|
3085
3086
|
query: this.typesenseResponse.request_params.q,
|
|
3086
3087
|
processingTimeMS: this.typesenseResponse.search_time_ms
|
|
3087
|
-
}
|
|
3088
|
+
}, this.configuration.renderingContent != null && {
|
|
3089
|
+
renderingContent: this.configuration.renderingContent
|
|
3090
|
+
}); // console.log(adaptedResult);
|
|
3091
|
+
|
|
3088
3092
|
|
|
3089
3093
|
return adaptedResult;
|
|
3090
3094
|
}
|