I have an Elasticsearch index which uses the @timestamp
field to store the date in a date
field.
There are many records which are missing the @timestamp
field, but have a timestamp
field containing a unix timestamp. (Generated from PHP, so seconds, not milliseconds)
Note, the timestamp
field is of date type, but numeric data seems to be stored there.
How can I use Painless script in a reindex and set @timestamp
where it is missing, IF there is a numeric timestamp
field with a unix timestamp?
Here's an example record that I would want to transform.
{
"_index": "my_log",
"_type": "doc",
"_id": "AWjEkbynNsX24NVXXmna",
"_score": 1,
"_source": {
"name": null,
"pid": "148651",
"timestamp": 1549486104
}
},