MapperParsingException:字段上未声明类型[日期/小时/分钟/秒]的处理程序

2024-04-27 19:04:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在为Elasticsearch开发一个PythonPyes客户端驱动程序。我需要一个日期列的映射索引,它的格式不是基于文档的“date-hour-minute-second”http://www.elasticsearch.org/guide/reference/mapping/date-format/我还要检查pyes-docshttps://pyes.readthedocs.org/en/latest/guide/reference/mapping/date-format.html

当我在字段中使用“日期-小时-分钟-秒”格式时,我得到了标题中提到的异常。

以下是我的字段定义:

      "date": {
           "boost": 1.0,
           "store": "yes",
           "type": "date_hour_minute_second_fraction",
           "term_vector": "with_positions_offsets"
       }

我不明白为什么它会抛出这样的异常,甚至文档都说它是受支持的。


Tags: 文档orgformat客户端date格式elasticsearchmapping
1条回答
网友
1楼 · 发布于 2024-04-27 19:04:24

我想你把映射放错了,你的"date"是字段名,你还需要"type": "date"试试这个:

"date": {
    "type": "date",
    "format": "date_hour_minute_second_fraction",
    "store": "yes"
}

"boost"默认为1.0,因此不需要。

我也会问你为什么需要"store": "yes",除非你已经关闭了全局存储(默认情况下是打开的,并且你发送给elasticsearch的整个文档都可以被检索)。

最后,"term_vector": "with_positions_offsets"不是"date"类型的适用参数。看看at the elasticsearch docs on core types and scroll to the date section

祝你好运!

相关问题 更多 >