Low Search - Minimum length keyword search and special characters
Low Search - Minimum word length doesn't appear to be working for keyword searches on my site. I can search for single letters and it brings back hundreds of results. I can also input special characters, for instance a search for "!?!" will bring back hundreds of results. Is there a way to prevent this? I'm pretty sure I have my collections all set up correctly, indexed etc.
Wondering if there's a fix for this or if I'm missing something.
Thanks!
I'm running EE v. 3.3.0 and Low Search v. 5.0.2
Replies
Low 9 May 2016 15:58
The "Minimum word length" setting means something else than you're thinking.
It would appear you're thinking that it means that no searches for keywords that fall below the threshold are not allowed, perhaps even return no results.
Instead, the setting refers to the 'ft_min_word_len' setting in your MySQL installation, and is used for how the search is performed. For this, there are two options: the optimal Full Text search, and the fallback LIKE search. Low Search analyses the keywords to see which algorithm to use, partially using the Minimum word length setting.
What Low Search doesn't do, is validate the keywords themselves. What constitutes special characters in one language, may not be that in another, so LS doesn't make any assumptions here. It processes the index and the keywords in the same way, which includes stripping any punctuation. The Minimum word length setting has nothing to do with that.
If you need server side validation for your keywords, then you could do that with a custom extension. But to be honest, I don't think that's really necessary. Real-world searches don't just contain "!?!" or similar.
Andy Thorpe 10 May 2016 12:00
Thanks for your reply, that makes sense.
I don't have a problem with the special characters, it's just that the client brought it up, but if Low Search doesn't validate keywords that's fine. Hopefully the client forgets about it!