Handle non-string errors for ES 2+ support
This commit is contained in:
parent
2715203d96
commit
5d13647d3c
7
goes.go
7
goes.go
@ -516,6 +516,13 @@ func (c *Client) Do(r Requester) (*Response, error) {
|
||||
}
|
||||
}
|
||||
|
||||
if len(esResp.RawError) > 0 && esResp.RawError[0] == '"' {
|
||||
json.Unmarshal(esResp.RawError, &esResp.Error)
|
||||
} else {
|
||||
esResp.Error = string(esResp.RawError)
|
||||
}
|
||||
esResp.RawError = nil
|
||||
|
||||
if esResp.Error != "" {
|
||||
return esResp, &SearchError{esResp.Error, esResp.Status}
|
||||
}
|
||||
|
@ -4,7 +4,10 @@
|
||||
|
||||
package goes
|
||||
|
||||
import "net/http"
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
// Client represents a connection to elasticsearch
|
||||
type Client struct {
|
||||
@ -23,6 +26,7 @@ type Client struct {
|
||||
type Response struct {
|
||||
Acknowledged bool
|
||||
Error string
|
||||
RawError json.RawMessage `json:"error"`
|
||||
Errors bool
|
||||
Status uint64
|
||||
Took uint64
|
||||
|
Loading…
Reference in New Issue
Block a user