Improve search results by filtering by doc version#722
Conversation
Signed-off-by: SuperCoolPencil <thesupercoolpencil@gmail.com>
27abbca to
43ca2a1
Compare
|
how to test it? |
|
You can test this by inspecting the docsearch initialization in the page source across different sections. On the homepage, you'll see facetFilters: ["version:2.14.0"] (defaulting to latest). On any versioned doc page (e.g., /docs/2.10.0/...), the filter will dynamically update to match that version. You can also verify the live requests in the browser's network tab assearching will now send the version facet to Algolia, ensuring results are about the current context. also added docsearch:version meta tags to doc pages to help the crawler maintain this scoping in future index updates. |
|
is it possible to test it here? -> https://deploy-preview-722--goharbor-io.netlify.app/ where this PR is deplyed? |
|
Ah! so the front-end implementation is correct the meta tag is populating properly and the search query is sending the expected version filter. The issue is on the Algolia side. I checked the index and it doesn't currently have a "version" attribute configured for records, nor does it seem to have any content indexed for 2.8.0 yet. This is why on the deployment the search comes up empty We'll likely need to update the DocSearch crawler config to extract that meta tag and add the version field to the index settings before the filtering will work. |
|
so what is needed on algolia side to index? |
|
The crawler needs to know how to extract the docs version from the page HTML. You’ll need to add a selector for the "selectors": {
"version": {
"selector": "meta[name='docsearch:version']",
"attribute": "content"
}
}In the Algolia dashboard for the Configuration > Facets and add The crawler config probably has a set of allowed paths (usually via /docs/2.8.0/are included, otherwise the crawler will skip them entirely. After that Once the config changes are in place and the |
Hey everyone,
I saw the message on Slack (https://cloud-native.slack.com/archives/CC1E09J6S/p1777501279083679) about the search results being a bit confusing because they show every doc version at once. I wanted to help out, so I've put together this fix for #626.
I've updated the Algolia DocSearch initialization to automatically filter results based on the version of the docs the user is currently viewing. If you're on the homepage or other non-versioned pages, it'll default to showing results for the latest stable version.
I also added a docsearch:version meta tag to the doc pages to help the crawler keep things organized in the future.
Let me know what you think!