_optimize was renamed to _forcemerge in ES 2.1.0

This commit is contained in:
Paul Bonser 2017-02-02 19:08:33 -06:00
parent 4b35e6f0cf
commit a6663ce61d

View File

@ -119,10 +119,18 @@ func (c *Client) Optimize(indexList []string, extraArgs url.Values) (*Response,
Method: "POST",
API: "_optimize",
}
if version, _ := c.Version(); version > "2.1" {
r.API = "_forcemerge"
}
return c.Do(&r)
}
// ForceMerge is the same as Optimize, but matches the naming of the endpoint as of ES 2.1.0
func (c *Client) ForceMerge(indexList []string, extraArgs url.Values) (*Response, error) {
return c.Optimize(indexList, extraArgs)
}
// Stats fetches statistics (_stats) for the current elasticsearch server
func (c *Client) Stats(indexList []string, extraArgs url.Values) (*Response, error) {
r := Request{