curl 'localhost:9200/_cat/indices?v'
health | status | index | pri | rep | docs.count | docs.deleted | store.size | pri.store.size |
---|---|---|---|---|---|---|---|---|
green | open | .kibana | 1 | 0 | 1 | 0 | 3.1kb | 3.1kb |
green | open | info | 5 | 0 | 19485 | 100 | 87.2mb | 87.2mb |
使用这种方式,查询文档数量,是不准确的!
原因如下:(来自官方网站)
We can tell quickly how many shards make up an index, the number of docs, deleted docs, primary store size, and total store size (all shards including replicas). All these exposed metrics come directly from Lucene APIs.
Notes:
As the number of documents and deleted documents shown in this are at the lucene level, it includes all the hidden documents (e.g. from nested documents) as well.
To get actual count of documents at the Elasticsearch level, the recommended way is to use either the cat count or the Count API
应该使用这种命令来查询数量
curl -X GET "localhost:9200/_cat/count?v"
epoch | timestamp | count |
---|---|---|
1532398649 | 02:17:29 | 8583295 |
查询某index的文档数量
curl -X GET "localhost:9200/_cat/count/index_name?v"
1532398739 | 02:18:59 | 6645550 |
The document count indicates the number of live documents and does not include deleted documents which have not yet been cleaned up by the merge process.
来自于官网