This is the React InstantSearch v7 documentation.
If you’re upgrading from v6, see the upgrade guide.
If you were using React InstantSearch Hooks,
this v7 documentation applies—just check for necessary changes.
To continue using v6, you can find the archived documentation.
Control automatic filtering and boosting in your UI
If you want to have automatic filtering and boosting on or off for all searches, you only need to turn on or off the feature to filter the results automatically. If you want to let users turn automatic filtering and boosting on or off, you can build an InstantSearch widget. This widget should inform users that the results are filtered. The widget should also let users remove any applied filters.Build a widget for automatic filtering and boosting
1
Check the search response
The search response includes the following properties if automatic filtering and boosting is enabled:If filters are applied to the query, they’re listed in the
JSON
facetFilters property.JSON
2
Let users remove applied filters
To remove filters applied with automatic filtering and boosting,
you need to turn the feature off for the current query
using the
enableAutoFiltering API parameter.JSON
3
Turn on automatic filtering and boosting for new queries
To keep automatic filtering and boosting for other queries,
check for a query change and then set
enableAutoFiltering to true.Implement the widget
The following custom connector implements all three of the preceding steps.The connector requires the Algolia search helper.
TypeScript
useConnector Hook,
you can turn this connector into a useAutoFiltering Hook.
TypeScript
React
AutoFiltering component to fit your design.
You can then place AutoFiltering in your app.