datetime的illegal_argument_exception

时间:2017-08-31 09:06:03

标签: elasticsearch

我想在Elasticsearch中使用默认日期格式。

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

但是,当我尝试输入一些数据时,它会失败:

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"}

错误讯息:

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

1 个答案:

答案 0 :(得分:2)

您需要根据ISO 8601格式设置日期格式,即2016-05-15T18:00:15,即您错过了T

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