Android
Signature
Explore example code
Browse the Dynamic Facets example code on GitHub.
About this widget
DynamicFacetsListView is a view that displays the ordered list of facets and facet values.
The order of groups and facet values in each group is defined by the corresponding index settings and applied index rules.
You can configure the facet merchandising through the corresponding index setting.
To learn more, see Facet display.
Requirements
You must set the attributes for faceting and configure the facet order, either using the dashboard or with the API parametersattributesForFaceting and renderingContent.
You must also set the facets property of the query with Searcher.indexQueryState.query.facets and provide the facet attributes you want to retrieve.
You must use InstantSearch Android v2.11 or later to use
DynamicFacets.Examples
Instantiate aDynamicFacetsListConnector, set the query facets and launch an initial search on its searcher.
Kotlin
Parameters
The
FilterState that holds your filters.The ordered list of attributed facets.
The mapping between a facet attribute and a set of selected facet values.
The mapping between a facet attribute and a facet values selection mode. If not provided, the default selection mode is
Single.The mapping between a facet attribute and a descriptor of a filter group where the corresponding facet filters are stored in the filter state.
View
The view that render the dynamic facets list.
Kotlin
Low-level API
If you want to fully control theDynamicFacetsList components and connect them manually, you can use the following components:
Searcher: theSearcherthat handles your searches.FilterState: the current state of the filters.DynamicFacetsListViewModel: dynamic facets business logic
Kotlin
Customizing your view
InstantSearch Android providesDynamicFacetListView interface, it’s the view presenting the ordered list of facets and handling user interaction.
You can provide your implementation of DynamicFacetListView interface:
Kotlin
Android view
InstantSearch Android providesDynamicFacetListAdapter, an opinionated implementation of DynamicFacetListView interface and a subclass of ListAdapter class.
Provide your implementation of DynamicFacetListViewHolder.Factory interface to your DynamicFacetListAdapter:
Kotlin
Compose UI
InstantSearch Android provides theDynamicFacetListState, an implementation of the DynamicFacetListView interface adapted for usage with Compose UI.
It provides facetOrder and facetSelections properties with convenient toggle and isSelected functions which let you implement your own Compose UI view.
Implementation example
Kotlin