Dec 11, 2024
Upgrade the Java API clients to v4
The latest major version of the algoliasearch package is v4.
This page lists the breaking changes since the last release, v3.
Method changes overview
The following table has links for all methods and their replacements
Search API client
Recommend API client
| v3 (legacy) | v4 (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.
Copy
1
2
3
4
5
6
7
8
9
10
11
12
// v3
var client = DefaultSearchClient.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");
var index = client.initIndex("ALGOLIA_INDEX_NAME", Record.class);
index.search(new Query("QUERY"));
// v4
var client = new SearchClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY");
client.searchSingleIndex(
"ALGOLIA_INDEX_NAME",
new SearchParamsObject().setQuery("QUERY"),
Hit.class,
)
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
Did you find this page helpful?