Elasticsearch cluster status becomes yellow or red due to multiple reasons. Sometimes it could so happen that, even after a considerable amount of time, the Elasticsearch domain doesn't fix the issue with the cluster status. This happens particularly when the maximum number of retries for shard allocation exceed the limit (5 retries).
In this scenario, as per the documentation, a manual shard allocation can be triggered by disabling and re-enabling the replica shard on the index.
You can figure out which index's shard allocation had failed by running the following
curl -XGET 'MyES_Endpoint/_cat/shards?h=index,shard,prirep,state,unassigned.reason' | grep UNASSIGNED
Once you figure out which index's shard is unassigned, you can disable the replica shards for the index with the below command
curl -XPUT 'MyES_Endpoint/<index>/_settings' -H 'Content-Type: application/json' -d'
{
"index" : {
"number_of_replicas" : 0
}
}'
You can re-enable the replica shards by setting it back to the appropriate number.
Caveat
Handling shard allocation manually on clusters that run heavy workloads is not suggested because, when we remove the replica shards for an index, we are left with just the primary shard and all the incoming load is then to be handled by just that shard alone. Any node failure then will result in the status of the cluster going to Red.
Take a look at the documentation to understand further on the different reasons for this and how they could be dealt with.