If you're using a nested hierarchicalCategories structure and want to leverage it for Query Categorization, you'll need to configure both facets and Query Categorization settings appropriately in the Algolia Dashboard.
1. Ensure your data schema follows the expected structure
Before making any configuration changes, verify that your records are structured like this:
{
"name": "banana",
"description": "...",
"price": 3.45,
"hierarchicalCategories": {
"lvl0": "Food",
"lvl1": "Food > Produce",
"lvl2": "Food > Produce > Fruits"
}
}Each level in the hierarchy (e.g., lvl0, lvl1, lvl2) should represent a progressively deeper categorization.
2. Configure hierarchicalCategories as facets
To make these hierarchical attributes available for Query Categorization:
Go to the Configuration tab in your Algolia Dashboard.
Navigate to the Facets section.
Add each level of your
hierarchicalCategoriesobject individually (e.g.,hierarchicalCategories.lvl0,hierarchicalCategories.lvl1, etc.).
Note: At this stage, you're defining which levels Algolia can use as filterable and analyzable facets.
3. Enable these attributes in Query Categorization settings
After saving your facet configuration:
Navigate to the Query Categorization tab in the dashboard.
Open the Category Settings section.
Add each hierarchical level (as previously configured) to the category mapping.
Additional Resources
For more detailed guidance on setup, configuration, and troubleshooting, see our full documentation on Query Categorization.