replace index in alias

This commit is contained in:
Marin Bek 2016-09-09 17:43:35 +02:00
parent 71d6bc3694
commit 6d8c5d2699

26
goes.go
View File

@ -641,3 +641,29 @@ func (c *Connection) GetAliases(indexes []string) (*Response, error) {
return r.Run() 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()
}