DEV Community

Abdallah Deeb
Abdallah Deeb

Posted on • Originally published at deeb.me on

Quick ElasticSearch Index Cleanup

There are many solutions using curator and other libraries. I’ll try to add links here later (if I remember)

However, most of the time, all that’s needed is a quick curl call

curl -X DELETE "https://${ES-Endpoint}/${INDEX_NAME}"
Enter fullscreen mode Exit fullscreen mode

Get the ES endpoint from the domain overview

List the index names using

curl "https://${ES-Endpoint}/_cat/indices"
Enter fullscreen mode Exit fullscreen mode

So for a quick cleanup session for everything that matches a grep

curl "https://${ES-Endpoint}/_cat/indices" | grep 'something' | awk '{print$3}' \
while read INDEX_NAME; do
  echo "Deleting ${INDEX_NAME}"
  curl -X DELETE "https://${ES-Endpoint}/${INDEX_NAME}"
done
Enter fullscreen mode Exit fullscreen mode

Top comments (0)