algolia / docsearch

:blue_book: The easiest way to add search to your documentation.
https://docsearch.algolia.com
MIT License
3.97k stars 384 forks source link

Version filtering based on folders #2061

Closed dandimeo closed 3 months ago

dandimeo commented 1 year ago

Description

The documentation site https://docs.arangodb.com has a folder per version version handling. (all versions are on main branch) We currently have 3 versions: 3.10, 3.11, 3.12.

We set up Algolia DocSearch V3 and added the following facets:

searchParameters: {
      facetFilters: [`version:${version}`],
}

Version value comes from var version = localStorage.getItem("docs-version");

However, when the version is switched through version selector and start a new search, the search results still address the previously selected version.

Steps to reproduce

  1. Go to https://docs.arangodb.com (will automatically redirect to 3.11 version, which is the stable version)
  2. Search something, the behaviour is correct showing 3.11 results
  3. Change version via the version selector (e.g. change to 3.12 version)
  4. Search something again, it will still show 3.11 results

Expected behavior

Expected behavior is to dynamically change DocSearch facetFilter value for version attribute when site's version is changed.

Environment

randombeeper commented 3 months ago

Hello @dandimeo , sorry for the long delay in answering your question, however looking at your site now it seems you resolved the situation. If you need interactive help in the future, please take a look at our Discord at https://alg.li/discord.