Deleted index is created again once i run the java program to create a new index

I am using es with java API , inserting the json content in to es with java api In which i used Bulk API to create the index . Very frequently my cluster status is turning red from yellow. whenever i run the Java Program to create the new bulk index all the deleted indexes are also being created and the cluster status turning to red immediately. Could anyone please mention what could be the problem ? Thanks.

In ES , deleted index will be created again if the cluster status is in red. The Issue is "auto importing dangled indices ". we can reset this settings before 2.x ES.But after 2.X there is no option to eliminate the auto import of dangled indices. The solution for this is, most of the cases you have to delete the cluster or create a new cluster with new index name. And also if there is any delayed allocation for unassigned shards or nodes . try using the following settings

PUT /_all/_settings
{
"settings": {
"index.unassigned.node_left.delayed_timeout": "0"
}
}

PUT /_cluster/settings
{
"transient" : {
"cluster.routing.allocation.enable" : "all"
}
}

This worked for me after deleting the current cluster and creating a new cluster with the above settings.