Sum aggs returning scientific value

Sum aggs gives scientific value as result as shown below.
Expected value 11111108.6789
Actual value : 1.1111108625E7

Index Mapping

{
  "sample-tx" : {
    "mappings" : {
      "properties" : {
        "Id" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "price" : {
          "type" : "float"
        },
        "promotion" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "publishedDate" : {
          "type" : "date"
        },
        "source" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "status" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "subType" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        },
        "transactionDate" : {
          "type" : "date"
        },
        "type" : {
          "type" : "text",
          "fields" : {
            "keyword" : {
              "type" : "keyword",
              "ignore_above" : 256
            }
          }
        }
      }
    }
  }
}

Added below data into index

POST /_bulk
{ "index" : { "_index" : "sample-tx", "_type" : "_doc", "_id" : "1" } }
{"Id" : "M-90010402224464143","type" : "E","source" : "mobile", "status" : "Processed","transactionDate" : "2021-03-18T21:12:00Z","price" : "1234567.6789", "promotion" : "Test1"}
{ "index" : { "_index" : "sample-tx", "_type" : "_doc", "_id" : "2" } }
{"Id" : "M-90020402224464143","type" : "E","source" : "mobile", "status" : "Processed","transactionDate" : "2021-03-18T21:12:00Z","price" : "1234567.6789", "promotion" : "Test1"}
{ "index" : { "_index" : "sample-tx", "_type" : "_doc", "_id" : "3" } }
{"Id" : "M-90030402224464143","type" : "E","source" : "mobile", "status" : "Processed","transactionDate" : "2021-03-18T21:12:00Z","price" : "1234567.6789", "promotion" : "Test1"}
{ "index" : { "_index" : "sample-tx", "_type" : "_doc", "_id" : "4" } }
{"Id" : "M-90040402224464143","type" : "E","source" : "mobile", "status" : "Processed","transactionDate" : "2021-03-18T21:12:00Z","price" : "1234567.6789", "promotion" : "Test1"}
{ "index" : { "_index" : "sample-tx", "_type" : "_doc", "_id" : "5" } }
{"Id" : "M-90050402224464143","type" : "E","source" : "mobile", "status" : "Processed","transactionDate" : "2021-03-18T21:12:00Z","price" : "1234567.6789", "promotion" : "Test1"}
{ "index" : { "_index" : "sample-tx", "_type" : "_doc", "_id" : "6" } }
{"Id" : "M-90060402224464143","type" : "E","source" : "mobile", "status" : "Processed","transactionDate" : "2021-03-18T21:12:00Z","price" : "1234567.6789", "promotion" : "Test1"}
{ "index" : { "_index" : "sample-tx", "_type" : "_doc", "_id" : "7" } }
{"Id" : "M-90070402224464143","type" : "E","source" : "mobile", "status" : "Processed","transactionDate" : "2021-03-18T21:12:00Z","price" : "1234567.6789", "promotion" : "Test1"}
{ "index" : { "_index" : "sample-tx", "_type" : "_doc", "_id" : "8" } }
{"Id" : "M-90080402224464143","type" : "E","source" : "mobile", "status" : "Processed","transactionDate" : "2021-03-18T21:12:00Z","price" : "1234567.6789", "promotion" : "Test1"}
{ "index" : { "_index" : "sample-tx", "_type" : "_doc", "_id" : "9" } }
{"Id" : "M-90090402224464143","type" : "E","source" : "mobile", "status" : "Processed","transactionDate" : "2021-03-18T21:12:00Z","price" : "1234567.6789", "promotion" : "Test1"}

When created alert using ES query:

GET /sample-tx/_search
{
  "size": 0, 
  "aggs": {
    "total": {
      "sum": {
        "field": "price"
        
      }
    }
  }
}

It gives results

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 9,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [ ]
  },
  "aggregations" : {
    "total" : {
      "value" : 1.1111108625E7
    }
  }
}

But , when I use same index to create visualization and use sum metric value is displayed correctly.

Wondering how? Is this a way to use sum metric in ES query to get correct value as shown in visualization?

That is a correct value; it's a valid JSON literal.

○ → ipython3
In [1]: import json

In [2]: doc = '''
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 9,
      "relation" : "eq"
    },
    "max_score" : null,
    "hits" : [ ]
  },
  "aggregations" : {
    "total" : {
      "value" : 1.1111108625E7
    }
  }
}
'''

In [3]: json.loads(doc)['aggregations']['total']['value']
Out[3]: 11111108.625

Hi Michael,

I am using the above ES query as part of monitor query. It does not allow json import.

Refer to below screenshots where in visualization and monitor sample message value is shown correctly but in slack message goes scientific value.

This looks like a problem with the Alerting tool.

Any idea or thoughts on how to overcome this limitation from alerting tool?

I'm not familiar with the tool you're using; you'll likely have to get in touch with the developers.

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