Skip to main content
The latest major version of the algoliasearch package is version 4. This page helps you upgrade from version 3 and explains the breaking changes you need to address. Algolia generates the version 4 clients from OpenAPI specifications, which provides consistent behavior across all languages and up-to-date API coverage. The main architectural change is the removal of the initIndex pattern: all methods are now on the client instance directly, with indexName as a parameter. For the full list of changes, see the Java changelog.

Update your dependencies

Version 4 consolidates the separate algoliasearch-core and HTTP client packages into a single algoliasearch artifact. You no longer need algoliasearch-apache or algoliasearch-java-net.

Maven

Replace your Algolia dependencies in pom.xml:
pom.xml

Gradle

Update your build.gradle file:
build.gradle
Find the latest version on Maven Central.

Update imports

The package structure changed. Client classes moved from com.algolia.search to com.algolia.api, and model classes moved to com.algolia.model.search.
Java
Version 4 also includes dedicated client classes for each API:
Java

Update client initialization

In version 3, the DefaultSearchClient.create() factory method created the client. Version 4 removes this factory. Use the SearchClient constructor instead.
Java
The version 4 client implements Closeable. Use try-with-resources to ensure the client is properly closed:
Java

Understand the new API surface

Version 4 introduces two major changes to the API surface:
  • No more initIndex. In version 3, the client created a typed SearchIndex<T> object with methods called on it. In version 4, the SearchIndex class is gone. All methods belong to the client instance, with indexName as a parameter.
  • Generic type parameter moves to each method call. In version 3, you set the result type once on initIndex("INDEX", Record.class). In version 4, you pass the target class (for example, Hit.class) as the last argument to each method that returns typed results, such as searchSingleIndex or getObject.
Java
If you have many files to update, search your codebase for initIndex or .initIndex( to find every place that needs changing.

Update search calls

Search a single index

The index.search() method is now client.searchSingleIndex(). Pass the index name, a SearchParamsObject, and the target class:
Java

Search multiple indices

The client.multipleQueries() method is now client.search(). Each request in the list requires an indexName:
Java

Search for facet values

The index.searchForFacetValues() method becomes client.searchForFacetValues() with an indexName parameter:
Java

Update indexing operations

In version 4, indexing methods are on the client instead of the index object, with indexName as a parameter.

Add or replace records

Java

Partially update records

Java

Delete records

Java

Update settings, synonyms, and rules

Get and set settings

Java

Save synonyms and rules

Java
In version 3, index.replaceAllRules() and index.replaceAllSynonyms() replaced all rules or synonyms. In version 4, use client.saveRules() or client.saveSynonyms() with the clearExistingRules or clearExistingSynonyms parameter set to true.

Update index management

The copyIndex, moveIndex, copyRules, copySynonyms, and copySettings methods are all replaced by a single operationIndex method.

Copy an index

Java

Move (rename) an index

Java

Copy only rules or settings

In version 4, use the scope parameter to limit the operation to specific data:
Java

Check if an index exists

In version 3, you could check if an index existed using the exists method on the index object. In version 4, use the indexExists helper method on the client:
Java

Update task handling

Version 3 supported chaining .waitTask() on operations. Version 4 replaces this pattern with dedicated wait helpers.
Java
Version 4 includes three wait helpers:

Helper method changes

The following sections document breaking changes in helper method signatures and behavior between version 3 and version 4.

replaceAllObjects

The safe parameter has been removed. In version 3, passing safe = true caused the helper to wait after each step. In version 4, the helper always waits—equivalent to the previous safe = true behavior. The scopes parameter is optional. When omitted, it defaults to all three: SETTINGS, RULES, and SYNONYMS.
Java

saveObjects

The autoGenerateObjectID parameter has been removed. In version 4, every object must include an objectID. To have the API generate object IDs, use chunkedBatch with Action.ADD_OBJECT. Two new optional parameters are available:
  • waitForTasks (default false)
  • batchSize (default 1,000)
Java

deleteObjects

Two new optional parameters are available:
  • waitForTasks (default false)
  • batchSize (default 1,000)
Java

partialUpdateObjects

The createIfNotExists parameter is now required—the overload without it has been removed (it previously defaulted to false).
Java

browseObjects, browseRules, browseSynonyms

These helpers no longer return iterable types (IndexIterable, RulesIterable, SynonymsIterable). In version 4, they return a lazy Iterable<T> that you can iterate or stream directly.
Java

waitForTask

The helper was renamed from waitTask to waitForTask. It now returns GetTaskResponse instead of void, and the timeToWait millisecond parameter is replaced by maxRetries (default 100) and a timeout function (default: retry delay that increases exponentially, up to 5 seconds).
Java

waitForAppTask

This is a new helper in version 4.
Java

waitForApiKey

This is a new standalone helper in version 4.
Java

generateSecuredApiKey

The method was renamed from generateSecuredAPIKey to generateSecuredApiKey (camelCase normalization). The parameter type also changed from SecuredApiKeyRestriction (singular) to SecuredApiKeyRestrictions (plural).
Java

getSecuredApiKeyRemainingValidity

The parameter was renamed from securedAPIKey to securedApiKey (camelCase normalization).
Java

indexExists

This helper is new in version 4.
Java

chunkedBatch

chunkedBatch is now a public helper. In version 3, chunking was an internal detail of saveObjects.
Java

copyIndexBetweenApplications

In version 3, the static AccountClient class provided copyIndex and copyIndexAsync for copying an index between two Algolia applications. It accepted two typed SearchIndex<T> objects. In version 4, AccountClient is removed. You can compose existing helpers across two clients to achieve the same result.
Java

saveObjectsWithTransformation

In version 4 and later: routes records with the Push to Algolia connector. Requires a client created with SearchClient.withTransformation, passing TransformationOptions with a region. The setTransformationRegion method is deprecated. Use withTransformation or setTransformationOptions instead.
Java

replaceAllObjectsWithTransformation

In version 4 and later: atomically replaces all records with the Push to Algolia connector. It copies settings, rules, and synonyms to a temporary index, pushes records to the temporary index, and moves the temporary index back. Requires a client created with SearchClient.withTransformation, passing TransformationOptions with a region. The setTransformationRegion method is deprecated. Use withTransformation or setTransformationOptions instead.
Java

partialUpdateObjectsWithTransformation

In version 4 and later: routes partial updates with the Push to Algolia connector. The createIfNotExists parameter defaults to false.
Java

Method changes reference

The following tables list all method names that changed between version 3 and version 4.

Search API client

Recommend API client

Last modified on June 10, 2026