mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 04:54:18 +02:00
57
cmd/index.go
57
cmd/index.go
@@ -36,11 +36,11 @@ func Index(conf *cfg.Config) *cli.Command {
|
||||
Commands: []*cli.Command{
|
||||
IndexList(conf),
|
||||
IndexShow(conf),
|
||||
IndexCreate(conf),
|
||||
IndexCreate(conf, false),
|
||||
IndexCreate(conf, true),
|
||||
IndexDelete(conf),
|
||||
IndexClose(conf),
|
||||
IndexAllocation(conf),
|
||||
IndexModify(conf),
|
||||
IndexFields(conf),
|
||||
IndexIlm(conf),
|
||||
|
||||
@@ -143,12 +143,20 @@ func IndexShow(conf *cfg.Config) *cli.Command {
|
||||
}
|
||||
}
|
||||
|
||||
func IndexCreate(conf *cfg.Config) *cli.Command {
|
||||
func IndexCreate(conf *cfg.Config, modify bool) *cli.Command {
|
||||
name := "create"
|
||||
usage := "create a new index"
|
||||
|
||||
if modify {
|
||||
name = "modify"
|
||||
usage = "modify anindex"
|
||||
}
|
||||
|
||||
return &cli.Command{
|
||||
Name: "create",
|
||||
Name: name,
|
||||
Aliases: []string{"+"},
|
||||
Usage: "create a new index",
|
||||
UsageText: `create <name> <fieldmapping:type>...
|
||||
Usage: usage,
|
||||
UsageText: name + ` <name> <fieldmapping:type>...
|
||||
Valid field mapping types: integer, text, date, keyword`,
|
||||
|
||||
Flags: []cli.Flag{
|
||||
@@ -171,6 +179,12 @@ Valid field mapping types: integer, text, date, keyword`,
|
||||
Aliases: []string{"r"},
|
||||
Value: 1,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "ilm-policy",
|
||||
Usage: "ilm policy to apply",
|
||||
Destination: &conf.Policy,
|
||||
Aliases: []string{"p"},
|
||||
},
|
||||
},
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
@@ -229,37 +243,6 @@ func IndexClose(conf *cfg.Config) *cli.Command {
|
||||
}
|
||||
}
|
||||
|
||||
func IndexModify(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "modify",
|
||||
Usage: "modify an index",
|
||||
UsageText: "modify <index[,index,...]|_all>",
|
||||
|
||||
ShellComplete: func(ctx context.Context, cmd *cli.Command) {
|
||||
complete(cmd, Cindex)
|
||||
},
|
||||
|
||||
Flags: []cli.Flag{
|
||||
&cli.IntFlag{
|
||||
Name: "replicas",
|
||||
Usage: "number of replicas",
|
||||
Destination: &conf.Replicas,
|
||||
Aliases: []string{"r"},
|
||||
Value: 1,
|
||||
},
|
||||
},
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
index := cmd.Args().Get(0)
|
||||
if index == "" {
|
||||
return errors.New("no index specified")
|
||||
}
|
||||
|
||||
return es.IndexModify(conf, index)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func IndexFields(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "fields",
|
||||
|
||||
Reference in New Issue
Block a user