ElasticSearch [5.5] Aggs Range过滤字符串数据类型

问题描述 投票:0回答:1

Mobile规范中的RAM字段有很多数据需要在字符串上应用某种Range过滤器。我已将格式化为键值对RAM和Doc计数

 "RAM": {
            "1": 7,
            "32": 1,
            "32 MB": 490,
            "1 GB": 426,
            "2 GB": 361,
            "3 GB": 269,
            "4 GB": 143,
            "512 MB": 136,
            "256 MB": 87,
            "10 MB": 61,
            "64 MB": 47,
            "1 MB": 45,
            "128 MB": 41,
            "56 MB": 27,
            "1.5 GB": 23,
            "16 MB": 12,
            "35 MB": 12,
            "4 MB": 11,
            "0.032 MB": 10,
            "100 MB": 7,
            "3 MB": 7,
            "2 MB": 6,
            "768 MB": 6,
            "40 MB": 4,
            "30 MB": 3,
            "6 GB": 3,
            "20 MB": 2,
            "46 MB": 2,
            "500 MB": 2,
            "60 MB": 2,
            "120 MB": 1,
            "131 MB": 1,
            "138 MB": 1,
            "153 MB": 1,
            "200 MB": 1,
            "24 MB": 1,
            "250 MB": 1,
            "260 MB": 1,
            "50 MB": 1,
            "55 MB": 1,
            "65 MB": 1,
            "8 GB": 1
        }

如何将上面的转换为如下所示

 128 MB and Below
     1 GB
     2 GB
     3 GB
     4 GB
     6 GB and Above

一种可能的解决方案是将RAM的值索引为数值数据类型,并在字段上应用范围过滤器。但如何区分1 Mb和1 GB。

elasticsearch search aggregate searchfiltercollection
1个回答
0
投票

我通过转换最低单位中的所有内容并删除了转换单元来解决它。

请看这里

https://discuss.elastic.co/t/elasticsearch-5-5-aggs-range-filter-on-string-datatype/106400/3

© www.soinside.com 2019 - 2024. All rights reserved.