Skip to main content
The latest major version of the algoliasearch-scala package is version 2. This page helps you upgrade from version 1 and explains the breaking changes you need to address. Algolia generates the version 2 client 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 domain-specific language (DSL). Instead of writing expressions like client.execute { search into "index" query "q" } (version 1), you call methods directly on the SearchClient instance, passing named parameters. For the full list of changes, see the Scala changelog.

Update your dependencies

Update the algoliasearch-scala package to version 2. With sbt, update the version range in your build.sbt file:
build.sbt
With Maven, update the version in your pom.xml file:
pom.xml
The version 2 client is cross-published for Scala 2.13 and Scala 3. sbt resolves the correct artifact automatically based on your scalaVersion. If you use Maven, replace _2.13 with _3 in the artifactId for Scala 3 projects.

Update imports

The package namespace changed from algolia to algoliasearch. Version 2 also includes dedicated imports for each API.
Scala
Version 2 includes separate client classes for each API. If you only need a specific API, import the corresponding client:
Scala

Update client initialization

The client class was renamed from AlgoliaClient to SearchClient, and you no longer use the new keyword.
Scala
Unlike other language clients, version 1 of the Scala client didn’t have a separate initIndex step. The DSL handled index references inline, embedding the index name into expressions like search into "index". In version 2, you pass indexName as a named parameter to every method. There’s no index object and no DSL expression.

Remove the domain-specific language

This is the most significant change when upgrading the Scala client. Version 1 provided a domain-specific language (DSL) through algolia.AlgoliaDsl._ that let you write expressive, English-like code inside client.execute { ... } blocks. Version 2 removes the DSL entirely. Every client.execute { ... } call must be replaced with a direct method call on the client. Here are the most common DSL patterns and their replacements:
Scala

Index an object

Scala

Parse results

Scala
Search your codebase for client.execute, AlgoliaDsl, and import algolia. to find every place that needs changing.

Update search calls

Search a single index

The DSL search into expression is now client.searchSingleIndex(). Pass the index name and search parameters as named arguments:
Scala

Search multiple indices

The multiQueries DSL is now client.search(). Each request in the list requires an indexName:
Scala

Search for facet values

The search facet DSL is now on the client and requires indexName and facetName parameters:
Scala

Update indexing operations

In version 2, indexing methods are direct client method calls with indexName as a parameter.

Add or replace records

Scala

Partially update records

Scala

Delete records

Scala

Update settings, synonyms, and rules

Get and set settings

Scala

Save synonyms and rules

Many synonym and rule operations weren’t available in version 1 of the Scala client. Version 2 includes full coverage of the API, including saveSynonyms, saveRules, and replaceAllObjects.
Scala
Scala
In version 1, replaceAllRules and replaceAllSynonyms weren’t available in the Scala client. In version 2, use client.saveRules() with clearExistingRules = Some(true) or client.saveSynonyms() with replaceExistingSynonyms = Some(true) to replace all rules or synonyms.

Update index management

The copy index and move index DSL commands are replaced by a single operationIndex method.

Copy an index

Scala

Move (rename) an index

Scala

Copy only rules or settings

In version 2, use the scope parameter to limit the operation to specific data:
Scala

Check if an index exists

Version 2 introduces the indexExists helper method to check if an index exists. This method wasn’t available in version 1.
Scala

Update task handling

Version 1 relied on calling .wait() on Future results or Await.ready. Version 2 replaces this pattern with dedicated wait helpers. Since all methods return Future[...], you can chain waitForTask with a flatMap:
Scala
Version 2 includes three wait helpers:

Helper method changes

The following sections document breaking changes in helper method signatures and behavior between version 1 and version 2.

generateSecuredApiKey

The method was previously available through the version 1 DSL as a static utility. In version 2, it is an instance method on the client.
Scala

replaceAllObjects

In version 2 and later: atomically replaces all objects in an index by copying it, batch-saving new objects, then moving the copy back. batchSize defaults to 1,000 and scopes defaults to ["settings", "rules", "synonyms"].
Scala

saveObjects

In version 2 and later: sends objects in chunks. waitForTasks defaults to false and batchSize defaults to 1,000.
Scala

deleteObjects

In version 2 and later: deletes objects by ID in chunks. waitForTasks defaults to false and batchSize defaults to 1,000.
Scala

partialUpdateObjects

In version 2 and later: createIfNotExists defaults to false.
Scala

browseObjects, browseRules, browseSynonyms

In version 2 and later: each helper accepts an aggregator callback invoked with every page, and an optional validate callback to stop early.
Scala

waitForTask

In version 2 and later: polls until an indexing task reaches the published state. maxRetries defaults to 100.
Scala

waitForAppTask

In version 2 and later: polls until an application-level task completes.
Scala

waitForApiKey

In version 2 and later: polls until an API key operation (add, update, or delete) has propagated.
Scala

indexExists

In version 2 and later: returns true if the index exists.
Scala

chunkedBatch

In version 2 and later: sends objects in chunks with a specified action. waitForTasks is required with no default.
Scala

getSecuredApiKeyRemainingValidity

In version 2 and later: returns the time remaining until a secured API key expires, based on its embedded validUntil parameter.
Scala

accountCopyIndex

The Scala API client doesn’t include a built-in helper for copying indices across applications. To achieve the same result, use the existing helpers with two clients.
Scala

saveObjectsWithTransformation

In version 2 and later: routes records with the Push to Algolia connector. Requires TransformationOptions to be passed to the client via SearchClient.withTransformation.
Scala

replaceAllObjectsWithTransformation

In version 2 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. scopes defaults to ["settings", "rules", "synonyms"].
Scala

partialUpdateObjectsWithTransformation

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

Method changes reference

The following tables list all method names that changed between version 1 and version 2.

Search API client

Recommend API client

Last modified on June 10, 2026