Skip to main content
Version: next

Query suggestions

Since version 3.16

This guides explains how to configure the Algolia extension to retrieve query suggestions.

Enable query suggestions

To enable query suggestions in Algolia, you need to create a Query Suggestions index in the Algolia dashboard. This index stores popular search queries as suggestions that help users search faster. Go to your Algolia dashboard, select your application, then navigate to the Query Suggestions page. Click New Query Suggestions Index and specify your source index.

warning

Algolia will automatically generate the correct name for your Query Suggestions index following the pattern <name_of_source_index>_query_suggestions. You shouldn't need to modify the naming.

Algolia will automatically generate suggestions based on your search analytics, updating them daily. For detailed setup instructions including how to augment suggestions with external analytics or facet data, see the official Algolia Query Suggestions documentation.

Specify the query suggestions index

By default, Front-Commerce will return suggestions from all the default search indices (products, categories and pages). You can specify the query suggestions index to use by configuring the queryBuilders property in your configuration provider (more information on adding a configuration provider here).

Example configuration to only use the products query suggestions index

algoliaConfigProvider.ts
export const algoliaConfigProvider = () => ({
name: "customAlgolia",
values: {
algolia: {
queryBuilders: [
{
key: "queries",
indexSuffix: "query_suggestions",
// Only return suggestions for the products query suggestions index
suggestionIndexSuffixes: ["products"],
// default: ["products", "categories", "pages"]
},
],
},
},
});