Controlling 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 enable 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.Building a widget for Automatic Filtering and Boosting
There are three steps to building an Automatic Filtering and Boosting widget:-
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 theJSON
facetFilters
property.JSON -
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 -
Turn on Automatic Filtering and Boosting for new queries. To keep Automatic Filtering and Boosting for other queries, you must first check for a query change and then set
enableAutoFiltering
totrue
.
Implementing the widget
The following custom connector implements all steps to let users turn off Automatic Filtering and Boosting for a search query.The connector requires the Algolia search helper.
JavaScript