fix: upgrade DocSearch to v4 and add version boosting#1994
Merged
dhmlau merged 1 commit intoMar 3, 2026
Merged
Conversation
Signed-off-by: Neeraj Deshmukh <neerajd002@gmail.com>
dhmlau
approved these changes
Mar 3, 2026
Member
dhmlau
left a comment
There was a problem hiding this comment.
@neerajd002, thanks for taking a look at this problem! The changes look reasonable to me.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1487
Target Issue
Currently, the search engine indexes and displays results from older versions of the API (v3, v2) side-by-side with the current version (v4).
The Solution
This PR resolves the issue by upgrading to DocSearch v4 and implementing contextual search behavior using Algolia's
optionalFilters.By parsing the current URL path, the site now dynamically boosts the ranking of the documentation version the user is currently viewing.
When on
/lb4/(or the root index), LoopBack 4 results are boosted.When on
/lb3/, LoopBack 3 results are boosted.When on
/lb2/, LoopBack 2 results are boosted.This ensures the most relevant results appear first while still allowing users to search across the entire domain.
Changes Made
DocSearch Upgrade: Bumped
@docsearch/jsand@docsearch/cssfromv3tov4.Meta Tag Injection (
_includes/head.html): Added Liquid templating to dynamically inject the<meta name="docsearch:version" content="..." />tag based on the page's directory path.Code snippet
docsearchinitialization): Added logic to parsewindow.location.pathnameto identify the user's current version, and passed that value into Algolia'ssearchParameters.Post-Merge Requirement
Action Required: Once this is merged and deployed, a manual re-crawl must be triggered in the Algolia Crawler Dashboard to index the new tags before the frontend optionalFilters will take effect.