Skip to main content
Signature

Explore example code

Browse the RelevantSort example code on GitHub.

About this widget

Virtual indices let you use relevant sort, a sorting mechanism that favors relevancy over the attribute you’re sorting on. The relevantSort widget displays the current search mode when searching in a virtual replica index, and allows users to switch between relevant and regular sorting, which is more exhaustive but can return less relevant results.

Examples

Instantiate a RelevantSortConnector and connect it to a RelevantSortView.

Android view

Kotlin

Compose UI

InstantSearch provides the RelevantSortState as a state model, which is an implementation of the RelevantSortView interface. RelevantSortState must be connected to the RelevantSortConnector or RelevantSortViewModel like any other RelevantSortView implementation.
Kotlin

Parameters

searcher
HitsSearcher
required
The Searcher that handles your searches.
viewModel
RelevantSortViewModel
default: RelevantSortViewModel()
The business logic handling the Relevant sort priority changes.

View

view
RelevantSortView<T>
required
The view that presents and toggles the relevant sort priority state. If you don’t need to transform anything, you can use RelevantSortPriorityView instead, which is a type alias of RelevantSortView<RelevantSortPriority?>.
presenter
RelevantSortPresenter<T>
required
Presenter transforming the Relevant sort priority state to its representation for a view. Not required if you use RelevantSortPriorityView.
Kotlin

Low-level API

If you want to fully control the RelevantSort components and connect them manually, you can use the following components:
  • Searcher. The Searcher that handles your searches.
  • RelevantSortViewModel. The business logic handling the Relevant sort priority changes.
  • RelevantSortView<T>. The view that presents and toggles the Relevant sort priority state. RelevantSortPriorityView is a type alias of RelevantSortView<RelevantSortPriority?>.
  • RelevantSortPresenter<T>. Generic presenter transforming the Relevant sort priority state to its representation for a view. Optional if you use RelevantSortPriorityView.
Kotlin
Last modified on July 10, 2026