# Long value displayed incorrectly in watcher email

**URL:** <https://discuss.elastic.co/t/long-value-displayed-incorrectly-in-watcher-email/292502>\
**Category:** Elasticsearch\
**Tags:** runtime-fields\
**Created:** [December 20, 2021, 7:38pm UTC](https://discuss.elastic.co/t/long-value-displayed-incorrectly-in-watcher-email/292502 "2021-12-20T19:38:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![keyu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/keyu/32/98794_2.png) [@keyu](https://discuss.elastic.co/u/keyu)\
**Post date:** [December 20, 2021, 7:38pm UTC](https://discuss.elastic.co/t/long-value-displayed-incorrectly-in-watcher-email/292502/1 "2021-12-20T19:38:58Z")

</div>

Hi,

I have created runtime field using a field price(type is float). The runtime field is a long type field.

```auto
"runtime_mappings": {
            "longPrice": {
              "type": "long",
              "script": """
			        long value = (long)doc['price'].value;
				    emit(value);
			    """
            }
          }

```

When I am trying to aggregate on the runtime field, the result still be treated as float value. As the aggregated value is not in float range, the value is displayed incorrectly.

```auto
"aggs": {
	"store": {
		"terms": {
			"field": "storeID"
		},
		"aggs": {
			"totalPrice": {
				"sum": {
					"field": "longPrice"
				}
			}
		}
	}
}

```

**SearchResult Snippet:**

```auto
"aggregations" : {
    "store" : {
      "doc_count_error_upper_bound" : 2246,
      "sum_other_doc_count" : 441896,
      "buckets" : [
        {
          "key" : "1234",
          "doc_count" : 9882,
          "totalPrice" : {
            "value" : 4585792.0
          }
        },
        {
          "key" : "1235",
          "doc_count" : 8233,
          "totalPrice" : {
            "value" : ***1.3391005E7***
          }
        },
        {
          "key" : "1236",
          "doc_count" : 5205,
          "totalPrice" : {
            "value" : 413264.0
          }
        },
        {
          "key" : "1237",
          "doc_count" : 5013,
          "totalPrice" : {
            "value" : 1000374.0
          }
        },
        {
          "key" : "1238",
          "doc_count" : 4544,
          "totalPrice" : {
            "value" : ***3.221301E7***
          }
        }
      ]
    }
  }

```

If we see the second and fifth bucket value, they are displaying incorrectly.

What need to be changed for this?

Thanks In Advance

Regards,  
Keyu

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 17, 2022, 7:39pm UTC](https://discuss.elastic.co/t/long-value-displayed-incorrectly-in-watcher-email/292502/2 "2022-01-17T19:39:15Z")

</div>

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