Upgrade the Go API clients to v4

The latest major version of the algoliasearch-client-go package is v4. This page lists the breaking changes since the last release, v3.

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// v3
client := search.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
index := client.InitIndex("ALGOLIA_INDEX_NAME")
index.Search("QUERY")

// v4
client, _ := search.NewClient("ALGOLIA_APPLICATION_ID", "ALGOLIA_API_KEY")
client.SearchSingleIndex(
    client.
        NewApiSearchSingleIndexRequest("ALGOLIA_INDEX_NAME").
        WithSearchParams(
            search.SearchParamsObjectAsSearchParams(
                search.NewEmptySearchParamsObject().SetQuery("QUERY"),
            ),
        ),
)

Wait for tasks

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

Copy or moving indices, settings, synonyms, or rules

Use the operationIndex method, which replaces the following methods:

  • CopyIndex
  • MoveIndex
  • CopyRules
  • CopySynonyms
  • CopySettings
Did you find this page helpful?
Go API clients v4