简体   繁体   English

Elasticsearch curl查询:具有0个文档的索引列表

[英]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. 我正在尝试获取具有0个文档的所有Elasticsearch索引的列表。

My approach was to query _cat/indices 我的方法是查询_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. 但这似乎不起作用,因为我看到列出的索引超过0个文档。

Cat indices documentation can be found here: https://www.elastic.co/guide/en/elasticsearch/reference/1.6/cat-indices.html 可以在以下位置找到Cat indices文档: 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. 我觉得awk和cat API将是一个更好的选择。 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}'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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