Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Date 创建带有映射的索引时发生ElasticSearch日期分析错误_Date_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Mapping_Date Formatting_Aws Cdk - Fatal编程技术网 elasticsearch,mapping,date-formatting,aws-cdk,Date,elasticsearch,Mapping,Date Formatting,Aws Cdk" /> elasticsearch,mapping,date-formatting,aws-cdk,Date,elasticsearch,Mapping,Date Formatting,Aws Cdk" />

Date 创建带有映射的索引时发生ElasticSearch日期分析错误

Date 创建带有映射的索引时发生ElasticSearch日期分析错误,date,elasticsearch,mapping,date-formatting,aws-cdk,Date,elasticsearch,Mapping,Date Formatting,Aws Cdk,我在cdk脚本中创建ElasticSearch(7.7版本)索引(带有映射)。以下是我对日期字段的映射: { "mappings": { "numeric_detection": true, "properties": { "approximateArrivalTime": { "type": "date", &q

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

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

原因可能是什么?

该错误清楚地表明,您在
时间
中索引的数据与索引映射中指定的日期格式不匹配

尝试以以下格式为文档编制索引:

索引映射:

{
  "mappings": {
    "properties": {
      "approximateArrivalTime": {
       "type": "date",
       "format": "yyyy-MM-dd HH:mm:ss.SSS"
        }
    }
  }
}
{
  "approximateArrivalTime":"2020-11-23 11:48:20.472"
}
索引数据:

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

@答:你是否有机会仔细阅读我的答案,期待得到你的反馈:)谢谢你的回答,不幸的是,它没有帮助。仍然是相同的错误。@A.Di我也在本地尝试过,效果很好。您是否可以共享您正在为
time
编制索引的数据?在
time
上运行搜索查询时是否出现错误?2020-11-23 11:48:20.472-我尝试解析此日期。错误表明,当我在映射中提供字段类型时,它无法解析此字段。因此,我猜您尝试索引数据,但失败。@A.Di您正在索引您在上述问题中提供的同一文档
2020-11-23 11:48:20.472
。请仔细阅读我的答案,您正在索引的数据与您在索引映射中提到的日期格式不匹配。因此,您将得到解析错误