使用Map创建索引时elasticsearch日期分析错误

ycl3bljg  于 2021-06-10  发布在  ElasticSearch
关注(0)|答案(1)|浏览(377)

我在cdk脚本中创建elasticsearch(7.7版本)索引(带有Map)。以下是日期字段的Map:

{
  "mappings": {
    "numeric_detection": true,
    "properties": {
      "approximateArrivalTime": {
        "type": "date",
        "format": "yyyy-MM-dd HH:mm:ss.SSSXXX"
      }, ......}

但我一直有这样的错误信息:

{\"type\":\"illegal_argument_exception\",\"reason\":\"failed to parse date field [2020-11-23 11:48:20.472] with format [yyyy-MM-dd HH:mm:ss.SSSXXX]\",\"caused_by\":{\"type\":\"date_time_parse_exception\",\"reason\":\"Text \\u00272020-11-23 11:48:20.472\\u0027 could not be parsed at index 23\"}}}

原因是什么?

2eafrhcq

2eafrhcq1#

这个错误清楚地表明您正在索引中的数据 approximateArrivalTime 与索引Map中指定的日期格式不匹配。
尝试按以下格式索引文档:
索引Map:

{
  "mappings": {
    "properties": {
      "approximateArrivalTime": {
       "type": "date",
       "format": "yyyy-MM-dd HH:mm:ss.SSS"
        }
    }
  }
}

索引数据:

{
  "approximateArrivalTime":"2020-11-23 11:48:20.472"
}

相关问题