From ba0b983f7f761a9d4641bb8a6b95f6562c2203fd Mon Sep 17 00:00:00 2001 From: cmpoon Date: Mon, 16 May 2022 08:31:55 +0100 Subject: [PATCH] Add waitForNoInitializingShards to cluster_health.go --- cluster_health.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cluster_health.go b/cluster_health.go index eba5e2212..41b81e882 100644 --- a/cluster_health.go +++ b/cluster_health.go @@ -34,6 +34,7 @@ type ClusterHealthService struct { timeout string waitForActiveShards *int waitForNodes string + waitForNoInitializingShards *bool waitForNoRelocatingShards *bool waitForStatus string } @@ -130,6 +131,12 @@ func (s *ClusterHealthService) WaitForNodes(waitForNodes string) *ClusterHealthS return s } +// WaitForNoRelocatingShards can be used to wait until all shard relocations are finished. +func (s *ClusterHealthService) WaitForNoInitializingShards(waitForNoInitializingShards bool) *ClusterHealthService { + s.waitForNoInitializingShards = &waitForNoInitializingShards + return s +} + // WaitForNoRelocatingShards can be used to wait until all shard relocations are finished. func (s *ClusterHealthService) WaitForNoRelocatingShards(waitForNoRelocatingShards bool) *ClusterHealthService { s.waitForNoRelocatingShards = &waitForNoRelocatingShards @@ -201,6 +208,9 @@ func (s *ClusterHealthService) buildURL() (string, url.Values, error) { if s.waitForNodes != "" { params.Set("wait_for_nodes", s.waitForNodes) } + if s.waitForNoInitializingShards != nil { + params.Set("wait_for_no_initializing_shards", fmt.Sprintf("%v", *s.waitForNoInitializingShards)) + } if s.waitForNoRelocatingShards != nil { params.Set("wait_for_no_relocating_shards", fmt.Sprintf("%v", *s.waitForNoRelocatingShards)) }