|
|
@ -104,6 +104,27 @@ func handleIndexCommand() { |
|
|
|
os.Exit(1) |
|
|
|
} |
|
|
|
|
|
|
|
case "refresh": |
|
|
|
refreshcmd := flag.NewFlagSet("index refresh", flag.ExitOnError) |
|
|
|
refreshcmd.SetOutput(os.Stdout) |
|
|
|
cfgpath := refreshcmd.String("config", "", "path to configuration") |
|
|
|
iname := refreshcmd.String("name", "", "(required) index name to refresh") |
|
|
|
refreshcmd.Parse(os.Args[3:]) |
|
|
|
|
|
|
|
if *iname == "" { |
|
|
|
fmt.Fprintf(os.Stderr, "name parameter is required for index refresh\n") |
|
|
|
refreshcmd.PrintDefaults() |
|
|
|
os.Exit(1) |
|
|
|
} |
|
|
|
|
|
|
|
cfg := LoadConfig(*cfgpath) |
|
|
|
es := ClientFromConfig(cfg.Elastic) |
|
|
|
_, err := es.Refresh(*iname).Do(context.Background()) |
|
|
|
if err != nil { |
|
|
|
fmt.Fprintf(os.Stderr, "elastic error: %s\n", err.Error()) |
|
|
|
os.Exit(1) |
|
|
|
} |
|
|
|
|
|
|
|
case "--help": |
|
|
|
printIndexUsage() |
|
|
|
os.Exit(0) |
|
|
@ -124,4 +145,5 @@ func printIndexUsage() { |
|
|
|
fmt.Printf(" list list indexes\n") |
|
|
|
fmt.Printf(" delete delete index\n") |
|
|
|
fmt.Printf(" create create index\n") |
|
|
|
fmt.Printf(" refresh refresh index\n") |
|
|
|
} |