Elasticsearch等待索引状态

Mik*_*mmi 5 elasticsearch

Cluster health API具有参数wait_for_status(根据文档)等待指定的群集状态.但是,我想等待特定索引达到某种状态.

如果我使用群集运行状况请求level=indices并且index=myindex等待是否仍在群集级别上运行?我想轮询状态并在达到状态后继续会产生相同的效果但是有更好的方法吗?

And*_*fan 7

也可以将healthapi用于特定索引:

GET /_cluster/health/index_name?wait_for_status=green&timeout=10s
Run Code Online (Sandbox Code Playgroud)

  • 这很容易测试:-).在一个节点集群中创建两个索引.两个索引都有`number_of_replicas:1`.这意味着它们将是"黄色",群集将是"黄色".然后运行`/ _cluster/health/index_name?wait_for_status = green&timeout = 100s`.在一个单独的窗口中,运行`PUT/index_name/_settings {"index":{"number_of_replicas":0}}`.这会将副本的数量从1更改为0,这将立即使该特定索引变为"绿色" .然后你会看到第一个命令返回.即使群集仍然是来自具有1个副本的其他索引的"黄色" (2认同)