Improve short-query precision in Algolia search#741
Improve short-query precision in Algolia search#741Flamki wants to merge 2 commits intoprecice:masterfrom
Conversation
|
Hi @Flamki, thanks for submitting the PR! I just have one question about the scope of the fix. The Since Was this intentional to keep the fix narrow? (Also can you attach the screenshot of your solution working locally) Also can you see my PR #744 |
|
Thanks for the careful review, great catch. You were right: the earlier helper was too narrow for multi-word input. I updated the PR so short tokens are handled even when part of a longer query (for example Follow-up changes in this PR:
This keeps the scope narrow (only short-token queries), avoids global index/config changes, and keeps XML search behavior for normal XML queries. Validation:
Local screenshots:
|
d33a06c to
6629092
Compare
|
Hey @Flamki , thanks for iterating on this! One thing I wanted to point out about the updated approach:
This means the conditional check via So the helper function adds ~20 lines of logic that doesn't change any search behavior compared to the simpler unconditional approach. I think the minimal 2-line version keeps things cleaner and easier to maintain. Happy to discuss if I'm missing something though! 🙂 |
6629092 to
05a7bd6
Compare
|
This pull request has been mentioned on preCICE Forum on Discourse. There might be relevant details there: https://precice.discourse.group/t/gsoc-2026-website-modernization-interest-ayush-singh-flamki/2766/1 |
05a7bd6 to
fbe90d1
Compare
|
@MakisH @MuhammadAashirAslam It now unconditionally sets I also added a short inline comment in both files to explain why these values are used (to reduce short-query false positives like Note: the indexing root-cause fix (typo in Validation update: I ran a full local Jekyll build in Docker. Command: Result: |
|
Hey @Flamki I see you have implemented exactly the same solution as my PR but the issue was something else (already working on it and found the root cause). This is something for after that so for now you can look into other issues. Thanks 😊 |
|
@MakisH @MuhammadAashirAslam thanks! It now serves as a small hardening improvement: adding query-time typo threshold tuning in _includes/algolia.html and js/algolia-search.js (minWordSizefor1Typo=5, minWordSizefor2Typos=9) to reduce fuzzy false positives for short tokens. I’m happy to keep this as an optional follow-up enhancement, or close it if you prefer to keep things minimal post-#813. Let me know your preference. |
|
Will look into this after we manage to update the Algolia record again (see #388). Let's see if this is still needed then (happy to merge it if yes). |
|
Regarding the original issue, this has now been solved. I would prefer to leave the settings as-is for now, unless there is a separate good reason to change them. Thanks a lot for contributing anyway! |
|
Thank you for the clarification and for taking the time to review this thoroughly. That makes sense — since the original issue has now been resolved and there isn’t a strong need to adjust the typo thresholds at this point, I’m happy to leave the current settings unchanged and close this PR. I appreciate the feedback and the discussion. It was helpful to dig into how Algolia’s per-word typo thresholds behave in practice. Thanks again, and I’ll look into other issues where I can contribute. |


Summary
Improve short-query precision in Algolia by applying a minimal query-time typo-threshold tweak in both Algolia entry points.
What changed
_includes/algolia.htmljs/algolia-search.jsBoth now set:
minWordSizefor1Typo = 5minWordSizefor2Typos = 9This is intentionally unconditional and minimal. Algolia applies these as per-word thresholds, so the behavior is naturally scoped to short words without extra helper logic.
Why
This reduces false positives for short queries (for example
gsocmatching unrelated XML tokens) while avoiding broader search/index configuration changes.Context
#813.Validation
pre-commit run --files _includes/algolia.html js/algolia-search.js(passed)docker run --rm -v "${PWD}:/srv/jekyll" -w /srv/jekyll jekyll/jekyll:4 bash -lc "bundle exec jekyll build"dockerDesktopLinuxEnginepipe missing).Related: #733