Skip to content

Commit 48eb43b

Browse files
authored
Fix UpdateResp to parse get field when _source is requested (#739)
Signed-off-by: raccone <[email protected]>
1 parent fd8d553 commit 48eb43b

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
3333
### Fixed
3434
- Missing "caused by" information in StructError ([#752](https://github.com/opensearch-project/opensearch-go/pull/752))
3535
- Add missing `ignore_unavailable`, `allow_no_indices`, and `expand_wildcards` params to MSearch ([#757](https://github.com/opensearch-project/opensearch-go/pull/757))
36+
- Fix `UpdateResp` to correctly parse the `get` field when `_source` is requested in update operations. ([#739](https://github.com/opensearch-project/opensearch-go/pull/739))
3637

3738
### Security
3839

opensearchapi/api_update.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ type UpdateResp struct {
6161
Successful int `json:"successful"`
6262
Failed int `json:"failed"`
6363
} `json:"_shards"`
64-
SeqNo int `json:"_seq_no"`
65-
PrimaryTerm int `json:"_primary_term"`
66-
Type string `json:"_type"` // Deprecated field
64+
SeqNo int `json:"_seq_no"`
65+
PrimaryTerm int `json:"_primary_term"`
66+
Type string `json:"_type"` // Deprecated field
67+
Get *DocumentGetResp `json:"get,omitempty"`
6768
response *opensearch.Response
6869
}
6970

opensearchapi/api_update_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func TestUpdate(t *testing.T) {
4747
resp, err := client.Update(
4848
nil,
4949
opensearchapi.UpdateReq{
50+
Params: opensearchapi.UpdateParams{Source: true},
5051
Index: testIndex,
5152
DocumentID: "1",
5253
Body: strings.NewReader(`{"script":{"source":"ctx._source.counter += params.count","lang":"painless","params":{"count":4}}}`),

0 commit comments

Comments
 (0)