Skip to main content
To help users with their search, Algolia provides Query Suggestions. This feature creates an of your user’s best queries. You can then use this index to propose suggestions to your users as they’re typing into the ais-search-box. Once you’ve configured the generation of the Query Suggestions index, you need to query this index as well. Use multi-index search to do that. This guide shows how to use a search box to display a list of suggestions and their associated categories. Once users select a suggestion, Algolia will apply the query and the category. If you’re building an autocomplete with Query Suggestions, you should use the Autocomplete library which lets you build a full-featured, accessible autocomplete experience. This is the recommended way of building an autocomplete search with Algolia. For more information, see:

Working example

Open CodeSandbox

Run and edit the Query Suggestions UI example in CodeSandbox.

Explore source code

Browse the source for the Query Suggestions UI example on GitHub.
This code has been specifically created for Vue 2. Some modifications may be required for it to work correctly in Vue 3.

Refine your results with suggestions

To set up multi-index search experience so users can select a suggestion and use it to search the main index:
1

Set up custom autocomplete component

Set up a custom autocomplete component with the Vue Autosuggest library.
2

Wrap the conponent in the connector

Wrap the autocomplete component with the ais-autocomplete connector. For more infomation, see Autocomplete.
Vue
3

Create the multi-index search experience

The ais-autocomplete widget reads from two indices: instant_search_demo_query_suggestions and instant_search. The first index widget is implied by the creation of the ais-instant-search widget.
Vue
A typical use of autocomplete is to display both relevant categories and suggestions. Then when a user selects a suggestion, both the suggestion and the associated category are used to refine the search. For this example, the relevant categories are stored on the suggestions . You must update your render function to display the categories with the suggestions. For simplicity and brevity of the code, assume that all suggestions have categories, but this isn’t the case in the actual dataset. Take a look at the complete example to see the actual implementation.
Vue
Now that you can display categories, you can use them to refine the main search. Use the ais-configure widget with disjunctiveFacets and disjunctiveFacetsRefinement. These two parameters are the same as internally used in a refinement list.
Vue
That’s it. When a suggestion is selected, both the query and the category are applied to the main search.
Last modified on July 22, 2026