I have users substituting the & for the word 'and', how do I handle this?

My customers are looking for something specific like M&M’s but they are typing M and M and no results are showing. How can I fix this?

Hi there!
By default, Algolia only shows records which have a match on every query word. Right now, when a user searches “M and Ms” the word “and” is likely not being found in the “M&Ms” records.

To disable this behavior, I would recommend setting removeStopWords to [“en”]. With this setting, the engine will remove words like “and, “is”, and “a”, etc. before executing the query, and therefore just search for “M" "M"s. (By default special characters are also not indexed.)

Just changing this setting should do the trick, though there are other options. For example, if some stop words are relevant to your searches, you could leave this on and make just “and” an optionalWord.

I hope one of these options works for you! Let us know if you have further questions.

2 Likes