meilisearch / meilisearch-js-plugins

The search client to use Meilisearch with InstantSearch.

Home Page:https://www.meilisearch.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve usage of the @algolia/autocomplete-plugin-recent-searches plugin

bidoubiwa opened this issue · comments

Description
Currently the recent-search plugins requires your document to contain a ObjectID field that itself contains the value of the query. This is a mistake on their part, see here.

This means that the index containing the query suggestion of another index must have an ObjectID field:
For example:

{
    "id": 1,
    "popularity": 1214,
    "query": "cooktop",
    "objectID": "cooktop"
  }

Additionally, ObjectID must also be added in the filterableAttributes

{
  "filterableAttributes": ["objectID"]
}

Solution
To tackle this issue, we should create our own getAlgoliaSearchParams, named getMeilisearchSearchParams.

That method should me similar to the one from algolia, but instead of using ObjectID it should use the query field in this line.