Timestamp update

Hello !

I would like to update my timestamp field, but all the info that i've found are not working...
Probably a synthax error but i'm not able to figure out where it stucks... I already tried several option...

POST myindex/_update_by_query
{
    "script" : {
      "source": "ctx._source.timestamp = '2020-01-30T23:00:00.000Z';",
      "lang": "painless"
    },
    "query": {
        "term" : {
            "@timestamp": "2019-12-31T23:00:00.000Z"
        }
    }
}

Here is the result:

 {
      "index" : "myindex",
      "type" : "_doc",
      "id" : "zv9hMncB6BPk8lMws2HZ",
      "cause" : {
        "type" : "mapper_parsing_exception",
        "reason" : "failed to parse field [timestamp] of type [long] in document with id 'zv9hMncB6BPk8lMws2HZ'. Preview of field's value: '2020-01-30T23:00:00.000Z'",
        "caused_by" : {
          "type" : "illegal_argument_exception",
          "reason" : "For input string: \"2020-01-30T23:00:00.000Z\""
        }
      },
      "status" : 400
    },

It seems that the mapping for the field timestamp is a long and not a date so you can't do that.

After several tries, i got it working:

"source": "ctx._source['@timestamp'] = '2018-03-30T23:00:00.000Z';"

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