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

被折叠的 条评论
为什么被折叠?



