Elasticsearch日期无效格式太短

时间:2018-07-22 19:26:44

标签: ruby elasticsearch

我有一个带有字段starts_at和映射的Elasticsearch模型

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

当我尝试输入2018-07-29T13:00:00Z时,出现错误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}

我在做什么错了?

1 个答案:

答案 0 :(得分:0)

我无法复制它:

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

这很好用...