I am trying to implement an internal search for my website that can point users in the right direction in case the mistype a word, something like the did you mean : in google search.
Does anybody have an idea how such a search can be done? How can we establish the relevance of the word or the phrase we assume the user intended to search for?
Thank you
You could use an algorithm for determining string similarity and then suggest other string from your search index up to a certain difference.
One of these algorithms is the Levenshtein distance.
However, don't forget searching for existing solutions. I think e.g. Lucene has the capability to search for similar strings.
Btw, here's a related post on this topic: How does the Google “Did you mean?” Algorithm work?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With