Update timestamp from millis to second in all documents

I'm trying to update my timestamps from milliseconds to seconds while re-indexing but i'm not sure how to do it. We are using elasticsearch 2.4.6 which in turn uses groovy script.

My script looks like below: (i know this not the best way to do it)

    "script":{"inline":"ctx._source.service.created=DateTime.parse(ctx._source.service.created)/1000"}

i got the below Error when i'm executing the script

{

 "error": {
   "root_cause": [
     {
       "type": "script_exception",
       "reason": "failed to run inline script [ctx._source.service.created=DateTime.parse(ctx._source.service.created)/1000 ] using lang [groovy]"}],
   "type": "script_exception",
   "reason": "failed to run inline script [ctx._source.service.created=DateTime.parse(ctx._source.service.created)/1000 ] using lang [groovy]",
      "caused_by": {
              "type": "missing_method_exception",
              "reason": "No signature of method: org.joda.time.DateTime.div() is applicable for argument types: (java.lang.Integer) values: [1000] Possible solutions: is(java.lang.Object), wait(), era(), now(), find(), dump()"}},
"status": 500

}

My mappings looks like this

{  
  "es" : {
     "properties" : {
             "service" : {
                     "created" : {
					      "format": "epoch_second||dateOptionalTime",
					      "type": "date"
				      }
                }
       }
   }
}

Any suggestions could be helpful

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