meilisearch / meilisearch-js-plugins

The search client to use Meilisearch with InstantSearch.
https://www.meilisearch.com
MIT License
476 stars 59 forks source link

distinct attribute in getMeilisearchResults is lost #1317

Closed thomas-lcdp closed 3 months ago

thomas-lcdp commented 3 months ago

Description distinct attribute passed in function getMeilisearchResults from autocomplete-client is lost when request meilisearch service.

Expected behavior distinct attribute is propagated to request

Screenshots or Logs image
In generated autocomplete-client.umd.js, I added a console.log in function fetchMeilisearchResults to display the queries.
We can see in console the distinct attribute is well present.

In network, we see the request send to meilisearch service and the distinct attribute has disappear.

Environment:

thomas-lcdp commented 3 months ago

My fault, bad usage of the params.

distinct must be under object meiliSearchParams and not directly under params

return getMeilisearchResults({
      searchClient,
      queries: [
        {
          indexName: defaultStoreIndex,
          query,
          params: {
            filters: ['_tags IN [HAS_STORE, IS_PHARMLAB]'],
            hitsPerPage: 3,
            clickAnalytics: true,
            meiliSearchParams: {
              distinct: 'store.id',
            },
          },
        },
      ],