Hello,
I am trying to crated new field in indices by recalculate duration based on response and request timestamps.
I have this document:
{
    "request" : {
      "time" : "2019-08-04T20:02:15.459Z"
    },
    "response" : {
      "time" : "2019-08-04T20:04:03.009Z"
    }
  }
Mapping is following:
{
  "my_index" : {
    "mappings" : {
      "properties" : {
        "request" : {
          "properties" : {
            "time" : {
              "type" : "date"
            }
          }
        },
        "response" : {
          "properties" : {
            "time" : {
              "type" : "date"
            }
          }
        }
      }
    }
  }
}
I am trying to run this script:
POST my_index/_update_by_query
{
    "script" : {
    "inline": "ctx._source.duration = (new SimpleDateFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSSZ\").parse(ctx._source.response.time).getTime() - new SimpleDateFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSSZ\").parse(ctx._source.request.time).getTime())"
  },
  "query": { "match_all": {} }
}
but getting error:
"script": "ctx._source.duration = (new SimpleDateFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSSZ\").parse(ctx._source.response.time).getTime() - new SimpleDateFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSSZ\").parse(ctx._source.request.time).getTime())",
"lang": "painless",
"caused_by": {
  "type": "null_pointer_exception",
  "reason": null
}
I do not see there any problem or did I overlooked something?
Thank you for help
Cheers, Reddy