ElasticSearch[5.5] Aggs Range filter on string datatype

RAM field in Mobile specifications has lots of data which i need to apply some kind of Range filter on strings . I have formatted bucket into key value pair RAM and Doc count
"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
}

How to convert the above one to something like below

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

One possible solution would be index the value of RAM as numeric datatype and apply range filter on the field. But how to differentiate 1 Mb and 1 GB .

If you convert all that in the lowest unit you can have, let say kb like 1mb = 1024 and 1gb = 1024*1024 for example, then it would become obvious.

My 2 cents.

That said it could be nice that we support (in core or as a plugin) a « size » type with size_histogram agg and size_range agg.
I did not check if that has been already asked though.

That could be a good solution for RAM field and what about incase of field like battery capacity.

It would be good if it has inbuilt support like size aggregate as you mentioned.

That’s the same for whatever unit. If you have something in W, kW, mW, just Store it as Watts and you re done

Thanks this work perfectly. I have stored data without and with conversation.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.