Oct 21, 2024
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
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.
Copy
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:
WaitForTask
to wait until indexing operations are doneWaitForAppTask
to wait for application-level tasksWaitForApiKey
to wait for API key operations
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?