InstantSearch: Perform another search if initial search query returns with 0 results

I have setup an <InstantSearch in which I have some initial refinement filters pre-applied to the initial search query. It turns out that in some situations these refinement filters returns with no results at all for certain users.

Question is how can I achieve performing another search query with lessened filters if initial query does return with 0 results?

To my understanding so far if the InstantSearch search component accepted a searchResults prop the same way it provides a searchState I would be able to implement what I need by binding the searchResults ref to my component state and take action in some of the component lifecycle to perform the less restricted search query.

Thanks for any guidance in advance!

Hi there,
Thank you for reaching out to us.

If you’re not strictly filtering your results, then you might be interested in optionalFilters.


It’s similar to normal filters, but allows to return results which don’t match the criteria.

You can also add scores to the optionalFilters.

If optionalFilter isn’t for you, you can utilize “searchState”.

And you can acquire the state result by using connectStateResults connector.

Let me know how it goes!

Thanks! Let me check if the optional filters thing is what we need.