As per my understanding and from here [http://stackoverflow.com/questions/29341715/understanding-how-elasticsearch-stores-dates-internally] (http://stackoverflow.com/questions/29341715/understanding-how-elasticsearch-stores-dates-internally) ealstic search stores the date internally as epoch format. Now consider I need to access this epoch in groovy script and out doc date format is date_optional_time. Now when I try to access it in groovy script it gives me the formatted date(as on the time of input). Is there a way to access the epoch time here.
I have come up with three thoughts
- Convert the doc value to date and get millis in script,
- Create a new field with copy_to that stores the date as epoch format
3)//or if possible directly access the epoch. but how?
Can some body guide me on this.I need epoch because I need to update some other field on basis of the epoch
e.g
Consider a mapping like this
{
"createdDate": {
"type": "date",
"store": true,
"format": "dateOptionalTime"
}
"modifiedDate": {
"type": "date",
"store": true,
"format": "dateOptionalTime"
}
"daysINBetween" : {
"type" : "long"
}
,
}
Now I need to run a script that stores (createdDate.millis - modifiedDate.millis) / (24 * 60 * 60 * 1000)
. I don't want to create a new object of date each time, that's why I am trying to access epoch in script