algoliasearch-client-kotlin package is version 3.
This page helps you upgrade from version 2
and explains the breaking changes you need to address.
Algolia generates the version 3 clients from OpenAPI specifications,
which provides consistent behavior across all languages and up-to-date API coverage.
The main architectural changes are the removal of the initIndex pattern
and the Kotlin DSL:
all methods are now on the client instance directly, with indexName as a parameter,
and parameters use typed data classes instead of DSL builders.
For the full list of changes, see the Kotlin changelog.
Update your dependencies
Update thealgoliasearch-client-kotlin dependency to version 3 in your build file:
build.gradle
Update imports
The package structure changed fromcom.algolia.search to com.algolia.client.
Type wrapper classes like ApplicationID, APIKey, IndexName, and ObjectID no longer exist.
Kotlin
Kotlin
Update client initialization
Version 3 renamesClientSearch to SearchClient.
It also removes the ApplicationID and APIKey type wrappers. Pass plain strings instead.
Kotlin
initIndex no longer exists.
Remove initIndex
This is the most significant structural change when upgrading.
Version 2 relied on an index object with methods called on it.
In version 3, all methods belong to the client instance,
with indexName as a parameter.
Kotlin
Replace the domain-specific language
Version 2 of the Kotlin client included a domain-specific language (DSL) for building queries, settings, and filters. Version 3 removes this DSL. Replace all DSL builder blocks with typed data class constructors and named parameters.Query parameters
Kotlin
Settings
Kotlin
Filters
Kotlin
Update search calls
Search a single index
Theindex.search() method is now client.searchSingleIndex().
Pass the index name and search parameters using named arguments:
Kotlin
Search multiple indices
Theclient.multipleQueries() method is now client.search().
Each request in the list requires an indexName:
Kotlin
Search for facet values
Theindex.searchForFacets() method becomes client.searchForFacetValues()
with an indexName parameter:
Kotlin
Update indexing operations
In version 3, indexing methods are on the client instead of the index object, withindexName as a parameter.
Version 3 replaces type wrappers like ObjectID("id") with plain strings.
Add or replace records
Kotlin
Partially update records
Kotlin
Delete records
Kotlin
Update settings, synonyms, and rules
Get and set settings
Kotlin
Save synonyms and rules
Kotlin
In version 2,
index.replaceAllRules() and index.replaceAllSynonyms() replaced all rules or synonyms.
In version 3, use client.saveRules() or client.saveSynonyms() with the clearExistingRules or clearExistingSynonyms parameter set to true.Update index management
ThecopyIndex, moveIndex, copyRules, copySynonyms, and copySettings
methods are all replaced by a single operationIndex method.
Copy an index
Kotlin
Move (rename) an index
Kotlin
Copy only rules or settings
In version 3, use thescope parameter to limit the operation to specific data:
Kotlin
Update task handling
Version 2 supported chaining.wait() on operations.
Version 3 replaces this pattern with dedicated wait helpers.
Kotlin
waitForTask: wait until indexing operations are done.waitForAppTask: wait for application-level tasks.waitForApiKey: wait for API key operations.
Method changes reference
The following tables list all method names that changed between version 2 and version 3.Search API client
| Version 2 (legacy) | Version 3 (current) | |
|---|---|---|
client.addAPIKey | → | client.addApiKey |
client.addAPIKey.wait | → | client.waitForApiKey |
client.clearDictionaryEntries | → | client.batchDictionaryEntries |
client.copyIndex | → | client.operationIndex |
client.copyRules | → | client.operationIndex |
client.copySynonyms | → | client.operationIndex |
client.deleteAPIKey | → | client.deleteApiKey |
client.deleteDictionaryEntries | → | client.batchDictionaryEntries |
client.generateAPIKey | → | client.generateSecuredApiKey |
client.getAPIKey | → | client.getApiKey |
client.getSecuredAPIKeyRemainingValidity | → | client.getSecuredApiKeyRemainingValidity |
client.listAPIKeys | → | client.listApiKeys |
client.listIndices | → | client.listIndices |
client.moveIndex | → | client.operationIndex |
client.multipleBatchObjects | → | client.multipleBatch |
client.multipleQueries | → | client.search |
client.replaceDictionaryEntries | → | client.batchDictionaryEntries |
client.restoreAPIKey | → | client.restoreApiKey |
client.saveDictionaryEntries | → | client.batchDictionaryEntries |
client.updateAPIKey | → | client.updateApiKey |
index.batch | → | client.batch |
index.clearObjects | → | client.clearObjects |
index.clearRules | → | client.clearRules |
index.clearSynonyms | → | client.clearSynonyms |
index.copySettings | → | client.operationIndex |
index.delete | → | client.deleteIndex |
index.deleteBy | → | client.deleteBy |
index.deleteObject | → | client.deleteObject |
index.deleteObjects | → | client.deleteObjects |
index.deleteRule | → | client.deleteRule |
index.deleteSynonym | → | client.deleteSynonym |
index.findObject | → | client.searchSingleIndex |
index.getObject | → | client.getObject |
index.getObjects | → | client.getObjects |
index.getRule | → | client.getRule |
index.getSettings | → | client.getSettings |
index.getSynonym | → | client.getSynonym |
index.getTask | → | client.getTask |
index.partialUpdateObject | → | client.partialUpdateObject |
index.partialUpdateObjects | → | client.partialUpdateObjects |
index.replaceAllObjects | → | client.replaceAllObjects |
index.replaceAllRules | → | client.saveRules |
index.replaceAllSynonyms | → | client.saveSynonyms |
index.saveObject | → | client.saveObject |
index.saveObjects | → | client.saveObjects |
index.saveRule | → | client.saveRule |
index.saveRules | → | client.saveRules |
index.saveSynonym | → | client.saveSynonym |
index.saveSynonyms | → | client.saveSynonyms |
index.search | → | client.searchSingleIndex |
index.searchForFacets | → | client.searchForFacetValues |
index.searchRules | → | client.searchRules |
index.searchSynonyms | → | client.searchSynonyms |
index.setSettings | → | client.setSettings |
index.{operation}.wait | → | client.waitForTask |
Recommend API client
| Version 2 (legacy) | Version 3 (current) | |
|---|---|---|
client.getFrequentlyBoughtTogether | → | client.getRecommendations |
client.getRecommendations | → | client.getRecommendations |
client.getRelatedProducts | → | client.getRecommendations |