How To Delete Unassigned Shards or Indexes | Elasticsearch
Bash Script To Delete Unassigned Shards Indices
Create a file delete_unassigned_shards.sh
Make this file executable by running the following command:
sudo chmod +x delete_unassigned_shards.sh
#!/bin/bash IFS=$'\n' for line in $(curl -s 'localhost:9200/_cat/shards' | fgrep UNASSIGNED); do INDEX=$(echo $line | (awk '{print $1}')) SHARD=$(echo $line | (awk '{print $2}')) #echo $INDEX curl -XDELETE localhost:9200/$INDEX done
Execute the script with the following command
sudo ./delete_unassigned_shards.sh