Skip to main content
The latest major version of the algolia gem 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 change is the removal of the init_index pattern: all methods are now on the client instance directly, with index_name as a parameter. For the full list of changes, see the Ruby changelog.

Update your dependencies

Update the algolia gem to version 3:
Command line
The gem name stays algolia. Don’t confuse it with the older algoliasearch gem, which installs version 1.

Update imports

The module paths for API clients changed. Algolia::Search::Client is now Algolia::SearchClient, and all other clients follow the same flattened pattern.
Ruby
Version 3 includes dedicated client classes for each API:
Ruby

Update client initialization

Besides the class name change, client creation follows the same pattern. The constructor still accepts your application ID and API key:
Ruby
The other major change concerns what follows initialization: init_index no longer exists.

Remove init_index

This is the most significant 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 index_name as a parameter.
Ruby
If you have many files to update, search your codebase for init_index or .init_index( to find every place that needs changing.

Update search calls

Search a single index

The index.search method is now client.search_single_index. Pass the index name and search parameters as positional arguments:
Ruby

Search multiple indices

The client.multiple_queries method is now client.search. Each request in the array requires an index_name:
Ruby

Search for facet values

The index.search_for_facet_values method becomes client.search_for_facet_values with an index_name parameter:
Ruby

Update indexing operations

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

Add or replace records

Ruby

Partially update records

Ruby

Delete records

Ruby

Update settings, synonyms, and rules

Get and set settings

Ruby

Save synonyms and rules

Ruby
In version 2, index.replace_all_rules and index.replace_all_synonyms replaced all rules or synonyms. In version 3, use client.save_rules or client.save_synonyms with clear_existing_rules or replace_existing_synonyms set to true.

Update index management

The copy_index, move_index, copy_rules, copy_synonyms, and copy_settings methods are all replaced by a single operation_index method.

Copy an index

Ruby

Move (rename) an index

Ruby

Copy only rules or settings

In version 3, use the scope parameter to limit the operation to specific data:
Ruby

Check if an index exists

In version 2, you could check if an index existed using the exists? method on the index object. In version 3, use the index_exists helper method on the client:
Ruby

Update task handling

Version 2 supported chaining .wait on operations. Version 3 replaces this pattern with dedicated wait helpers or the built-in wait_for_tasks parameter.
Ruby
Version 3 includes three wait helpers:

Helper method changes

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

Bang methods removed

All bang (!) variants of helper methods have been removed. In version 2, bang methods (save_objects!, delete_objects!, partial_update_objects!, replace_all_objects!) automatically waited for indexing tasks to complete. In version 3, pass true as the wait_for_tasks argument instead.
Ruby

replace_all_objects

The safe: option has been removed. In version 2, safe: true caused the helper to wait after each step. In version 3, 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.
Ruby

save_objects and delete_objects

Two new optional parameters are available in version 3: wait_for_tasks (default false) and batch_size (default 1,000). In version 2, you had to call the bang variants to wait for tasks.
Ruby

browse_objects, browse_rules, browse_synonyms

These helpers moved from the index object to the client and now accept index_name as an explicit first argument. The block receives individual records—one record per block call, not a page object.
Ruby

generate_secured_api_key and get_secured_api_key_remaining_validity

Both methods were class methods in version 2. In version 3, they are available both as instance methods on the client and as class methods on Algolia::Search::SearchClient.
Ruby

wait_for_task

The helper was renamed from wait_task and moved from the index object to the client. The index_name parameter is now required as an explicit argument.
Ruby

wait_for_api_key

In version 2, waiting for API key operations was done by calling .wait on the response object returned by add_api_key, update_api_key, or delete_api_key. Version 3 provides a standalone wait_for_api_key helper.
Ruby

wait_for_app_task and chunked_batch

These are new helpers in version 3 with no equivalent in version 2.
Ruby

index_exists?

This is a new helper in version 3.
Ruby

copy_index_between_applications

In version 2, the separate Algolia::AccountClient class provided a copy_index method for copying an index between two different Algolia applications. It accepted two index objects, each belonging to a different client. In version 3, AccountClient is removed. You can compose existing helpers across two clients to achieve the same result.
Ruby

save_objects_with_transformation

In version 3 and later: routes records with the Push to Algolia connector. Requires set_transformation_options to be called, or the client created via Algolia::SearchClient.with_transformation.
Ruby

replace_all_objects_with_transformation

In version 3 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, and synonyms.
Ruby

partial_update_objects_with_transformation

In version 3 and later: routes partial updates with the Push to Algolia connector. The create_if_not_exists parameter defaults to false.
Ruby

Method changes reference

The following tables list all method names that changed between version 2 and version 3.
A few methods were also renamed: list_indexes is now list_indices, and get_top_user_id is now get_top_user_ids.

Search API client

Recommend API client

Last modified on June 10, 2026