This repository was archived by the owner on Sep 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathflush_disable.go
More file actions
63 lines (50 loc) · 1.26 KB
/
flush_disable.go
File metadata and controls
63 lines (50 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"log"
)
var cmdFlushDisable = &Command{
Run: runFlushDisable,
Usage: "flush-disable [index]",
Short: "disable flush",
Long: `
Disables flush. Useful if you want to prevent accidential flushes
from happening, e.g. while performing a backup via rsync.
Use flush-enable to revert this action.
This is basically the same as:
curl -XPUT 'localhost:9200/_settings' -d '{
"index" : {
"translog.disable_flush" : "true"
}
}'
Example:
$ es flush-disable
$ es flush-disable twitter
`,
ApiUrl: "http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings.html",
}
func runFlushDisable(cmd *Command, args []string) {
index := ""
if len(args) >= 1 {
index = args[0]
}
translogReq := make(map[string]interface{})
translogReq["translog.disable_flush"] = "true"
data := make(map[string]interface{})
data["index"] = translogReq
var response struct {
Ok bool `json:"ok,omitempty"`
Error string `json:"error,omitempty"`
Status int `json:"status,omitempty"`
}
path := ""
if index != "" {
path += "/"+index
}
path += "/_settings"
req := ESReq("PUT", path)
req.SetBodyJson(data)
req.Do(&response)
if len(response.Error) > 0 {
log.Fatalf("Error: %v (%v)\n", response.Error, response.Status)
}
}