Skip to content

Facet results by version in Algolia search

Sarah German requested to merge 182-versioned-search into main

What does this MR do and why

This change, in tandem with configuration changes to our Algolia crawler (see discussion #182 (comment 974554856)), enables Search to return results specific to the version of the site you're currently viewing.

For example, if you set the version to 14.10 and run a search, all pages in the results will be from that release.

This particular MR only gets the change onto the current production site and should not have any visible impact there. We will need separate MRs to get it onto previous releases (like 14.10), where it will actually matter. (TBD on how to do this)

Related issue: #182 (closed)

How to test

This is not easy to test since we don't spin up older versioned sites in the review app for this MR.

  1. Pull this branch to your local environment
  2. Make two changes to content/assets/javascripts/docsearch.js to use our non-prod test index:
  • Change the value for indexName to gitlab_testing
  • Change the value of the API key to the key here
  1. Compile the site: bundle exec nanoc compile
  2. Spin up older versions of the site using this shell script.
  3. Copy our updated JS code down to some older versions for testing:
  • cp public/assets/javascripts/docsearch-v4.js public/15.0/assets/javascripts/docsearch-v3.js
  • cp public/assets/javascripts/docsearch-v4.js public/14.10/assets/javascripts/docsearch-v2.js
  1. Run the site: bundle exec nanoc view
  2. Open a page on an older release (e.g, http://localhost:3000/14.10/runner/) and run a search. The results should all be pages within this version.

(This is not a great way to have to test. I am open to better ideas for this!)

Edited by Achilleas Pipinellis

Merge request reports