mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 09:44:17 +02:00
add sort support to search, add index fields command, fix error messages (#25)
This commit is contained in:
20
cmd/index.go
20
cmd/index.go
@@ -42,6 +42,7 @@ func Index(conf *cfg.Config) *cli.Command {
|
||||
IndexAllocation(conf),
|
||||
IndexModify(conf),
|
||||
IndexAlias(conf),
|
||||
IndexFields(conf),
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -157,6 +158,8 @@ func IndexCreate(conf *cfg.Config) *cli.Command {
|
||||
Name: "create",
|
||||
Aliases: []string{"+"},
|
||||
Usage: "create a new index",
|
||||
UsageText: `create <name> <fieldmapping:type>...
|
||||
Valid field mapping types: integer, text, date, keyword`,
|
||||
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
@@ -250,3 +253,20 @@ func IndexModify(conf *cfg.Config) *cli.Command {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func IndexFields(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "fields",
|
||||
Usage: "show info about field capabilities",
|
||||
UsageText: "index fields <index>",
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
index := cmd.Args().Get(0)
|
||||
if index == "" {
|
||||
return errors.New("no index specified")
|
||||
}
|
||||
|
||||
return es.IndexFields(conf, index)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,19 @@ func Search(conf *cfg.Config) *cli.Command {
|
||||
Destination: &conf.TimestampFormat,
|
||||
Value: "strict_date_hour_minute",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "sort-by",
|
||||
Usage: "sort by a field",
|
||||
Destination: &conf.SortBy,
|
||||
Value: "@timestamp",
|
||||
Aliases: []string{"k"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "ascending",
|
||||
Usage: "sort in ascending order (default: descending)",
|
||||
Destination: &conf.Ascending,
|
||||
Aliases: []string{"a"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "help-jsonpath",
|
||||
Usage: "show jsonPath help",
|
||||
|
||||
Reference in New Issue
Block a user