mdn / yari

The platform code behind MDN Web Docs
Mozilla Public License 2.0
1.19k stars 501 forks source link

Unable to search for `::` #7877

Open NiedziolkaMichal opened 1 year ago

NiedziolkaMichal commented 1 year ago

Summary

Quick search results are correctly showing a few pseudo-elements when :: is typed, but when I click Not seeing what you are searching for? button, 0 matches are found:

image

URL

https://developer.mozilla.org/en-US/search?q=%3A%3A

Expected behavior

It would be great to see all pseudo-elements.

Device

Desktop

Browser

Chrome

Browser version

Stable

Operating system

Windows

Screenshot

No response

Anything else?

No response

Validations

KartikSoneji commented 1 year ago

The searching is done by elasticsearch: https://github.com/mdn/rumba/blob/5409df734847a35c442415f1363c9c1bcb940344/src/api/search.rs#L312-L328

and it looks like elasticsearch ignoring special characters is the default behaviour: https://stackoverflow.com/questions/51785404/search-special-characters-with-elasticsearch

Setting a custom search analyser and/or tokenizer seems to be the best way to search for special characters too: https://www.elastic.co/guide/en/elasticsearch/reference/current/specify-analyzer.html#specify-search-query-analyzer

KartikSoneji commented 1 year ago

Interestingly, the quick-search box uses a static index of article titles so it does show a list of pseudo elements when searching for :: I think the current behaviour should be changed to ensure the search page returns at least the same results as the quick search bar. image