I have couple of date fields
in my type . I am trying to run a script
on those date fields find the duration between 2 dates.
Script takes a date field as String and gives No such property: millis for class. i beleive Elastic Search stores in the date in epoch millis.
Here is the script i am trying
ctx._source.duraton = ctx._source.sessionTerminationDateTime.value.millis - ctx._source.eventConversionDateTime.value.millis
Here is my mapping
"access-event-logs": {
"mappings": {
"session-summary": {
"dynamic_templates": [
{
"long_1": {
"mapping": {
"type": "long"
},
"match": "generation"
}
},
{
"datetime_1": {
"mapping": {
"format": "strict_date_optional_time||epoch_millis",
"type": "date"
},
"match": "*DateTime"
}
},
{
"string_1": {
"mapping": {
"index": "not_analyzed",
"type": "string"
},
"match": "*"
}
}
],
"properties": {
"eventConversionDateTime": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
"generation": {
"type": "long"
},
"hostname": {
"type": "string",
"index": "not_analyzed"
},
"sessionKey": {
"type": "string",
"index": "not_analyzed",
"include_in_all": false
},
"sessionTerminationDateTime": {
"type": "date",
"format": "strict_date_optional_time||epoch_millis"
},
}
}
}
}
}
How can i get the duration in millis between 2 date fields
doc['eventConversionDateTime'].date.getMillis().
{
"_index":"access-event-logs",
"_type":"session-summary",
"_id":"c2de4a9dkarabip1new.lab.fp.f5net.com",
"_version":1,
"found":true,
"_source":{
"sessionKey":"c2de4a9dkarabip1new.lab.fp.f5net.com",
"eventConversionDateTime":"2016-01-06T16:08:43.047-08:00",
"badIpReputation":false,
"virtualServer":"/Common/access_virtual",
"lastUpdateMicros":0
}
}