From c4580cb2e3aab786e41a3ad1ef32f3fce168b8d5 Mon Sep 17 00:00:00 2001 From: medcl Date: Thu, 5 Sep 2019 12:25:47 +0800 Subject: [PATCH] enable to skip cluster status check, use index instead of create for bulk operations --- bulk.go | 2 +- main.go | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bulk.go b/bulk.go index 76a322c..544cf9e 100644 --- a/bulk.go +++ b/bulk.go @@ -121,7 +121,7 @@ func (c *Migrator) NewBulkWorker(docCount *int, pb *pb.ProgressBar, wg *sync.Wai // encode the doc and and the _source field for a bulk request post := map[string]Document{ - "create": doc, + "index": doc, } if err = docEnc.Encode(post); err != nil { log.Error(err) diff --git a/main.go b/main.go index 64fe844..536b7b2 100644 --- a/main.go +++ b/main.go @@ -11,7 +11,7 @@ import ( "bufio" log "github.com/cihub/seelog" goflags "github.com/jessevdk/go-flags" - pb "gopkg.in/cheggaaa/pb.v1" + "gopkg.in/cheggaaa/pb.v1" "os" "io" "io/ioutil" @@ -485,8 +485,12 @@ func (c *Migrator) ClusterVersion(host string, auth *Auth,proxy string) (*Cluste } func (c *Migrator) ClusterReady(api ESAPI) (*ClusterHealth, bool) { - health := api.ClusterHealth() + + if !c.Config.WaitForGreen{ + return health,true + } + if health.Status == "red" { return health, false }