首页 > 解决方案 > 有什么方法可以知道索引字段在 Elasticsearch 中占用多少磁盘空间

问题描述

我正在索引一个定义了映射字段的文档,磁盘大小最终太大,我想检查每个索引字段占用多少磁盘空间?

有什么办法吗?此处的索引统计信息似乎仅显示所有字段的整体(https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-stats.html

{
    '_source': {
        'enabled': False,
    },
    'properties': {
        'ip': {
            'type': 'ip',
        },
        'timestamp': {
            'type': 'date',
        },
        'data': {
            'type': 'text',
        },
        ...
    }
}

更新索引统计信息

curl -X GET "localhost:9200/_cat/allocation?v"
shards disk.indices disk.used disk.avail disk.total disk.percent host       ip         node
     3        6.3mb    28.3gb       30gb     58.4gb           48 172.17.0.3 172.17.0.3 57dac878cf46
     2                                                                                 UNASSIGNED

curl -X GET "localhost:9200/_cat/indices?v"
health status index                           uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open   my-index                        vjdK1nkRRimxtdUvgKWNHA   1   1      10000            0      6.3mb          6.3mb
yellow open   .kibana                         kDM_5IpMQfacYN6F2_mxrQ   1   1          1            0        5kb            5kb

标签: elasticsearch

解决方案


给定字段的值可能不会只在一个地方存储一次,Lucene 中有许多不同的底层数据结构。

您可以在回答相同问题的此线程中找到更多信息:https ://lucene.472066.n3.nabble.com/Get-size-occupied-by-each-field-in-lucene-index-td4347856.html


推荐阅读