Upgrade from InstantSearch v3 to v4
In InstantSearch v4.0.0 and later, InstantSearch uses Kotlin 2.2 and the Algolia Kotlin API client 3.x. This client updates models and simplifies types.Kotlin
Requirements
InstantSearch Android 4.x has updated minimum requirements:Wrapper types removed
The Kotlin API client 3.x removed primitive wrapper types. Use plainString values instead:
Search parameters
Replaces theQuery class with SearchParamsObject from the Algolia Kotlin Client 3.x:
Response types
Search response types have been updated to match the Kotlin API client 3.x:Filters
InstantSearch now owns its own filter model. Update your imports:Request options
RequestOptions uses immutable construction from the Algolia Kotlin Client 3.x:
Insights
Insights has been updated to use v3 events and thepushEvents API:
Trackers
Tracker initialization now usesString for event names:
Indexable interface
Hit models for tracking must implement theIndexable interface:
Kotlin
Removed features
The following features have been removed in v4:Dependencies
Update your dependencies inbuild.gradle or gradle/libs.versions.toml:
Migration checklist
- Update dependencies to the versions listed above
- Update
minSdkto 23 in yourbuild.gradle - Remove wrapper types: replace
ApplicationID,APIKey,IndexName,Attribute,ObjectID,QueryID,EventName,UserTokenwith plainString - Update query types: replace
QuerywithSearchParamsObject - Update response types: replace
ResponseSearchwithSearchResponse,FacetwithFacetHits - Update filter imports: use
com.algolia.instantsearch.filter.Filterinstead ofcom.algolia.search.model.filter.Filter - Update Insights: use v3 event methods instead of
InsightsEventconstructors - Implement
Indexable: ensure hit models implementIndexablefor tracking - Remove Answers/Places: if using
SearcherAnswersorSearcherPlaces, migrate to standard search - Test thoroughly: the new versions include significant internal changes
Upgrade event tracking
Starting from v3.2.0, InstantSearch makes it easier to send view events using theisAutoSendingHitsViewEvents option on HitsSearcher:
Kotlin
Upgrade from InstantSearch v2 to v3
The library version3.0 uses Kotlin 1.6 and Algolia Kotlin API Client 2.0. Below are the steps to migrate.
This new version removes all deprecated methods and features from
v2.InstantSearch Android package
InstantSearch Android package has changed. Update your imports accordingly:Kotlin API client
The Kotlin API client (and its underlying Ktor client) is part of the library’s binary interface. Read the migration guide, or apply the following changes:LogLevel
The library uses LogLevel from the Kotlin API client instead of Ktor’s Loglevel:
Public constants
Constants (for example,KeyIndexName, KeyEnglish, and RouteIndexesV1) aren’t exposed. Use your constants instead.
Ktor client
For more information, refer to Ktor’s migration guide.Searchers
Legacy searchers are removed. Migrate as follows:Extension modules
Multiple extensions have been extracted to modules:Upgrade from InstantSearch v1 to v2
InstantSearch v2 introduces a new architecture and new widgets, which brings several breaking changes from v1:-
No longer an
InstantSearchcomponent automatically connecting widgets. You are now in control of theSearcherand responsible for connecting and disconnecting it from widgets and other components. -
The widgets are now built around
ViewModels, holding their data and business logic. Compared to the V1 where widgets were AndroidViews, now the core of the widget is its view-model, and the UI is behind an interface to ensure minimal coupling.
The InstantSearch Android v1 documentation is available on the legacy docs page.