11package main
22
33import (
4+ "context"
45 "fmt"
56
67 "github.com/algolia/algoliasearch-client-go/v4/algolia/next/search"
78)
89
9- func testSearch (appID , apiKey string ) int {
10+ func testSearch (ctx context. Context , appID , apiKey string ) int {
1011 // indexName := getEnvWithDefault("SEARCH_INDEX", "test_index")
1112 searchClient , err := search .NewClient (appID , apiKey )
1213 if err != nil {
1314 panic (err )
1415 }
1516
16- err = searchClient .BrowseObjects ("test-flag" , * search .NewEmptyBrowseParamsObject (), search .WithAggregator (func (res any , err error ) {
17+ err = searchClient .BrowseObjects (ctx , "test-flag" , * search .NewEmptyBrowseParamsObject (), search .WithAggregator (func (res any , err error ) {
1718 if err != nil {
1819 panic (err )
1920 }
@@ -29,12 +30,12 @@ func testSearch(appID, apiKey string) int {
2930 //})))
3031
3132 // new way
32- //searchClient.Search([]search.SearchQuery{
33+ //searchClient.Search(ctx, []search.SearchQuery{
3334 // search.NewSearchForHits("indexName").WithQuery("foo"),
3435 //}, nil)
3536
3637 /*
37- response, err := searchClient.AddOrUpdateObject(
38+ response, err := searchClient.AddOrUpdateObject(ctx,
3839 searchClient.NewApiAddOrUpdateObjectRequest(
3940 indexName,
4041 "1",
@@ -49,12 +50,12 @@ func testSearch(appID, apiKey string) int {
4950 panic(err)
5051 }
5152
52- _, err = searchClient.WaitForTask(indexName, *response.TaskID)
53+ _, err = searchClient.WaitForTask(ctx, indexName, *response.TaskID)
5354 if err != nil {
5455 panic(err)
5556 }
5657
57- searchResponse, err := searchClient.Search(
58+ searchResponse, err := searchClient.Search(ctx,
5859 searchClient.NewApiSearchRequest(
5960 search.NewSearchMethodParams(
6061 []search.SearchQuery{
0 commit comments