typesense / typesense-instantsearch-adapter

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

Issue with max_facet_values parameter in Typesense-InstantSearch Integration: missing from request payload #218

Open DidoMarchet opened 2 hours ago

DidoMarchet commented 2 hours ago

Hi,

I’m using "instantsearch.js": "^4.74.1" along with "typesense-instantsearch-adapter": "^2.8.0", and I’m having trouble figuring out why the max_facet_values parameter is being removed from the request payload.

Here are the parameters I’m passing:

{
  "q": "*",
  "query_by": "code",
  "facet_by": "tipology.code",
  "max_facet_values": 100
}

However, this is the request payload that’s being sent:

{
  "searches": [
    {
      "q": "*",
      "query_by": "code",
      "facet_by": "tipology.code",
      "highlight_full_fields": "code",
      "collection": "wines",
      "page": 1
    }
  ]
}

and the result:

Screenshot 2024-09-20 at 18 15 48

My goal is to retrieve the count of items per facet for my collection, but it only returns 10 facets because the max_facet_values parameter isn't included in the request.

I would appreciate any suggestions or insights on how to solve this issue!

Thanks and kind regards, Davide

jasonbosco commented 2 hours ago

Could you try the solution mentioned here: https://github.com/typesense/typesense-instantsearch-adapter/issues/177#issuecomment-1644629457 and the rest of the discussion?

DidoMarchet commented 2 hours ago

Hi @jasonbosco , thanks for the quick response!

I checked, but they are using the widget version, whereas I am using the programmatic version:

searchClient.value.search([
  {
    indexName: 'myindex',
    query: '',
    params: {
      q: "*",
      query_by: "code",
      facet_by: "tipology.code",
      max_facet_values: 100
    },
  },
]);

I also tried passing the limit parameter (here's the request payload):

{
  "q": "*",
  "query_by": "code",
  "facet_by": "tipology.code",
  "limit": 100,
  "highlight_full_fields": "code",
  "collection": "wines",
  "page": 1
}

But unfortunately, the facets still only return 10 :(

Any further suggestions would be greatly appreciated!

jasonbosco commented 2 hours ago

Hmmm, I'm not familiar with the programmatic version...

But I suspect that your first code snippet needs to use Algolia search parameter names, so that the typesense-instantsearch-adapter can transform it into Typesense parameters.

On a side note, any reason you're not using typesense-js directly if you need this level manual control?