typesense / typesense-instantsearch-adapter

A JS adapter library to build rich search interfaces with Typesense and InstantSearch.js
MIT License
406 stars 63 forks source link

How to pass facets parameters to typesense search params ? #136

Closed ycouble closed 1 year ago

ycouble commented 1 year ago

Documentation and Type definitions state that it is possible to provide the facet_by parameter to the adapter additionalSearchParameters, but they are completely ignored by the adapter and not forwarded to typesense.

I've narrowed the problem down to this line of code: https://github.com/typesense/typesense-instantsearch-adapter/blob/33b6c291c2cfe6b35b9ecf452acf09e7e046660b/src/SearchRequestAdapter.js#L287

Which seems to tell to get facet params from the search request and not from the adapter params.

Is there a conventional way to pass a facet_by parameter with the instant search adapter ? If so how ?

I was expecting to provide them at the adapter definition level:

import TypesenseInstantSearchAdapter from "typesense-instantsearch-adapter";

const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
  server: {
    apiKey: "abcd", // Be sure to use the search-only-api-key
    nodes: [
      {
        host: "localhost",
        port: "8108",
        protocol: "http"
      }
    ]
  },
  additionalSearchParameters: {
    query_by: "title,authors",
    facet_by: "editor",
  }
});

Cheers, Yoann

jasonbosco commented 1 year ago

Summarizing our Slack conversation here:

facet_by is handled by instantsearch through all the filter widgets like refinementList, menu, etc. so you shouldn’t have to set it manually.

So if you want to modify how faceting works, you want to build a custom widget using one of the Instantsearch connecters.