Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Backport 8.12] Add untyped union deserialization #777

Merged
merged 2 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
48 changes: 48 additions & 0 deletions elasticsearch_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,21 @@ func TestTypedClient(t *testing.T) {
t.Fatalf("could not retrieve document: %s", err)
}

mgetResponse, err := es.Mget().Index(indexName).Ids("1", "2").Do(context.Background())
if err != nil {
t.Fatalf("could not mget documents: %s", err)
}
for _, doc := range mgetResponse.Docs {
switch d := doc.(type) {
case *types.GetResult:
if d.Found != true {
t.Fatalf("error while doing reading mget response")
}
case *types.MultiGetError:
t.Fatalf("document should exist at this point")
}
}

// Try to retrieve a faulty index name
if ok, _ := es.Get("non-existent-index", "9999").IsSuccess(context.Background()); ok {
t.Fatalf("index shouldn't exist")
Expand Down Expand Up @@ -466,6 +481,39 @@ func TestTypedClient(t *testing.T) {
}
}
}

msearch := es.Msearch()
_ = msearch.AddSearch(types.MultisearchHeader{Index: []string{indexName}}, types.MultisearchBody{Query: &types.Query{
Match: map[string]types.MatchQuery{
"name": {Query: "Foo"},
},
}})
_ = msearch.AddSearch(types.MultisearchHeader{Index: []string{indexName}}, types.MultisearchBody{Aggregations: map[string]types.Aggregations{
"total_prices": {
Sum: &types.SumAggregation{
Field: some.String("price"),
},
},
}})
_ = msearch.AddSearch(types.MultisearchHeader{Index: []string{"non-existent-index"}}, types.MultisearchBody{Query: &types.Query{Match: map[string]types.MatchQuery{
"foo": {Query: "bzz"},
}}})
msearchRes, err := msearch.Do(context.Background())
if err != nil {
t.Fatal(err)
}
for _, response := range msearchRes.Responses {
switch r := response.(type) {
case *types.MultiSearchItem:
if *r.Status != 200 {
t.Fatalf("error while reading multisearch response")
}
case *types.ErrorResponseBase:
if r.Status != 404 {
t.Fatalf("expected 404 index_not_found_exception, got: %v", r)
}
}
}
})

t.Run("Term query from JSON", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion typedapi/api._.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion typedapi/asyncsearch/delete/delete.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions typedapi/asyncsearch/delete/response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion typedapi/asyncsearch/get/get.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions typedapi/asyncsearch/get/response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions typedapi/asyncsearch/status/response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion typedapi/asyncsearch/status/status.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions typedapi/asyncsearch/submit/request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions typedapi/asyncsearch/submit/response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion typedapi/asyncsearch/submit/submit.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions typedapi/autoscaling/deleteautoscalingpolicy/response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions typedapi/autoscaling/getautoscalingcapacity/response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions typedapi/autoscaling/getautoscalingpolicy/response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions typedapi/autoscaling/putautoscalingpolicy/request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions typedapi/autoscaling/putautoscalingpolicy/response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion typedapi/cat/aliases/aliases.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions typedapi/cat/aliases/response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion typedapi/cat/allocation/allocation.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions typedapi/cat/allocation/response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion typedapi/cat/componenttemplates/component_templates.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions typedapi/cat/componenttemplates/response.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading