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)