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.

Method changes overview

The following table has links for all methods and their replacements

Search API client

v3 (legacy) v4 (latest)
client.AddAPIKey client.AddApiKey
client.AddAPIKey.wait client.WaitForApiKey
client.AssignUserID client.AssignUserId
not available client.BatchAssignUserIds
client.ClearDictionaryEntries client.BatchDictionaryEntries
client.CopyIndex client.OperationIndex
client.CopyRules client.OperationIndex
client.CopySynonyms client.OperationIndex
client.DeleteAPIKey client.DeleteApiKey
client.DeleteDictionaryEntries client.BatchDictionaryEntries
client.GenerateSecuredAPIKey client.GenerateSecuredApiKey
client.GetAPIKey client.GetApiKey
client.GetSecuredAPIKeyRemainingValidity client.GetSecuredApiKeyRemainingValidity
client.GetTopUserIDs client.GetTopUserIds
client.GetUserID client.GetUserId
client.ListAPIKeys client.ListApiKeys
client.ListIndices client.ListIndices
client.ListUserIDs client.ListUserIds
client.MoveIndex client.OperationIndex
client.MultipleBatch client.MultipleBatch
client.MultipleQueries client.Search
client.RemoveUserID client.RemoveUserId
client.ReplaceDictionaryEntries client.BatchDictionaryEntries
client.RestoreAPIKey client.RestoreApiKey
client.SaveDictionaryEntries client.BatchDictionaryEntries
client.SearchUserIDs client.SearchUserIds
client.UpdateAPIKey client.UpdateApiKey
index.Batch client.Batch
index.BrowseObjects client.BrowseObjects
index.BrowseRules client.BrowseRules
index.BrowseSynonyms client.BrowseSynonyms
index.ClearObjects client.ClearObjects
index.ClearRules client.ClearRules
index.ClearSynonyms client.ClearSynonyms
index.CopySettings client.OperationIndex
index.Delete client.DeleteIndex
index.DeleteBy client.DeleteBy
index.DeleteObject client.DeleteObject
index.DeleteObjects client.DeleteObjects
index.DeleteRule client.DeleteRule
index.DeleteSynonym client.DeleteSynonym
index.FindObject client.SearchSingleIndex
index.GetObject client.GetObject
index.GetObjects client.GetObjects
index.GetRule client.GetRule
index.GetSettings client.GetSettings
index.GetSynonym client.GetSynonym
index.GetStatus client.GetTask
index.PartialUpdateObject client.PartialUpdateObject
index.PartialUpdateObjects client.PartialUpdateObjects
index.ReplaceAllObjects client.ReplaceAllObjects
index.ReplaceAllRules client.SaveRules
index.ReplaceAllSynonyms client.SaveSynonyms
index.SaveObject client.SaveObject
index.SaveObjects client.SaveObjects
index.SaveRule client.SaveRule
index.SaveRules client.SaveRules
index.SaveSynonym client.SaveSynonym
index.SaveSynonyms client.SaveSynonyms
index.Search client.SearchSingleIndex
index.SearchForFacetValues client.SearchForFacetValues
index.SearchRules client.SearchRules
index.SearchSynonyms client.SearchSynonyms
index.SetSettings client.SetSettings
index.{operation}.wait client.WaitForTask

Recommend API client

v3 (legacy) v4 (latest)
client.GetFrequentlyBoughtTogether client.GetRecommendations
client.GetRecommendations client.GetRecommendations
client.GetRelatedProducts client.GetRecommendations

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