diff --git a/goes.go b/goes.go index 7f4358b..4439b1a 100644 --- a/goes.go +++ b/goes.go @@ -350,6 +350,17 @@ func (req *Request) Run() (Response, error) { return Response{}, err } + if req.api == "_bulk" && esResp.Errors { + for _, item := range esResp.Items { + for _, i := range item { + if i.Error != "" { + return Response{}, &SearchError{i.Error, i.Status} + } + } + } + return Response{}, &SearchError{Msg: "Unknown error while bulk indexing"} + } + if esResp.Error != "" { return Response{}, &SearchError{esResp.Error, esResp.Status} } diff --git a/structs.go b/structs.go index 6ab44ee..cfd043b 100644 --- a/structs.go +++ b/structs.go @@ -59,6 +59,7 @@ type Request struct { type Response struct { Acknowledged bool Error string + Errors bool Status uint64 Took uint64 TimedOut bool `json:"timed_out"` @@ -111,6 +112,8 @@ type Item struct { Id string `json:"_id"` Index string `json:"_index"` Version int `json:"_version"` + Error string `json:"error"` + Status uint64 `json:"status"` } // Represents the "_all" field when calling the _stats API