private void CreateIndex(IRequestConfiguration requestConfig) { var indexName = requestConfig.GenerateIndexIdentifier(this.ctx); this.client.Raw.IndicesCreate(indexName, null); const int CircuitBreaker = 2; int count = 0; do { if (count > 0) // on retries - wait a bit System.Threading.Thread.Sleep(25); // ES creates new indices in an async fashion, so you have to check manually when the index is ready // across the whole cluster to receive writes. Waiting for one healthy shard is good enough. this.client.ClusterHealth(p => p.Index(indexName).WaitForActiveShards(1).Timeout("5s")); count++; } while (count <= CircuitBreaker); }
private void DeleteIndex(IRequestConfiguration requestConfig) { this.client.Raw.IndicesDelete(requestConfig.GenerateIndexIdentifier(this.ctx)); }