Upgrade the Kotlin API clients to v3
The latest major version of the algoliasearch-client-kotlin package is v3.
This page lists the breaking changes since the last release, v2.
Method changes overview
The following table has links for all methods and their replacements
Search API client
Recommend API client
| v2 (legacy) | v3 (latest) | |
|---|---|---|
client.getFrequentlyBoughtTogether |
→ | client.getRecommendations |
client.getRecommendations |
→ | client.getRecommendations |
client.getRelatedProducts |
→ | client.getRecommendations |
Removal of initIndex
All methods are methods of a client instance.
The initIndex method of the SearchClient class has been removed.
Instead, all methods require a indexName parameter.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// v2
val client = ClientSearch(
ApplicationID("ALGOLIA_APPLICATION_ID"),
APIKey("ALGOLIA_API_KEY")
)
val index = client.initIndex(
IndexName("ALGOLIA_INDEX_NAME")
)
index.search(Query("QUERY"))
// v3
val client = SearchClient(
"ALGOLIA_APPLICATION_ID",
"ALGOLIA_API_KEY"
)
client.searchSingleIndex(
"ALGOLIA_INDEX_NAME",
SearchParamsObject(query = "QUERY")
)
No domain-specific language
The domain-specific language for setting parameters and filters from the v2 API client has been removed.
Wait for tasks
The wait method has been removed.
Instead, use one of the following helpers:
waitForTaskto wait until indexing operations are donewaitForAppTaskto wait for application-level taskswaitForApiKeyto wait for API key operations
Copy or moving indices, settings, synonyms, or rules
Use the operationIndex method,
which replaces the following methods:
copyIndexmoveIndexcopyRulescopySynonymscopySettings