How do use RemoveWordsIfNoResults smoothly

currently I use RemoveWordsIfNoResults: alloptional

This has the problem that the users sometimes experience that when they type the number of search results decrease and then suddenly increases when the RemoveWordsIfNoResults fallback kicks in. Is there a way to do this smoothly out of the box? I consider a solution where Í count the number of results an if this number is below lets say 10 I do a second search where I do an OR search (all words optional) and append the results to the standard Algolia search results. Is that teh way to do it?

Hello again @jmad! :slight_smile:

From my point of view, removeWordsIfNoResults wasn’t really intended to be used in an as-you-type setting, precisely because of the behavior you described. The idea is that, with as-you-type results, users get instant feedback on whether their search query matches results or not. Therefore, the fact that it matches none is an information per se, to which they can react as soon as it occurs.

This contrasts with a one-off search set up, where the users potentially entered a long phrase, only to discover when pressing enter that it matches nothing—which can be frustrating. removeWordsIfNoResults was more designed to address this use case.

So, I would advise:

  1. Either disable removeWordsIfNoResults completely in as-you-type searches.
  2. Or play with other values of this setting; namely, the lastWords options, that seems more suited to that kind of use case.

See the documentation for more information on the various possibilities. You could also have a look at optionalWords.

Have a nice day!

Dear Clement

That makes sense :slight_smile: Thank you