Re-Index to new date format. getting parse_exception

   POST _reindex
    {
      "source": {
        "index": "source"
      },
      "dest": {
        "index": "dest"
      },
      "script": {
        "source": """
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");
        ctx._source.execution_end_time = format.format(format.parse(ctx._source.execution_end_time));
        """
      }
    }

getting this error. Please guide on this.

    {
      "error": {
        "root_cause": [
          {
            "type": "script_exception",
            "reason": "runtime error",
            "script_stack": [
              "java.base/java.text.DateFormat.parse(DateFormat.java:395)",
              "ctx._source.execution_end_time = format.format(format.parse(ctx._source.execution_end_time));",
              "                                                                       ^---- HERE"
            ],
            "script": "    SimpleDateFormat format = new SimpleDateFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSSZ\");\n    ctx._source.execution_end_time = format.format(format.parse(ctx._source.execution_end_time));",
            "lang": "painless"
          }
        ],
        "type": "script_exception",
        "reason": "runtime error",
        "script_stack": [
          "java.base/java.text.DateFormat.parse(DateFormat.java:395)",
          "ctx._source.execution_end_time = format.format(format.parse(ctx._source.execution_end_time));",
          "                                                                       ^---- HERE"
        ],
        "script": "    SimpleDateFormat format = new SimpleDateFormat(\"yyyy-MM-dd'T'HH:mm:ss.SSSZ\");\n    ctx._source.execution_end_time = format.format(format.parse(ctx._source.execution_end_time));",
        "lang": "painless",
        "caused_by": {
          "type": "parse_exception",
          "reason": "Unparseable date: \"2020:09:17 06:46:26.679\""
        }
      },
      "status": 400
    }

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