Guides / Building Search UI / UI & UX patterns / Query Suggestions

Optimize Query Suggestions for React InstantSearch

We released React InstantSearch Hooks, a new InstantSearch library for React. We recommend using React InstantSearch Hooks in new projects or upgrading from React InstantSearch.

Once you’ve created a Query Suggestions index, you can leverage existing features such as Rules and synonyms to customize and boost the relevance of your suggestions.

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:

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 typoTolerance or 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.

Did you find this page helpful?