Skip to content

Conversation

@haarchri
Copy link
Member

@haarchri haarchri commented Jan 28, 2026

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.

  • Added logic to detect the current page version via .Page.Params.version.
  • Configured DocSearch to apply a facetFilters value dynamically:
['version:X.XX']
  • Added special handling for the master version - uses version:0.0.0-master, which matches the existing meta tag convention where master is labeled 0.0.0-master to keep it de-ranked in search

Background

Each page already includes:

which the Algolia crawler indexes.

curl https://docs.crossplane.io/v2.0/composition/  | grep -A 10 "docsearch"
<meta name=docsearch:modified content='August 14, 2025'><meta name=docsearch:version content="2.0">
curl https://docs.crossplane.io/v1.20/concepts/  | grep -A 10 "docsearch"
<meta name=docsearch:modified content='May 21, 2025'><meta name=docsearch:version content="1.20">

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:
    searchable(version)
    to Attributes for faceting

  • Save

Testing:

curl http://localhost:1313/v2.1/composition/ | grep -A 10 "docsearch"
...
<script>
    docsearch({
    container: '#docSearch',
    appId: 'xxx',
    indexName: 'crossplane',
    apiKey: 'xxxxx',
    placeholder: 'Search the docs',
    searchParameters: {
      facetFilters: ['version:2.1']
    }
    });
</script>

To verify this PR:

  • Open any versioned docs page (for example, /v1.20/concepts/providers/)
  • Open DevTools → Network
  • Perform a search
  • Inspect the request to algolia.net
{"requests":[{"query":"t","indexName":"crossplane","attributesToRetrieve":["hierarchy.lvl0","hierarchy.lvl1","hierarchy.lvl2","hierarchy.lvl3","hierarchy.lvl4","hierarchy.lvl5","hierarchy.lvl6","content","type","url"],"attributesToSnippet":["hierarchy.lvl1:10","hierarchy.lvl2:10","hierarchy.lvl3:10","hierarchy.lvl4:10","hierarchy.lvl5:10","hierarchy.lvl6:10","content:10"],"snippetEllipsisText":"…","highlightPreTag":"<mark>","highlightPostTag":"</mark>","hitsPerPage":20,"clickAnalytics":false,"facetFilters":["version:2.0"]}]}

we see the facetFilters

Fixes: #1008

@netlify
Copy link

netlify bot commented Jan 28, 2026

Deploy Preview for crossplane ready!

Name Link
🔨 Latest commit 470ee0c
🔍 Latest deploy log https://app.netlify.com/projects/crossplane/deploys/697cae7f5b362a0008cf373b
😎 Deploy Preview https://deploy-preview-1051--crossplane.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 95 (no change from production)
Accessibility: 90 (🔴 down 2 from production)
Best Practices: 92 (no change from production)
SEO: 100 (no change from production)
PWA: 70 (no change from production)
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Member

@jbw976 jbw976 left a 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?

Copy link
Member

@jbw976 jbw976 left a 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?

Image

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

@haarchri
Copy link
Member Author

@jbw976 the facet needs to match the tagName ... can you add docsearch:version ? its fine to do this before i guess - if we have an issue we can remove it

@jbw976
Copy link
Member

jbw976 commented Jan 29, 2026

added docsearch:version to attributes for faceting as "filter only" and saved it @haarchri!
Screenshot 2026-01-29 at 10 20 11 AM

@jbw976
Copy link
Member

jbw976 commented Jan 29, 2026

do you know what the UX is going to be for showing multiple versions in the search?

and i think the answer to this is that we don't show multiple versions in the results - we only show results for the version you're currently on. is that right @haarchri?

@jbw976
Copy link
Member

jbw976 commented Jan 29, 2026

by the way, trying to also make sense of this comment in the the netlify_build.sh:

# Search indexing only points to /latest, this prevents broken or out of date
# search results

is this configured somewhere in this docs repo that we need to update? on the algolia side? i haven't found it yet 😇

edit: ah, i think it's controlled by the sitemap.xml: https://docs.crossplane.io/sitemap.xml, which is generated from https://github.com/crossplane/docs/blob/master/themes/geekboot/layouts/_default/sitemap.xml.

Algolia doesn't appear to be configured to only look at latest, our sitemap/canonical/permalinks/etc. make it so any search engine (including Algolia) will only look at /latest and /contribute.

So i think we'd have to update that logic in this PR also for Algolia to start indexing those? If so, does that mean that google etc. will start indexing old versions too? we probably don't want old versions showing up in google results, only having /latest there is probably the right thing to do.

this is starting to get confusing, what do you think @haarchri? 😂

Signed-off-by: Christopher Haar <christopher.haar@upbound.io>
@haarchri haarchri force-pushed the feature/algolia-search-facets branch from 2f73f76 to 6afdf98 Compare January 30, 2026 12:40
Signed-off-by: Christopher Haar <christopher.haar@upbound.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Web Bug] - Algolia Documentation version Facets not set-up.

2 participants