Signature
Explore example code
Browse the example code on GitHub.
About this widget
This widget displays matching refinement widgets in the order provided by renderingContent.facetOrdering in the search response.
Configure the order with facet display, override it with Algolia Rules, or generate it automatically with Dynamic Facets. Dynamic Facets orders facets and facet values based on recent search data.
Requirements
Declare each facet attribute inattributesForFaceting.
Use the Algolia dashboard or the API.
Configure the facet order with renderingContent.facetOrdering.
Add each facet attribute to the query’s facets property with Searcher.request.query.facets.
Dynamic facet list requires InstantSearch iOS v7.12.0 or later.
In v8, passing
controller when you create the connector crashes your app.
Upgrade to v9, or omit controller and call the connector’s connectController method.Example
Create aDynamicFacetListConnector, set the query’s facets, and run the initial search.
Swift
Parameters
The
Searcher that runs searches.The
FilterState that stores the current filters.Maps each facet attribute to its facet-value selection mode.
The default mode is
.single.Maps each facet attribute to the filter group that stores its filters in the filter state.
Low-level API
Use the following components to connect the dynamic facet list:Searcher: runs searches.FilterState: stores the current filter state.DynamicFacetListInteractor: manages dynamic facet state and behavior.DynamicFacetListController: displays the ordered facets and handles user interactions.
Swift
Customize the view
Use a built-in controller or useDynamicFacetListController to customize how the dynamic facet list appears and handles user interactions.
UIKit
DynamicFacetListTableViewController is a built-in UITableViewController that conforms to the DynamicFacetListController protocol.
To use a UICollectionView, a third-party view, or custom behavior, create a controller that conforms to DynamicFacetListController.
DynamicFacetListController protocol
SwiftUI
DynamicFacetListObservableController conforms to DynamicFacetListController for SwiftUI.
Use its orderedFacets and selections properties and its toggle and isSelected methods to build a custom SwiftUI view.
Build a SwiftUI view
Swift