Hi there @Collins_Mbathi, welcome to the Elastic community and thanks for posting!
Could you please provide a little more information - perhaps the mappings in your index and more information on the data you've indexed, more information on the query you're running, and what you're getting back?
I put the snippet you provided into a simple test indexing using Elasticsearch 8.14.1:
PUT /test
{
"mappings": {
"properties": {
"Date": {
"type": "date"
},
"Cost": {
"type": "float"
}
}
}
}
POST test/_doc/
{
"Date": "2024-06-01",
"Cost": 12.34
}
POST test/_doc
{
"Date": "2024-07-02",
"Cost": 56.78
}
GET test/_search
{
"size": 0,
"aggs": {
"dateAggs": {
"terms": {
"field": "Date",
"format": "MMM YYYY",
"order": {
"_key": "asc"
}
},
"aggs": {
"costSum": {
"sum": {
"field": "Cost"
}
}
}
}
}
}
Using this script, I see that costSum
is returning floating point values.
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 2,
"relation": "eq"
},
"max_score": null,
"hits": []
},
"aggregations": {
"dateAggs": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": 1717200000000,
"key_as_string": "Jun 2024",
"doc_count": 1,
"costSum": {
"value": 12.34000015258789
}
},
{
"key": 1719878400000,
"key_as_string": "Jul 2024",
"doc_count": 1,
"costSum": {
"value": 56.779998779296875
}
}
]
}
}
}
More information about what you're seeing vs. what you expect, and how to reproduce it, will be helpful for us to help you.
Thanks!