Optimize Query Suggestions for React InstantSearch
On this page
Using Rules on your Query Suggestions index
Using Rules on your Query Suggestions index allows you to customize the relevance of suggestions based on the user’s query or Rule context. You may also choose to apply some Rules globally. Here are some examples of what you can do with Rules:
- Change the ranking of suggestions, by promoting or hiding certain suggestions.
- Change the user’s query.
- Return custom JSON in the response to, for example, display a banner in the UI.
Using synonyms on your Query Suggestions index
Creating synonyms on a Query Suggestions index can help users pick a better query. For example, suppose you have a record for the game “Grand Theft Auto V”, but your users often unsuccessfully search for “gta v” (because your record doesn’t contain this acronym). “gta v” won’t be added to the index because the Query Suggestions feature only indexes suggestions which lead to results.
To enable a better user experience, create a one-way synonym for
"gta v" ⇒ "Grand Theft Auto V" in the suggestions index. Then, if users search for “gta v”,
the suggested query “Grand Theft Auto V” would appear.
Applying index settings to your Query Suggestions index
Just like any other index, a Query Suggestions index may benefit from index settings like
separatorsToIndex. You can set index settings on a Query Suggestions index by navigating to the Indices page of the dashboard and selecting Configuration.
Whenever your Query Suggestions index rebuilds, it preserves all your Rules, synonyms, and index settings.