Search multiple indices with InstantSearch
The following example uses a single search view to search in two indices. This is achieved through the aggregation of twoHitsSearchers
by the MultiSearcher
.
Each of them targets a specific index: the first one is mobile_demo_actors
and the second is mobile_demo_movies
. The results are presented in the dedicated sections of a LazyColumn
.
The source code of this example is on GitHub.
Search data models
Kotlin
Search view model
Kotlin
Search UI
Kotlin
Search view activity
Kotlin
Combine search for hits and facets values
This example uses a single search view to search in the index and facet values for attributes of the same index. This is achieved through the aggregation of theHitsSearcher
and the FacetSearcher
by the MultiSearcher
.
The results are presented in the dedicated sections of a LazyColumn
.
The source code of this example is on GitHub.
Search data model
Kotlin
Search view model
Kotlin
Search UI components
Kotlin
Search view activity
Kotlin
Category display
Algolia can help you display both category matches and results if you:- Add categories to your Query Suggestions either inline or listed below a result. For example, you might see the following in your Query Suggestions list “game of thrones in Books”
- Use multi-index search to display categories from a separate category index. This is useful if you want to display categories and Query Suggestions at the same time. Clicking such a result typically redirects to a category page. The following is a sample dataset for a product index and a category index.
Example product index
JSON
Example category index
JSON