-
Notifications
You must be signed in to change notification settings - Fork 149
feat(algolia): add facets based on version for search #1051
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: Christopher Haar <christopher.haar@upbound.io>
✅ Deploy Preview for crossplane ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
|
||
| {{ partialCached "footer" . }} | ||
| {{ partialCached "scripts" . }} | ||
| {{ partial "scripts" . }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is required because partialCached would cache the first version rendered and reuse it across pages, causing the wrong version filter to be applied.
jbw976
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very interesting @haarchri! Hopefully everything works smoothly after this PR gets merged 😂
One immediate question for you - do you know what the UX is going to be for showing multiple versions in the search? will the search popup make it clear which version each result is from? Will it favor newer versions over older versions? are you able to see this in your local testing, or do we have to merge this, update Algolia config, and see what happens?
jbw976
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RE: the Algolia config instructions
Add:
filterOnly(docsearch:version)
to Attributes for faceting
Looks like we have a version attribute for faceting already on https://dashboard.algolia.com/apps/9UXKYX61NK/explorer/configuration/crossplane/facets, is that useful?
I was able to do a network inspect on the preview site and when searching it does look like facetFilters are being sent in the request, so that's a good sign 😉
facetFilters=%5B%22docsearch%3Aversion%3A0.0.0-master%22%5D
| {{/* Only filter if we have a version parameter, which means the meta tag exists */}} | ||
| {{ if .Page.Params.version }} | ||
| {{ if eq .Page.Params.version "master" }} | ||
| {{ $cur_ver = "0.0.0-master" }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 0.0.0-master instead of just master? does it need the numbers to work correctly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, that's how we're setting it in the header: https://github.com/crossplane/docs/blob/master/themes/geekboot/layouts/partials/header.html#L11-L12

When browsing older documentation versions (for example, v1.20), search results currently all content from latest....
This leads to confusion when users discover features or APIs in search results that don’t actually exist in the version they’re viewing.
This PR introduces version-aware search filtering using Algolia facet filters. https://www.algolia.com/doc/guides/managing-results/refine-results/faceting
Search results will be restricted to the documentation version the user is currently viewing.
.Page.Params.version.facetFiltersvalue dynamically:docsearch:version:0.0.0-master, which matches the existing meta tag convention where master is labeled0.0.0-masterto keep it de-ranked in searchBackground
Each page already includes:
which the Algolia crawler indexes.
Required: Algolia configuration
After this PR is merged, someone with Algolia admin access must enable faceting:
Open Algolia Dashboard
Go to the crossplane index
Navigate to Configuration → Facets
Add:
filterOnly(docsearch:version)
to Attributes for faceting
Save
Important: The docsearch:version attribute is already indexed, so no re-crawl is required.Testing:
To verify this PR:
we see the facetFilters
Fixes: #1008