Upgrade the Ruby API clients to v3

The latest major version of the algolia gem is v3. This page lists the breaking changes since the last release, v2.

Client imports

The class names for the API clients changed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# Search API
Algolia::SearchClient
# Recommend API
Algolia::RecommendClient
# A/B testing
Algolia::AbtestingClient
# Analytics API
Algolia::AnalyticsClient
# Ingestion API
Algolia::IngestionClient
# Insights API
Algolia::InsightsClient
# Monitoring API
Algolia::MonitoringClient
# Personalization API
Algolia::PersonalizationClient
# Query Suggestions API
Algolia::QuerySuggestionsClient
# Usage API
Algolia::UsageClient

Removal of init_index

All methods are methods of a client instance. The init_index method of the SearchClient has been removed. Instead, all methods require a index_name parameter.

1
2
3
4
5
6
7
8
# v2
client = Algolia::Search::Client.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
index = client.init_index("ALGOLIA_INDEX_NAME")
index.search("QUERY")

# v3
client = Algolia::Search::Client.create("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
client.search_single_index("ALGOLIA_INDEX_NAME", {query: "QUERY"})

Wait for tasks

The wait method has been removed. Instead, use one of the following helpers:

Copy or move indices, settings, synonyms, or rules

Use the operation_index method, which replaces the following methods:

  • copy_index
  • move_index
  • copy_rules
  • copy_synonyms
  • copy_settings
Did you find this page helpful?
Ruby API clients v3