Fix irrelevant search results for short queries like GSoC#744
Open
MuhammadAashirAslam wants to merge 1 commit intoprecice:masterfrom
Open
Fix irrelevant search results for short queries like GSoC#744MuhammadAashirAslam wants to merge 1 commit intoprecice:masterfrom
MuhammadAashirAslam wants to merge 1 commit intoprecice:masterfrom
Conversation
Member
|
Thank you for your contribution. However, I am confused. Testing locally, it does not seem to have any effect, and the screenshots don't demonstrate the expected result. General note: the PR description is quite long for what the change is (I guess suggested by some tool). This makes it tricky to see what is going on. I see that there is a similar discussion in #741. I am not going to interact with these PRs for now, and let the discussion converge. |
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.
Fixes #733
Summary
Improve search precision for short single-word queries (e.g.
gsoc) by preventing irrelevant matches from XML code tokens — implemented as a client-side query-time adjustment, without modifying indexing or documentation content.Problem
While testing search locally, I noticed that short queries like
gsocwere returning unrelated XML reference results.This was happening due to Algolia's default typo tolerance behavior.
By default:
So the query:
was matching:
because:
This was confirmed via Algolia ranking info:
Meaning the result was purely a fuzzy match from code content, not real page relevance.
Change
A client-side rendering fix was implemented to make short queries stricter without touching indexing or documentation.
In both Algolia client entry points:
_includes/algolia.htmljs/algolia-search.jsthe following parameters were added inside the
searchFunction:Effect
gsoc) now require an exact matchThis prevents short queries from matching unrelated code tokens such as:
Why this approach
_config.ymlThis is purely a query-time adjustment in client rendering, ensuring:
Files Changed
_includes/algolia.htmljs/algolia-search.jsBoth updates were applied inside the
searchFunction.Validation
After this change:
gsocno longer returns irrelevant XML reference matchesconfigurationcontinue returning correct resultsNote
This change only improves relevance for short queries at the client level. Making pages containing terms like "GSoC" fully discoverable would additionally require adding
keywordstosearchableAttributesin_config.ymland rebuilding the Algolia index withbundle exec jekyll algolia. This is outside the scope of this PR since it involves indexing configuration.Screenshot Before
Screenshot After