MapperParsingException:没有在字段上声明的类型[date_hour_minute_second]的处理程序

Fat*_*ana 3 python elasticsearch pyes

我正在为Elasticsearch开发一个带Python Pyes客户端的驱动程序.我需要具有日期列的映射索引具有基于文档的格式No"date_hour_minute_second" http://www.elasticsearch.org/guide/reference/mapping/date-format/我还检查了pyes docs https://pyes.readthedocs.组织/ EN /最新/引导/参考/制图/日期format.html

当我在我的字段中使用"date_hour_minute_second"格式时,我得到了标题中提到的异常.

这是我的字段定义:

      "date": {
           "boost": 1.0,
           "store": "yes",
           "type": "date_hour_minute_second_fraction",
           "term_vector": "with_positions_offsets"
       }
Run Code Online (Sandbox Code Playgroud)

我无法弄明白为什么它会抛出一个例外,即使是文档说它是受支持的.

ram*_*laf 12

我认为你把映射略有错误,"date"你有的是字段名称,你还需要"type": "date"试试这个:

"date": {
    "type": "date",
    "format": "date_hour_minute_second_fraction",
    "store": "yes"
}
Run Code Online (Sandbox Code Playgroud)

"boost" 默认为1.0,所以不需要.

另外我会问你为什么需要"store": "yes",除非你已经关闭全局存储(它默认打开,并且可以检索你发送给elasticsearch的整个文档).

最后,"term_vector": "with_positions_offsets"不是"date"类型的适用参数.查看核心类型的elasticsearch文档并滚动到日期部分.

祝好运!