Elasticsearch 6.3版本 查询某索引下文档数量等信息

本文介绍了如何在Elasticsearch 6.3版本中查询索引的详细信息,包括文档数量、存储大小等。通过`_cat/indices`命令可以获取主分片数、副分片数等,但`docs.count`可能因nested字段不准确,要获取准确文档数需使用`_count`命令。此外,还展示了如何查看特定索引信息和内存占用情况。

想要查询某集群下已存在的索引、文档数量,占用存储空间大小等信息,可使用如下命令:

GET _cat/indices?v

响应结果如图所示:

返回的结果从左到右依次包括:pri(主分片数)、rep(副分片数)、docs.count(索引现有文档数)、docs.deleted(索引标记为删除的文档数)、store.size(索引总大小)、pri.store.size(索引主分片大小)。

注意:通过cat/indices命令,获取到的docs.count(索引现有文档数),是不准确的,如果索引mapping中有nested类型的字段,则nested字段是单独作为一个文档进行索引的,此时通过此命令获取到的docs.count则不准确。获取索引当前文档数,通过count命令获取才是准确的,eg:GET indexName/_count

也可以单独查询某一个索引下信息,如:想要查询索引test的相关信息:

GET _cat/indices/test?v

则此时响应结果只包含test的索引信息。

 

帮助命令:GET _cat/indices?help

health                           | h                              | current health status
status                           | s                              | open/close status
index                            | i,idx                          | index name
uuid                             | id,uuid                        | index uuid
pri                              | p,shards.primary,shardsPrimary | number of primary shards
rep                              | r,shards.replica,shardsReplica | number of replica shards
docs.count                       | dc,docsCount                   | available docs
docs.deleted                     | dd,docsDeleted                 | deleted docs
creation.date                    | cd                             | index creation date (millisecond value)
creation.date.string             | cds                            | index creation date (as string)
store.size                       | ss,storeSize                   | store size of primaries & replicas
pri.store.size                   |                                | store size of primaries
memory.total                     | tm,memoryTotal                 | total used memory
pri.memory.total                 |                                | total user memory

查看各个索引占用的es内存大小:GET _cat/indices?v&h=i,pri.memory.total,memory.total&s=memory.total:desc
命令简写: GET _cat/indices?v&h=i,pri.memory.total,tm&s=tm:desc

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值