Algolia search is not prioritizing v5 documentation over previous versions (v1-v4).
Algolia ranking is primarily controlled through the Algolia Dashboard, not through Docusaurus configuration. Here are the steps to fix this:
-
Go to Algolia Dashboard
- Navigate to: https://www.algolia.com/apps/6C0XLHGK46/explorer/browse/juicebox
- Login with your Algolia account
-
Configure Custom Ranking
- Go to Indices > juicebox > Ranking tab
- Scroll to Custom Ranking section
- Add a new custom ranking attribute (e.g.,
version_priority) - Set ranking values:
- v5 docs:
10(highest) - v4 docs:
5 - v3 docs:
3 - v2 docs:
2 - v1 docs:
1 - No version:
0
- v5 docs:
-
Update Index Records
- You'll need to add the
version_priorityattribute to each record - This can be done via:
- Algolia API (bulk update)
- Algolia Dashboard (manual, not recommended for large indices)
- Custom indexing script
- You'll need to add the
-
Enable Version Facet
- In Algolia Dashboard, go to Indices > juicebox > Facets
- Add
versionas a facet attribute (if it exists in your index) - Or add
urlas a facet and use pattern matching
-
Update Docusaurus Config
- If you have a
versionfacet, you can use:searchParameters: { optionalFilters: ['version:v5'], }
- If you have a
Create a custom search component that modifies the search query to boost v5 results:
- Create
src/theme/SearchBar/index.js - Override the default Algolia search component
- Add custom ranking logic in the search query
If Docusaurus's Algolia plugin doesn't include version information:
- Check what attributes are currently indexed
- If
versionis not indexed, you may need to:- Use a custom Algolia plugin
- Or modify the Docusaurus Algolia plugin configuration
- Or use a post-processing script to add version attributes
The docusaurus.config.js file includes searchParameters that can be used once custom ranking is set up in the Algolia dashboard.
After making changes:
- Wait for Algolia to re-index (can take a few minutes)
- Test searches in the documentation site
- Verify v5 results appear first
-
Docusaurus's
@docusaurus/theme-search-algoliaplugin automatically indexes:titlecontentheadingsurltype(page, doc, etc.)
-
Custom attributes like
versionmay not be automatically indexed unless configured in the Algolia plugin or dashboard. -
The MCP server has version extraction logic, but this is separate from Algolia indexing.