Skip to content

Commit

Permalink
Adding refresh interval option
Browse files Browse the repository at this point in the history
  • Loading branch information
gsocgsoc committed May 18, 2019
1 parent 2e960d2 commit 75df311
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions cmd/esbulk/esbulk.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,21 @@ import (
const Version = "0.5.1"

var (
version = flag.Bool("v", false, "prints current program version")
cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
memprofile = flag.String("memprofile", "", "write heap profile to file")
indexName = flag.String("index", "", "index name")
docType = flag.String("type", "default", "elasticsearch doc type")
batchSize = flag.Int("size", 1000, "bulk batch size")
numWorkers = flag.Int("w", runtime.NumCPU(), "number of workers to use")
verbose = flag.Bool("verbose", false, "output basic progress")
gzipped = flag.Bool("z", false, "unzip gz'd file on the fly")
mapping = flag.String("mapping", "", "mapping string or filename to apply before indexing")
purge = flag.Bool("purge", false, "purge any existing index before indexing")
idfield = flag.String("id", "", "name of field to use as id field, by default ids are autogenerated")
user = flag.String("u", "", "http basic auth username:password, like curl -u")
zeroReplica = flag.Bool("0", false, "set the number of replicas to 0 during indexing")
version = flag.Bool("v", false, "prints current program version")
cpuprofile = flag.String("cpuprofile", "", "write cpu profile to file")
memprofile = flag.String("memprofile", "", "write heap profile to file")
indexName = flag.String("index", "", "index name")
docType = flag.String("type", "default", "elasticsearch doc type")
batchSize = flag.Int("size", 1000, "bulk batch size")
numWorkers = flag.Int("w", runtime.NumCPU(), "number of workers to use")
verbose = flag.Bool("verbose", false, "output basic progress")
gzipped = flag.Bool("z", false, "unzip gz'd file on the fly")
mapping = flag.String("mapping", "", "mapping string or filename to apply before indexing")
purge = flag.Bool("purge", false, "purge any existing index before indexing")
idfield = flag.String("id", "", "name of field to use as id field, by default ids are autogenerated")
user = flag.String("u", "", "http basic auth username:password, like curl -u")
zeroReplica = flag.Bool("0", false, "set the number of replicas to 0 during indexing")
refreshInterval = flag.String("r", "1s", "Refresh interval after import")
)

// indexSettingsRequest runs updates an index setting, given a body and
Expand Down Expand Up @@ -194,7 +195,7 @@ func main() {
// Shutdown procedure. TODO(miku): Handle signals, too.
defer func() {
// Realtime search.
if _, err := indexSettingsRequest(`{"index": {"refresh_interval": "1s"}}`, options); err != nil {
if _, err := indexSettingsRequest(fmt.Sprintf(`{"index": {"refresh_interval": %s}}`, refreshInterval), options); err != nil {
log.Fatal(err)
}
// Reset number of replicas.
Expand Down

0 comments on commit 75df311

Please # to comment.