From 6d8c5d2699145dfc0968306c4e8024fd1ed8a3b5 Mon Sep 17 00:00:00 2001 From: Marin Bek Date: Fri, 9 Sep 2016 17:43:35 +0200 Subject: [PATCH] replace index in alias --- goes.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/goes.go b/goes.go index 684c024..9c54a90 100644 --- a/goes.go +++ b/goes.go @@ -641,3 +641,29 @@ func (c *Connection) GetAliases(indexes []string) (*Response, error) { return r.Run() } + +func (c *Connection) ReplaceIndexInAlias(alias string, old_index string, new_index string) (*Response, error) { + command := map[string]interface{}{ + "actions": make([]map[string]interface{}, 1), + } + + command["actions"] = append(command["actions"].([]map[string]interface{}), map[string]interface{}{ + "remove": map[string]interface{}{ + "index": old_index, + "alias": alias, + }, + "add": map[string]interface{}{ + "index": new_index, + "alias": alias, + }, + }) + + r := Request{ + Conn: c, + Query: command, + method: "POST", + api: "_aliases", + } + + return r.Run() +}