Delete mapping is no longer supported in 2.x+ versions of ES

This commit is contained in:
Paul Bonser 2017-02-02 18:28:09 -06:00
parent 28784db09c
commit 7ee055cb7d
2 changed files with 9 additions and 0 deletions

View File

@ -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 // DeleteMapping deletes a mapping along with all data in the type
func (c *Client) DeleteMapping(typeName string, indexes []string) (*Response, error) { 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{ r := Request{
IndexList: indexes, IndexList: indexes,

View File

@ -1365,6 +1365,10 @@ func (s *GoesTestSuite) TestDeleteMapping(c *C) {
time.Sleep(200 * time.Millisecond) time.Sleep(200 * time.Millisecond)
response, err = conn.DeleteMapping("tweet", []string{indexName}) 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(err, IsNil)
c.Assert(response.Acknowledged, Equals, true) c.Assert(response.Acknowledged, Equals, true)