简体   繁体   中英

Elasticsearch curl query: List of indices having 0 documents

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}'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM