How do we know replication status in elasticsearch? How do we know replication status in elasticsearch? elasticsearch elasticsearch

How do we know replication status in elasticsearch?


In addition to John Petrone's answer, I would prefer using the below command

http://localhost:9200/_cat/shards/twitterindex?v

This will enlist the status of all the shards primary or replica specific to the index. Shards which are in "INITIALIZING" state are in process whereas which are marked as "STARTED" means they are successfully replicated.


The quickest way to check to see that all shards have been successfully replicated is the cluster health api: http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/cluster-health.html

A status of "green" will tell you that all shards have allocated:

The cluster health status is: green, yellow or red. On the shard level, a red status indicates that the specific shard is not allocated in the cluster, yellow means that the primary shard is allocated but replicas are not, and green means that all shards are allocated. The index level status is controlled by the worst shard status. The cluster status is controlled by the worst index status.

It has a built in mechanism to wait for status to change and then notify you. As an example:

curl -XGET 'http://localhost:9200/_cluster/health?wait_for_status=green&timeout=60s'

will check to see if status is green. If yes it will return immediately, if not it will wait for up to 60 seconds while checking and then return status. You can call this api in a loop, or just set the timeout to a high number, and it will return when the status has changed to green, letting you know that all shards have been allocated.