alphagov / tech-docs-gem

Gem to distribute the tech docs project
https://tdt-documentation.london.cloudapps.digital/
MIT License
15 stars 38 forks source link

Search has weird behaviour #222

Closed lfdebrux closed 3 years ago

lfdebrux commented 3 years ago

What I'm trying to do

Search for "reliability engineering"

What I expect to happen

As I type the word "reliability" the number of results decreases steadily to only those pages containing the word "reliability"

What actually happens

I type "reliab", I get 10 results.

I type "reliabi", or "reliabil", or "reliabili", or "reliabilit", I get 0 results.

I type "reliability", I get 10 results.

I've attached a screen recording of this happening.

https://user-images.githubusercontent.com/503614/112124302-1c4e3f00-8bba-11eb-9090-99ddbe236f1a.mp4

36degrees commented 3 years ago

This'll be due to the way that stemming rules are applied to the different 'versions' of the search term as the user types – we disabled stemming in the Design System search for this exact reason (https://github.com/alphagov/govuk-design-system/commit/531d3c3c0e564c35891026df49712d0e480c5337).

36degrees commented 3 years ago

Suspect this issue might makes more sense on the alphagov/tech-docs-gem repo as it'll affect all tech docs instances?

lfdebrux commented 3 years ago

Oh interesting, I didn't realise search was shared behaviour, thanks @36degrees I will share there

lfdebrux commented 3 years ago

Thanks for transferring @36degrees

It looks like search pipeline is configured in govuk_tech_docs.rb, using middleman-search

https://github.com/alphagov/tech-docs-gem/blob/master/lib/govuk_tech_docs.rb#L106-L118

lfdebrux commented 3 years ago

middleman-search is based on LunrJS so the fix from Design System might still work, I am happy to investigate.

lfdebrux commented 3 years ago

I can reproduce with the example in this repo by searching for documentatio / documentation

lfdebrux commented 3 years ago

So fixing the behaviour is very straightforward; I am just trying to work it how to write tests for it!