Dinosaurius
Dinosaurius

Reputation: 8628

illegal_argument_exception for datetime

I want to use a default date format in Elasticsearch.

"mydate": {
   "type":"date"
}

However, when I try to put some data, it fails:

POST test-index/entry/_bulk
{"index":{"_id":"1"}}
{"mydate":"2016-05-15 18:00:15"}
{"index":{"_id":"2"}}
{"mydate":"2016-05-16 19:05:00"}

Error message:

caused_by": {
            "type": "illegal_argument_exception",
            "reason": """Invalid format: "2016-05-15 18:00:15" is malformed at "18:00:15""""
          }

Upvotes: 0

Views: 141

Answers (1)

Val
Val

Reputation: 217254

You need to format your dates according to the ISO 8601 format, i.e. 2016-05-15T18:00:15, i.e. you're missing the T

POST test-index/entry/_bulk
{"index":{"_id":"1"}}
{"mydate":"2016-05-15T18:00:15"}
{"index":{"_id":"2"}}
{"mydate":"2016-05-16T19:05:00"}

Upvotes: 2

Related Questions