How to show results even if some of the query words match?

In the index I have “My big dog” indexed, and I want it to show as a result if the user searches for “who has a dog” because they both have “dog” in it.

How can I achieve this?

Hi @shervin, thanks for asking your question.

For this, you can use the removeWordsIfNoResults query parameter. Find the documentation here.

This parameter removes words query words one by one and retries the query until it returns more than zero results. In your example, assuming that removeWordsIfNoResults is set to firstWords, the words “who”, “has”, and “a” would be removed until only “dog” remains, which would match “my big dog”. All of these iterations happen behind the scenes - to your code it will look like just one query.

You can provide this parameter at query time, or set a value for all queries from the index’s Ranking tab in the Algolia dashboard.