Skip to content

Improve search results by filtering by doc version#722

Open
SuperCoolPencil wants to merge 1 commit into
goharbor:mainfrom
SuperCoolPencil:fix-search-filtering
Open

Improve search results by filtering by doc version#722
SuperCoolPencil wants to merge 1 commit into
goharbor:mainfrom
SuperCoolPencil:fix-search-filtering

Conversation

@SuperCoolPencil
Copy link
Copy Markdown

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!

Signed-off-by: SuperCoolPencil <thesupercoolpencil@gmail.com>
@Vad1mo
Copy link
Copy Markdown
Member

Vad1mo commented May 13, 2026

how to test it?

@SuperCoolPencil
Copy link
Copy Markdown
Author

@Vad1mo

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.

@Vad1mo
Copy link
Copy Markdown
Member

Vad1mo commented May 13, 2026

is it possible to test it here? -> https://deploy-preview-722--goharbor-io.netlify.app/ where this PR is deplyed?

@SuperCoolPencil
Copy link
Copy Markdown
Author

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.

@Vad1mo
Copy link
Copy Markdown
Member

Vad1mo commented May 13, 2026

so what is needed on algolia side to index?

@SuperCoolPencil
Copy link
Copy Markdown
Author

SuperCoolPencil commented May 13, 2026

The crawler needs to know how to extract the docs version from the page HTML. You’ll need to add a selector for the version field in the crawler JSON config that reads from the meta tag we added:

"selectors": {
  "version": {
    "selector": "meta[name='docsearch:version']",
    "attribute": "content"
  }
}

In the Algolia dashboard for the goharbor index, go to:

Configuration > Facets

and add version under Attributes for faceting.

The crawler config probably has a set of allowed paths (usually via start_urls, sitemap_urls, or path patterns). Make sure the new versioned routes like:

/docs/2.8.0/

are included, otherwise the crawler will skip them entirely.

After that

Once the config changes are in place and the version facet is enabled, trigger a manual re-crawl from the Algolia dashboard. That should populate the index with the new versioned docs and attach the correct version attribute to each record.

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.

5 participants