Optimize Query Suggestions for React InstantSearch
On this page
Using Rules on your Query Suggestions index
By leveraging Rules on your Query Suggestions index, you can 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 display a banner in a rich autocomplete, for example.
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 search for “gta v” with no results because your record doesn’t contain this acronym. Then, “gta v” won’t be a suggestion, because the Query Suggestions feature only indexes suggestions which lead to results. “Grand Theft Auto V” would be a suggestion, assuming some users also search for the game this way.
To enable a better use experience, you can 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, facilitating them to make the query to get the best results.
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.