typesense-instantsearch-adapter 2.8.0 → 2.9.0-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.
- package/README.md +36 -3
- package/dist/typesense-instantsearch-adapter.js +8171 -6532
- 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 +27 -33
- package/lib/Configuration.js.map +1 -1
- package/lib/FacetSearchResponseAdapter.js +2 -12
- package/lib/FacetSearchResponseAdapter.js.map +1 -1
- package/lib/SearchRequestAdapter.js +113 -140
- package/lib/SearchRequestAdapter.js.map +1 -1
- package/lib/SearchResponseAdapter.js +29 -66
- package/lib/SearchResponseAdapter.js.map +1 -1
- package/lib/TypesenseInstantsearchAdapter.js +13 -38
- package/lib/TypesenseInstantsearchAdapter.js.map +1 -1
- package/lib/support/utils.js +1 -3
- package/lib/support/utils.js.map +1 -1
- package/package.json +27 -27
- package/scripts/postinstall.js +2 -2
- package/src/Configuration.js +5 -3
- package/src/FacetSearchResponseAdapter.js +1 -1
- package/src/SearchRequestAdapter.js +35 -14
- package/src/SearchResponseAdapter.js +11 -11
- package/src/TypesenseInstantsearchAdapter.js +9 -3
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`
|
|
@@ -581,7 +614,7 @@ const search = instantsearch({
|
|
|
581
614
|
if (query !== "") {
|
|
582
615
|
// Get embedding for the query
|
|
583
616
|
let response = await fetch(
|
|
584
|
-
"http://localhost:8000/embedding?" + new URLSearchParams({ q: query }) // <=== Embedding API
|
|
617
|
+
"http://localhost:8000/embedding?" + new URLSearchParams({ q: query }), // <=== Embedding API
|
|
585
618
|
);
|
|
586
619
|
|
|
587
620
|
let parsedResponse = await response.json();
|
|
@@ -592,7 +625,7 @@ const search = instantsearch({
|
|
|
592
625
|
helper
|
|
593
626
|
.setQueryParameter(
|
|
594
627
|
"typesenseVectorQuery", // <=== Special parameter that only works in typesense-instantsearch-adapter@2.7.0-3 and above
|
|
595
|
-
`vectors:([${parsedResponse["embedding"].join(",")}], k:${totalNearestNeighborsToFetch})
|
|
628
|
+
`vectors:([${parsedResponse["embedding"].join(",")}], k:${totalNearestNeighborsToFetch})`,
|
|
596
629
|
)
|
|
597
630
|
.setPage(page)
|
|
598
631
|
.search();
|