@@ -29,7 +29,7 @@ go get github.com/opensearch-project/opensearch-go
29
29
30
30
## Connecting to OpenSearch
31
31
32
- To connect to the default OpenSearch host, create a client object with the address ` https://localhost:9200 ` if you are using the Security plugin:
32
+ To connect to the default OpenSearch host, create a client object with the address ` https://localhost:9200 ` if you are using the Security plugin:
33
33
34
34
``` go
35
35
client , err := opensearch.NewClient (opensearch.Config {
@@ -66,11 +66,11 @@ import (
66
66
" context"
67
67
" log"
68
68
69
- " github.com/aws/aws-sdk-go-v4 /aws"
70
- " github.com/aws/aws-sdk-go-v4 /config"
69
+ " github.com/aws/aws-sdk-go-v2 /aws"
70
+ " github.com/aws/aws-sdk-go-v2 /config"
71
71
opensearch " github.com/opensearch-project/opensearch-go/v4"
72
- opensearchapi " github.com/opensearch-project/opensearch-go/v4@v4.3.0 /opensearchapi"
73
- requestsigner " github.com/opensearch-project/opensearch-go/v4@v4.3.0 /signer/awsv2"
72
+ opensearchapi " github.com/opensearch-project/opensearch-go/v4/opensearchapi"
73
+ requestsigner " github.com/opensearch-project/opensearch-go/v4/signer/awsv2"
74
74
)
75
75
76
76
const endpoint = " " // e.g. https://opensearch-domain.region.com or Amazon OpenSearch Serverless endpoint
@@ -102,6 +102,9 @@ func main() {
102
102
if err != nil {
103
103
log.Fatal (" client creation err" , err)
104
104
}
105
+
106
+ _ = client
107
+ // your code here
105
108
}
106
109
107
110
func getCredentialProvider (accessKey , secretAccessKey , token string ) aws .CredentialsProviderFunc {
@@ -128,11 +131,10 @@ import (
128
131
" context"
129
132
" log"
130
133
131
- " github.com/aws/aws-sdk-go-v4 /aws"
132
- " github.com/aws/aws-sdk-go-v4 /config"
134
+ " github.com/aws/aws-sdk-go-v2 /aws"
135
+ " github.com/aws/aws-sdk-go-v2 /config"
133
136
opensearch " github.com/opensearch-project/opensearch-go/v4"
134
- opensearchapi
" github.com/opensearch-project/opensearch-go/[email protected] /opensearchapi"
135
- requestsigner
" github.com/opensearch-project/opensearch-go/[email protected] /signer/awsv2"
137
+ requestsigner " github.com/opensearch-project/opensearch-go/v4/signer/awsv2"
136
138
)
137
139
138
140
const endpoint = " " // e.g. https://opensearch-domain.region.com or Amazon OpenSearch Serverless endpoint
@@ -164,6 +166,9 @@ func main() {
164
166
if err != nil {
165
167
log.Fatal (" client creation err" , err)
166
168
}
169
+
170
+ _ = client
171
+ // your code here
167
172
}
168
173
169
174
func getCredentialProvider (accessKey , secretAccessKey , token string ) aws .CredentialsProviderFunc {
@@ -173,7 +178,6 @@ func getCredentialProvider(accessKey, secretAccessKey, token string) aws.Credent
173
178
SecretAccessKey: secretAccessKey,
174
179
SessionToken: token,
175
180
}
176
- return *c, nil
177
181
}
178
182
}
179
183
```
@@ -197,7 +201,7 @@ client, err := opensearch.NewClient(opensearch.Config{
197
201
```
198
202
{% include copy.html %}
199
203
200
- The Go client retries requests for a maximum of three times by default. To customize the number of retries, set the ` MaxRetries ` parameter. Additionally, you can change the list of response codes for which a request is retried by setting the ` RetryOnStatus ` parameter. The following code snippet creates a new Go client with custom ` MaxRetries ` and ` RetryOnStatus ` values:
204
+ The Go client retries requests for a maximum of three times by default. To customize the number of retries, set the ` MaxRetries ` parameter. Additionally, you can change the list of response codes for which a request is retried by setting the ` RetryOnStatus ` parameter. The following code snippet creates a new Go client with custom ` MaxRetries ` and ` RetryOnStatus ` values:
201
205
202
206
``` go
203
207
client , err := opensearch.NewClient (opensearch.Config {
@@ -226,7 +230,7 @@ settings := strings.NewReader(`{
226
230
}` )
227
231
228
232
res := opensearchapi.IndicesCreateRequest {
229
- Index : " go-test-index1" ,
233
+ Index : " go-test-index1" ,
230
234
Body : settings,
231
235
}
232
236
```
@@ -369,7 +373,7 @@ func main() {
369
373
370
374
// Create an index with non-default settings.
371
375
res := opensearchapi.IndicesCreateRequest {
372
- Index: IndexName,
376
+ Index: IndexName,
373
377
Body: settings,
374
378
}
375
379
fmt.Println (" Creating index" )
@@ -396,7 +400,7 @@ func main() {
396
400
fmt.Println (" Inserting a document" )
397
401
fmt.Println (insertResponse)
398
402
defer insertResponse.Body .Close ()
399
-
403
+
400
404
// Perform bulk operations.
401
405
blk , err := client.Bulk (
402
406
strings.NewReader (`
0 commit comments