# Different behavior between POST \_add and \_update endpoints on documents with epoch\_millis dates as strings or int/float

**URL:** <https://discuss.elastic.co/t/different-behavior-between-post-add-and-update-endpoints-on-documents-with-epoch-millis-dates-as-strings-or-int-float/251194>\
**Category:** Elasticsearch\
**Created:** [October 6, 2020, 10:45pm UTC](https://discuss.elastic.co/t/different-behavior-between-post-add-and-update-endpoints-on-documents-with-epoch-millis-dates-as-strings-or-int-float/251194 "2020-10-06T22:45:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ljak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ljak/32/40307_2.png) [@ljak](https://discuss.elastic.co/u/ljak)\
**Post date:** [October 6, 2020, 10:45pm UTC](https://discuss.elastic.co/t/different-behavior-between-post-add-and-update-endpoints-on-documents-with-epoch-millis-dates-as-strings-or-int-float/251194/1 "2020-10-06T22:45:51Z")

</div>

Hello everyone,

According to documentation [https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html#mapping-date-format](https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html#mapping-date-format) ; Elasticsearch parses dates from Strings ... and such, even where your date could be represented as... a int/float, like for a timestamp as the [Unix epoch time](https://www.epochconverter.com/clock) (eg: `1602022482 -> "1602022482"` )

First, why not to parse from int/float as well for date representation like timestamp ? (at least, when the mapping is clear that that field should be a date).

I'm asking the question because I had this problem today:

```
PUT /test_update_timestamp
{
  "mappings": {
    "properties": {
      "timestamp": { "type": "date", "format": "epoch_millis" },  
      "info": { "type": "text" }
    }
  }
}

```

\_

```
POST test_update_timestamp/_doc/
{
  "timestamp": 1601990454497.311,
  "info": "test"
}
# WORKED (SURPRISE!)

POST test_update_timestamp/_doc/
{
  "timestamp": "1601990454497.311",
  "info": "test"
}
# WORKED (expected)

```

\_

```
POST test_update_timestamp/_update/7dTw_nQBakZdFzO4TJYz
{
  "doc": {
    "timestamp": "1601989445406.2952"
  }
} 
# WORKED (expected)
POST test_update_timestamp/_update/7dTw_nQBakZdFzO4TJYz
{
  "doc": {
    "timestamp": 1601989445406.2952
  }
} 
# DO **NOT** WORKED (surprise / not surprise) -> RequestError(400, 'mapper_parsing_exception', "failed to parse field [timestamp] of type [date] in document with id '69Ts_nQBakZdFzO4LJbf'. Preview of field's value: '1.601990454497311E12'"

```

\_

So, finally, it happens that Elasticsearch can parse dates from int/float representation, without any problem, when creating a new document (surprise!). But when updating a document, Elasticsearch do not to parse dates from int/float representation (surprise but not surprise!) by returning a `mapper_parsing_exception`.

Why is there a different behavior between the 2 endpoints ? Could it be possible to have the \_update endpoint be able to parse dates represented as int/float as well ?

Thanks a lot.

---

<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:** [November 3, 2020, 10:45pm UTC](https://discuss.elastic.co/t/different-behavior-between-post-add-and-update-endpoints-on-documents-with-epoch-millis-dates-as-strings-or-int-float/251194/2 "2020-11-03T22:45:53Z")

</div>

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