Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix search 'autocomplete' behaviour #236

Merged
merged 1 commit into from
Sep 6, 2021
Merged

Fix search 'autocomplete' behaviour #236

merged 1 commit into from
Sep 6, 2021

Conversation

lfdebrux
Copy link
Member

@lfdebrux lfdebrux commented Jun 7, 2021

Search results will no longer disappear and reappear again as a user is typing a word in.

Fixes #222.

Fix

This problem had already been identified in the Design System website, see commit alphagov/govuk-design-system@531d3c3. Thanks @36degrees for flagging that this fix existed.

The fix is to remove the stemmer from the lunr pipeline. This is easily done with the fork of middleman-search that the tech-docs-gem uses.

This commit also adds a simple test to prevent future changes breaking this functionality.

@lfdebrux lfdebrux changed the title Remove stemmer from search pipeline Fix search 'autocomplete' behaviour Jun 7, 2021
Copy link
Contributor

@kr8n3r kr8n3r left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lfdebrux update the change log and :shipit:

Search results will no longer disappear and reappear again as a user is
typing a word in.

Removing the stemmer from the search index pipeline stops the search
term from being truncated when a search is made.

This fixes #222.

Description of issue
--------------------

I noticed that certain searches have surprising behaviour as the search
term was typed in; for instance, when searching for "documentation":

- searching "d" gives 5 results
- searching "do" gives 0 results
- searching "doc", "docu", "docum", "docume", "documen", "document"
  gives 1 result
- searching "documenta", "documentat", "documentati", "documentatio"
  gives 0 results
- searching "documentation" gives 1 result

This is surprising because search is incremental, meaning the results
change a lot while typing a word.

It is could also be confusing when searching for a particular long word;
for instance, if someone was searching for references to "documentation"
and there are a lot of results for "document" but none for "documenta"
they might think that means they are no uses of the word "documentation"
in the website.

Fix
---

This problem had already been identified in the Design System website,
see commit alphagov/govuk-design-system@531d3c3. Thanks @36degrees for
flagging that this fix existed.

The fix is to remove the stemmer from the lunr pipeline. This is easily
done with the fork of [middleman-search] that the tech-docs-gem uses.

This commit also adds a simple test to prevent future changes breaking
this functionality.

[middleman-search]: https://github.com/alphagov/middleman-search
@lfdebrux lfdebrux merged commit 710cf72 into master Sep 6, 2021
@lfdebrux lfdebrux deleted the ldeb-fix-222 branch September 6, 2021 11:09
@lfdebrux lfdebrux mentioned this pull request Sep 13, 2021
kr8n3r added a commit to alphagov/paas-tech-docs that referenced this pull request Sep 15, 2021
Main one is govuk-tech-docs gem v2.4.3 which brings

- [#236: Fix search 'autocomplete' behaviour](alphagov/tech-docs-gem#236)
- [#203: Update vendored javascripts](alphagov/tech-docs-gem#203)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Search has weird behaviour
2 participants