From a6663ce61d1ba929f8f4d2c3037da781b4ed19d7 Mon Sep 17 00:00:00 2001 From: Paul Bonser Date: Thu, 2 Feb 2017 19:08:33 -0600 Subject: [PATCH] _optimize was renamed to _forcemerge in ES 2.1.0 --- goes.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/goes.go b/goes.go index 0e5513b..f99976b 100644 --- a/goes.go +++ b/goes.go @@ -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{