Skip to main content
Signature

About this widget

The QueryRuleCustomData widget displays custom data from Rules. You can use this widget to display banners or recommendations returned by rules when they match search parameters.

Explore example code

Browse the QueryRuleCustomData example code on GitHub.

Examples

Instantiate a QueryRuleCustomDataConnector and launch an initial search on its Searcher, triggering a Rule that returns custom data.

Android view

Kotlin

Compose UI

InstantSearch provides the QueryRuleCustomDataState as a state model, which is an implementation of the QueryRuleCustomDataPresenter interface.
Kotlin

Parameters

searcher
HitsSearcher
required
The Searcher that handles your searches.
initialItem
T?
Initial model value.
presenter
QueryRuleCustomDataPresenter<T>?
The Presenter defining how a model appears.
Kotlin

Low-level API

If you want to fully control the QueryRuleCustomData components and connect them manually, you can use the following components:
  • Searcher. The Searcher that handles your searches.
  • QueryRuleCustomDataViewModel. The component encapsulating the logic applied to the custom model.
  • QueryRuleCustomDataPresenter. Defines how to interact with a model.
Kotlin

Serialization

You must provide a DeserializationStrategy<T> implementation to deserialize your custom models. To do this, annotate your custom model class with @Serialization. The Kotlin serialization compiler plugin then automatically generates an implementation for you, accessible using the .serializer() function on the class’s companion object.

Example

Suppose your custom JSON data contains a banner URL that can be decoded to the following structure:
Kotlin
You can then either explicitly pass your serializer to the widget:
Kotlin
Or, pass your custom model class as a generic argument:
Kotlin
Last modified on July 10, 2026