Date Invalid format too short


(Maged Makled) #1

I have an elasticsearch model with a field starts_at with the mapping

"starts_at": {
               "type": "date",
               "format": "yyyy-MM-dd'T'HH:mm:ssZ"
             }

When I try to enter 2018-07-29T13:00:00Z, I get the error Invalid format: \"2018-07-29\" is too short"

Elasticsearch::Transport::Transport::Errors::BadRequest: [400] {"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"failed to parse [starts_at]"}],"type":"mapper_parsing_exception","reason":"failed to parse [starts_at]","caused_by":{"type":"illegal_argument_exception","reason":"Invalid format: \"2018-07-29\" is too short"}},"status":400}

What Am I doing wrong?


Date is too short
(David Pilato) #2

Just wondering about 2018-07-29T13:00:00Z. What is the meaning of Z here?
It should be a time zone I think.


(Maged Makled) #3

so the format with the Z is a UTC format but I also get the same error if I try to enter 2018-07-29T08:00:00-05:00


(David Pilato) #4

This works well on my end:

DELETE test 
PUT test
{
  "mappings": {
    "_doc": {
      "properties": {
        "starts_at": {
          "type": "date",
          "format": "yyyy-MM-dd'T'HH:mm:ssZ"
        }
      }
    }
  }
}
POST test/_doc
{
  "starts_at": "2018-07-29T08:00:00-05:00"
}

(system) #5

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