diff options
author | Christopher Speller <crspeller@gmail.com> | 2017-07-20 15:22:49 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-20 15:22:49 -0700 |
commit | 58839cefb50e56ae5b157b37e9814ae83ceee70b (patch) | |
tree | 5de966481678096fc9567f74f96673b34a65127c /vendor/gopkg.in/olivere/elastic.v5/delete.go | |
parent | e2f4492eadb5d3c58606b1fdd5774b63a07c236a (diff) | |
download | chat-58839cefb50e56ae5b157b37e9814ae83ceee70b.tar.gz chat-58839cefb50e56ae5b157b37e9814ae83ceee70b.tar.bz2 chat-58839cefb50e56ae5b157b37e9814ae83ceee70b.zip |
Upgrading server dependancies (#6984)
Diffstat (limited to 'vendor/gopkg.in/olivere/elastic.v5/delete.go')
-rw-r--r-- | vendor/gopkg.in/olivere/elastic.v5/delete.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/vendor/gopkg.in/olivere/elastic.v5/delete.go b/vendor/gopkg.in/olivere/elastic.v5/delete.go index 991338715..b1b06c2c3 100644 --- a/vendor/gopkg.in/olivere/elastic.v5/delete.go +++ b/vendor/gopkg.in/olivere/elastic.v5/delete.go @@ -9,6 +9,8 @@ import ( "fmt" "net/url" + "net/http" + "gopkg.in/olivere/elastic.v5/uritemplates" ) @@ -168,7 +170,9 @@ func (s *DeleteService) Validate() error { return nil } -// Do executes the operation. +// Do executes the operation. If the document is not found (404), Elasticsearch will +// still return a response. This response is serialized and returned as well. In other +// words, for HTTP status code 404, both an error and a response might be returned. func (s *DeleteService) Do(ctx context.Context) (*DeleteResponse, error) { // Check pre-conditions if err := s.Validate(); err != nil { @@ -182,7 +186,7 @@ func (s *DeleteService) Do(ctx context.Context) (*DeleteResponse, error) { } // Get HTTP response - res, err := s.client.PerformRequest(ctx, "DELETE", path, params, nil) + res, err := s.client.PerformRequest(ctx, "DELETE", path, params, nil, http.StatusNotFound) if err != nil { return nil, err } @@ -192,6 +196,12 @@ func (s *DeleteService) Do(ctx context.Context) (*DeleteResponse, error) { if err := s.client.decoder.Decode(res.Body, ret); err != nil { return nil, err } + + // If we have a 404, we return both a result and an error, just like ES does + if res.StatusCode == http.StatusNotFound { + return ret, &Error{Status: http.StatusNotFound} + } + return ret, nil } @@ -204,7 +214,7 @@ type DeleteResponse struct { Id string `json:"_id"` Version int64 `json:"_version"` Shards *shardsInfo `json:"_shards"` - Result bool `json:"string,omitempty"` + Result string `json:"result,omitempty"` ForcedRefresh bool `json:"forced_refresh,omitempty"` Found bool `json:"found"` } |