From 7ee055cb7dcfd82428b4bb450c0d1b608c2d1e59 Mon Sep 17 00:00:00 2001 From: Paul Bonser Date: Thu, 2 Feb 2017 18:28:09 -0600 Subject: [PATCH] Delete mapping is no longer supported in 2.x+ versions of ES --- goes.go | 5 +++++ goes_test.go | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/goes.go b/goes.go index d11e1fb..0e5513b 100644 --- a/goes.go +++ b/goes.go @@ -504,6 +504,11 @@ func (c *Client) Update(d Document, query interface{}, extraArgs url.Values) (*R // DeleteMapping deletes a mapping along with all data in the type func (c *Client) DeleteMapping(typeName string, indexes []string) (*Response, error) { + if version, err := c.Version(); err != nil { + return nil, err + } else if version > "2" { + return nil, errors.New("Deletion of mappings is not supported in ES 2.x and above.") + } r := Request{ IndexList: indexes, diff --git a/goes_test.go b/goes_test.go index bd2bab8..cd0ba7c 100644 --- a/goes_test.go +++ b/goes_test.go @@ -1365,6 +1365,10 @@ func (s *GoesTestSuite) TestDeleteMapping(c *C) { time.Sleep(200 * time.Millisecond) response, err = conn.DeleteMapping("tweet", []string{indexName}) + if version, _ := conn.Version(); version > "2" { + c.Assert(err, ErrorMatches, ".*not supported.*") + return + } c.Assert(err, IsNil) c.Assert(response.Acknowledged, Equals, true)