Skip to main content
Use Query Suggestions to help users find popular searches as they type. Query Suggestions creates an from popular searches. You can use this index to show search suggestions. After you configure the Query Suggestions index, use the autocomplete widget to show suggestions. When users select a suggestion, the widget navigates to the suggestion URL or refines the search query, depending on your configuration.

Open CodeSandbox

Run and edit the Query Suggestions UI example in CodeSandbox.

Explore source code

Browse the source code for the Query Suggestions UI example on GitHub.
This widget is and is subject to change in minor versions.

Add Query Suggestions and recent searches

The widget displays suggestions from a Query Suggestions index and recent searches stored in the browser’s local storage. Enable them with showQuerySuggestions and showRecent:
JavaScript

Refine results with suggestions

To keep users on the same page, set up a multi-index search experience that uses the selected suggestion to search the main index. The autocomplete widget targets the index that contains the suggestions. The other widgets target the main index that contains your records. For more information, see Multi-index search.
JavaScript

Customize recent searches

Pass an object to showRecent to customize how each recent search renders:
JavaScript

Customize suggestions

Pass an object to showQuerySuggestions to customize each suggestion and apply search parameters to the suggestions query:
JavaScript
Use ReverseHighlight to emphasize the text that doesn’t match the query. This is a common style for Query Suggestions. The widget has no built-in category grouping for suggestions and there’s no categoryAttribute. To show a category next to a suggestion, render the category in the suggestion’s item template.

See also

Last modified on July 21, 2026