How to perform a “silent” fallback search in React InstantSearch without losing facet sync or overwriting the user’s query #6546
-
Hi everyone! I’m working on a React InstantSearch project and need to handle a scenario where the main index finds no results for a user’s query. Specifically:
What I’ve Tried
Desired Outcome
Does anyone have a recommended pattern or code snippet showing how to achieve this? Perhaps a custom connector approach or additional filters that doesn’t overwrite the user’s visible query? Thanks in advance! Any guidance or examples are much appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
You could wrap your results with a Within the |
Beta Was this translation helpful? Give feedback.
Your understanding of the nesting and inheritance is correct indeed.
That does clarify it, however I'm not sure on how to achieve this. If you'd apply those different parameters, there would be a new search, which then would change the child results again, which seems like it has some looping potential.
I wonder if a more correct approach is to do this logic entirely in the search client level:
Normally then all facet values should be available as the ones from the final search that happened, and the UI should behave as expected.
the code would look something along the lines of: