# Transforms: date epoch\_millis parsing errors

**URL:** <https://discuss.elastic.co/t/transforms-date-epoch-millis-parsing-errors/235731>\
**Category:** Elasticsearch\
**Created:** [June 4, 2020, 10:23am UTC](https://discuss.elastic.co/t/transforms-date-epoch-millis-parsing-errors/235731 "2020-06-04T10:23:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carlos\_Moya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_moya/32/46457_2.png) [@Carlos\_Moya](https://discuss.elastic.co/u/Carlos_Moya)\
**Post date:** [June 4, 2020, 10:23am UTC](https://discuss.elastic.co/t/transforms-date-epoch-millis-parsing-errors/235731/1 "2020-06-04T10:23:02Z")

</div>

Hello,

We have a 7.6.2 elasticsearch cluster.

A transform is failing with the next parsing errors:

```auto
    261]: index [t_transform_testing], type [_doc], id [QWFGhHsjq4vzL5KDKy_E9J2TAAAAAAAA], message [MapperParsingException[failed to parse field [lastError] of type [date] in document with id 'QWFGhHsjq4vzL5KDKy_E9J2TAAAAAAAA'. Preview of field's value: '1.588590892488E12']; nested: IllegalArgumentException[failed to parse date field [1.588590892488E12] with format [strict_date_optional_time||epoch_millis]]; nested: NotSerializableExceptionWrapper[date_time_parse_exception: Failed to parse with all enclosed parsers];]

```

Seems that it doesn't accept "1.588590892488E12" as an epoch\_millis date. The strange thing is that this field is obtained by a "toInstant().toEpochMilli()" function, used in this aggregation:

```auto
    "lastError": {
            "scripted_metric": {
              "init_script": "state.timestamps = []",
              "map_script": "if (doc.error.value == true) { state.timestamps.add(doc.timestamp.value.toInstant().toEpochMilli()) }",
              "combine_script": "return state.timestamps.length > 0 ? Collections.min(state.timestamps) : -1L",
              "reduce_script": "double first = 0; for (a in states) { if(!(a == -1L) && (a < first || first == 0)) { first = a } } return first"
            }
          }

```

Is it a bug or I'm missing something?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![Hendrik\_Muhs](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hendrik_muhs/32/25802_2.png) [@Hendrik\_Muhs](https://discuss.elastic.co/u/Hendrik_Muhs)\
**Post date:** [June 4, 2020, 6:55pm UTC](https://discuss.elastic.co/t/transforms-date-epoch-millis-parsing-errors/235731/2 "2020-06-04T18:55:30Z")

</div>

This is a mapping error, if you try to put a document with `1.588590892488E12` as value of a date field you get the same error.

Any reason you use `double` (a floating point number)? If you change your script to use `long` I am sure it will work.

---

<div class="post-metadata">

**Author:** ![Carlos\_Moya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/carlos_moya/32/46457_2.png) [@Carlos\_Moya](https://discuss.elastic.co/u/Carlos_Moya)\
**Post date:** [June 5, 2020, 7:09am UTC](https://discuss.elastic.co/t/transforms-date-epoch-millis-parsing-errors/235731/3 "2020-06-05T07:09:54Z")

</div>

You are totally right @Hendrik_Muhs ! I was too focused on the toEpochMilli() function. Changing the double for a long it's working.

Thank you very much.

---

<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:** [July 3, 2020, 7:10am UTC](https://discuss.elastic.co/t/transforms-date-epoch-millis-parsing-errors/235731/4 "2020-07-03T07:10:02Z")

</div>

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