Default timestamp in date Field

I am looking for Replica of Default NOW() (MYSQL) in elasticsearch.As _timestamp has been removed in the higher version,how we do this in 6.X

{
    "properties":{
        "defautlt_time":{
            "type":"date",
            "default_value":"current_now()" --> this will the current time ,need to indexed by ES by default,is there any way to achieve this
        }
    }
}
1 Like

Hi, I am just working on a similar question.

One option is the use of ingest node with a pipeline:

https://www.elastic.co/guide/en/elasticsearch/reference/current/accessing-data-in-pipelines.html

Looks something like this:

{
"set": {
"field": "date",
"value": "{{_ingest.timestamp}}"
}
}

The drawback here is, that when doing the insert I need to add the ?pipeline=my_pipeline at the end of my REST call. This is not always possible when using an external service.

There is a discussion about default pipelines, which would solve this, but as far as I know, this is not shipped yet:

Perhaps there is another option as well ...

Thanks niemyjski,what is the other option? m not using any log stash ,I am pushing data to ES from java using Transport client

When you have control on the calling side, you most likely could use the ingest node as mentioned above. This should not require log stash.

In my case this does not work (as I can not modify the REST call for a new entry to Elasticsearch) thus I am still searching for another option ... I did not mention that there is one.

After further research there seems to be no direct other option. Under the following link there is a sample posted for using ingest node timestamps:

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