mirror of
https://codeberg.org/scip/esctl.git
synced 2026-08-24 04:54:18 +02:00
add index copy (aka reindex), fix typoe indicies to indices (#100)
This commit is contained in:
92
cmd/index.go
92
cmd/index.go
@@ -30,7 +30,7 @@ func Index(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "index",
|
||||
Aliases: []string{"i"},
|
||||
Usage: "manage indicies",
|
||||
Usage: "manage indices",
|
||||
|
||||
Commands: []*cli.Command{
|
||||
IndexList(conf),
|
||||
@@ -42,6 +42,7 @@ func Index(conf *cfg.Config) *cli.Command {
|
||||
IndexFields(conf),
|
||||
IndexIlm(conf),
|
||||
IndexDu(conf),
|
||||
IndexCopy(conf),
|
||||
|
||||
// sub commands
|
||||
IndexAlias(conf),
|
||||
@@ -54,7 +55,7 @@ func IndexList(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "list",
|
||||
Aliases: []string{"ls"},
|
||||
Usage: "list indicies",
|
||||
Usage: "list indices",
|
||||
|
||||
Flags: []cli.Flag{
|
||||
&cli.IntFlag{
|
||||
@@ -65,25 +66,25 @@ func IndexList(conf *cfg.Config) *cli.Command {
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "partials",
|
||||
Usage: "include partial indicies",
|
||||
Usage: "include partial indices",
|
||||
Destination: &conf.Partials,
|
||||
Aliases: []string{"p"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "hidden",
|
||||
Usage: "include hidden indicies",
|
||||
Usage: "include hidden indices",
|
||||
Destination: &conf.Hidden,
|
||||
Aliases: []string{"H"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "failed",
|
||||
Usage: "include only red failed indicies",
|
||||
Usage: "include only red failed indices",
|
||||
Destination: &conf.Failed,
|
||||
Aliases: []string{"f"},
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "filter",
|
||||
Usage: "show only indicies matching the filter",
|
||||
Usage: "show only indices matching the filter",
|
||||
Destination: &conf.Filter,
|
||||
Aliases: []string{"F"},
|
||||
},
|
||||
@@ -299,3 +300,82 @@ func IndexDu(conf *cfg.Config) *cli.Command {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func IndexCopy(conf *cfg.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "copy",
|
||||
Aliases: []string{"alias", "cp"},
|
||||
Usage: "copy (reindex) documents from one index to another",
|
||||
UsageText: "index copy [options] -s <source-index> -t <dest-index>",
|
||||
|
||||
Flags: []cli.Flag{
|
||||
// FIXME: not implemented by typed API
|
||||
// &cli.BoolFlag{
|
||||
// Name: "missing", // op_type
|
||||
// Usage: "copy only missing docs",
|
||||
// Destination: &conf.Missing,
|
||||
// Aliases: []string{"m"},
|
||||
// },
|
||||
// &cli.BoolFlag{
|
||||
// Name: "sync", // version_type to external
|
||||
// Usage: "create missing docs and update outdated docs",
|
||||
// Destination: &conf.Sync,
|
||||
// Aliases: []string{"S"},
|
||||
// },
|
||||
&cli.BoolFlag{
|
||||
Name: "force", // conflicts to proceed
|
||||
Usage: "continue reindexing even when conflicts happen",
|
||||
Destination: &conf.Force,
|
||||
Aliases: []string{"f"},
|
||||
},
|
||||
&cli.Float64Flag{
|
||||
Name: "requests-per-second",
|
||||
Usage: "the maximum number of documents to index per second (-1 turns off throttling)",
|
||||
Destination: &conf.RequestsPerSecond,
|
||||
Aliases: []string{"R"},
|
||||
},
|
||||
&cli.Int64Flag{
|
||||
Name: "max-docs",
|
||||
Usage: "the maximum number of documents to reindex",
|
||||
Destination: &conf.MaxDocs,
|
||||
Aliases: []string{"m"},
|
||||
},
|
||||
&cli.DurationFlag{
|
||||
Name: "timeout",
|
||||
Usage: "timeout for write operations (e.g. 300m or 120s)",
|
||||
Destination: &conf.Timeout,
|
||||
Aliases: []string{"T"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "refresh",
|
||||
Usage: "refresh affected shards to make this operation visible to search",
|
||||
Destination: &conf.Refresh,
|
||||
Aliases: []string{"r"},
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "wait",
|
||||
Usage: "wait for active shards",
|
||||
Destination: &conf.Wait,
|
||||
Aliases: []string{"w"},
|
||||
},
|
||||
&cli.StringSliceFlag{
|
||||
Name: "source",
|
||||
Usage: "source index (multiple supported)",
|
||||
Destination: &conf.SourceIndices,
|
||||
Aliases: []string{"s"},
|
||||
Required: true,
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "target",
|
||||
Usage: "target index",
|
||||
Destination: &conf.Index,
|
||||
Aliases: []string{"t"},
|
||||
Required: true,
|
||||
},
|
||||
},
|
||||
|
||||
Action: func(ctx context.Context, cmd *cli.Command) error {
|
||||
return es.IndexCopy(conf)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user