CloudCannon / pagefind

Static low-bandwidth search at scale
https://pagefind.app
MIT License
3.48k stars 113 forks source link

Feature request: Add support for misspellings #45

Open gaurav-nelson opened 2 years ago

gaurav-nelson commented 2 years ago

Thank you for creating this open search solution.

Currently, misspelling a search term doesn't return any result. Please add the ability to show results for misspelled words.

image

Relates to #2

bglw commented 2 years ago

Hi @gaurav-nelson 👋

This is on the roadmap to implement in some capacity, as you saw in #2.

There are some limitations around how good we can make this spellcheck with the current implementation. Since our strategy centers on loading partial regions of the search index, we don't have all search terms available at any given moment. This means if the misspelling occurs earlier in the word, we might not have loaded the correct word.

I have some plans for how this might be tackled, so some implementation of this will come in the future 🙂

While I have you, I'd love to hear what behavior you would like to see in this example? Some options:

gaurav-nelson commented 2 years ago

Thank you @bglw

Automatically search for the single closest matching word and show results — alongside some message like "Showing results for pagefind instead"

I believe the second option makes sense and replicates other search experiences. However, maybe it can be combined with the third option as well. Showing results for pagefind. Search instead for page, pagan.

bglw commented 2 years ago

Nice suggestion 🙂 I'll let you know what's possible as the implementation firms up a bit.