Metrics aggregation gives unreasonable result on long numeric datatype

ES version: 7.3.2

My daily index is using dynamic template to map incoming data automatically. Somehow the field "value" which might map to numeric float datatype sometimes. Then in other time, it was mapped to long datatype. I guess this is due to the value in this field has a large span, and the very first document in the index determined the datatype

I have a sum aggregation on this "value" field, and it only gave me correct result while the field was in float type. When in the days mapped to long type, most of the buckets returned had a 0 result. No any error or warning log found in my ES nodes.
The request:

indent preformatted text by 4 spaces
        "aggs": {
            "date": {
                "date_histogram": {
                    "interval": "5m",
                    "field": "@timestamp",
                    "min_doc_count": 1,
                    "extended_bounds": {
                        "min": "1582170942982",
                        "max": "1582192542982"
                    },
                    "format": "epoch_millis"
                },
                "aggs": {
                    "sum": {
                        "sum": {
                            "field": "value"
                        }
                    }
                }
            }
        }

The values in the "value" field of the above aggregation are in the form like 0.123. I can query the documents in Kibana and where it shows the correct value, no matter it mapped to long or float. Only the aggregation result in long type is problematic.

ES version 7.6.1 also meets this problem

can you provide a minimal but reproducible example including index creation, document creation and sample query? This would help tremendously!

--Alex

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