Guides / Getting insights and analytics / Leveraging analytics data / Query Suggestions

Adding Categories to Query Suggestions

You can enhance query suggestions by adding categories or scope to your suggestions list.

Category suggestions

Consider a Query Suggestions implementation that responds to the query “iphone”.

The standard approach is to present useful queries:

  • “iphone 7”
  • “iphone charger”
  • “iphone X cases”
  • “iphone X speakers”

With category suggestion, you can also present categories or scopes:

  • iphone
    • in phones
    • in accessories
    • in electronics

Your suggestions list can contain a mix of pure query suggestions and category suggestions.

Adding category information to your suggestions index

Adding categories to your suggestions can be done through your dashboard.

  1. From the Query Suggestions tab of your dashboard, select the suggestions index you want to add categories to.
  2. Scroll down until you find the Categories heading.
  3. Click on the Edit categories button.
  4. In the input field, type in the name of your category attribute and select the number of top categories you want to display for it.
  5. To the right of the input field, click Add.
  6. Once you’ve added all your categories, click Save.

Displaying categories

Once categories are set up, Algolia returns queries to your suggestions index with added category information. It will not automatically add the display logic for you. It’s up to you to choose:

  • how to display the category-based suggestions,
  • what to do when a category-based suggestions is clicked, selected, and hovered (we recommend redirecting to an InstantSearch page with a pre-filled query and adding a default filter for the chosen category).

To get a sense of what this looks like, check out our Query Suggestions demo.

Did you find this page helpful?