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

Optimize Query Suggestions for React InstantSearch

This is the React InstantSearch v7 documentation. React InstantSearch v7 is the latest version of React InstantSearch and the stable version of React InstantSearch Hooks.

If you were using React InstantSearch v6, you can upgrade to v7.

If you were using React InstantSearch Hooks, you can still use the React InstantSearch v7 documentation, but you should check the upgrade guide for necessary changes.

If you want to keep using React InstantSearch v6, you can find the archived documentation.

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

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:

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 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?