Invalid format for date

Hello ,

I am trying to use Index Template. The following is my template

 {
        "template": "te*",
        "settings": {
            "number_of_shards": 1
        },
        "mappings": {
            "log": {
                "properties": {
                    "@timestamp": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss.SSSZ",
                        "index": "not_analyzed"
                    },
                    "log_generation_date": {
                        "type": "date",
                        "format": "yyyy-MM-dd HH:mm:ss.SSSZ",
                        "index": "not_analyzed"
                    }
                }
            }
        }
    }

After this I have created my index and then I am trying to insert a document using the following command:

curl -XPUT 'localhost:9200/templateindex/demo/1?pretty' -d '
{
             
            
                   "@timestamp" : "2016-07-26T05:42:27.781Z", 
                 "log_generation_date" : "2014-02-06T00:00:38.000Z"

}'

I am getting the following error:

{
  "error" : {
    "root_cause" : [ {
      "type" : "mapper_parsing_exception",
      "reason" : "failed to parse [@timestamp]"
    } ],
    "type" : "mapper_parsing_exception",
    "reason" : "failed to parse [@timestamp]",
    "caused_by" : {
      "type" : "illegal_argument_exception",
      "reason" : "Invalid format: \"2016-07-26T05:42:27.781Z\" is malformed at \"T05:42:27.781Z\""
    }
  },
  "status" : 400
}

What I am doing wrong here ?
I hope my format is correct.

Thank you

Done.

I removed the 'format' and it is working

Hello shivkumar,

Just to give you small feedback. Your format was wrong, it specifying a space instead of "T".

It worked when you removed because that timestamp you are using is actually a standard format that elasticsearch already understands.

Cheers

Thank you sir for your feed back:slight_smile: