Switching Search Client Modes with react-instantsearch-dom
TLDR Zeyu asked about switching searchClient modes. Jason suggested re-instantiating Instantsearch.js and dynamically rendering widgets on button click.
Powered by Struct AI
5
6mo
May 24, 2023 (6 months ago)
Zeyu
Zeyu
05:46 PMI’m trying to use both normal search and vector search. A user can switch different “mode” when searching. However, I’m not sure how to switch between two searchClient by clicking a button. What is the best practice here?
Jason
Jason
05:55 PMYou would have re-instantiate all of Instantsearch.js along with the search client when the button is clicked
05:55
Jason
05:55 PMSo you’d want to move all of the initialization code into a function, and call that function both on page load and also on button click
Zeyu
Zeyu
06:15 PMwe are using react-instantsearch-dom,and we wish to click the button within SearchComponent
Jason
Jason
06:51 PMIt would be a similar concept - you would have to render the widgets dynamically and have them be re-rendered when the button is pressed, by may be attaching a variable as the react component’s key and changing this variables value when the button is pressed
Typesense
Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI
Indexed 3015 threads (79% resolved)
Similar Threads
Combining ReactInstant Search Widgets with React Hook Form Version
Uma asks if they can combine ReactInstant Search widgets with React Hook Form version widgets. Jason suggests asking in the Instantsearch github repo, but suspects they'd need to switch all widgets to the hooks version.
6
6mo
Issues with Search UI for Vector Search
WL is building a search UI for vector search and having issues with syntax, while Jason provides context on the issue.
6
9mo
Changing Filter Type on React's Instantsearch Client
Rushil asked how to change the Filter in react's instantsearch. Jason recommended using the `label` or `value` prop.
2
15mo