I am trying to get a list of all of my Elasticsearch indices that have 0 documents.
My approach was to query _cat/indices
curl -GET 'http://localhost:9200/_cat/indices' -d '{
"query": { "match": { "docs.count": "0" } }
}'
But it does not seem to work as I see indices with more than 0 documents being listed.
Cat indices
documentation can be found here: https://www.elastic.co/guide/en/elasticsearch/reference/1.6/cat-indices.html
Any suggestions?
Thank you.
I feel awk and cat API would be a better choice. You can use the below command to get what you are looking for -
curl -GET 'http://localhost:9200/_cat/indices' 2>/dev/null | awk ' ($6 == 0) {print $3}'