"reason":"No handler for type [attachment] declared on field [file]" 最完全解决方案

0、elasticsearch-mapper-attachments 2.3.4安装

mapper-attachments安装方法分两类,在线和离线:

  • 在线安装
bin/elasticsearch-plugin install mapper-attachments
  • 离线安装
bin/elasticsearch-plugin install file:///path/to/mapper-attachments-2.3.4.zip

插件下载地址见:ES插件elasticsearch-mapper-attachments 2.3.4及各个版本正确下载地址

1、插入attachment mapping时,报错

报错详情:

{"error":{"root_cause":[{"type":"mapper_parsing_exception","reason":"No handler for type [attachment] declared on field [file]"}],
"type":"mapper_parsing_exception","reason":"No handler for type [attachment] declared on field [file]"},"
status":400}

具体引起报错的指令:

curl -XPUT http://88.88.88.88:9200/test/person/_mapping -d '{
    "person": {
    "properties": {
    "file": {
    "type": "attachment",
    "path": "full",
    "fields": {
    "file": {
    "type": "string",
    "term_vector":"with_positions_offsets",
    "store": true
}}}}}}'

可以看到中间的attachment类别无法识别。

那么最完全解决方案是我总结如下:

  • 是否重启ES

大部分插件在重启后,ES才会在初始化过程中加载plugins。

  • 查看重启日志,查看是否存在mapper-attachments关键词
[node-es-xxxx-pub03] modules [reindex, lang-expression, lang-groovy], plugins [elasticsearch-analysis-ansj, mapper-attachments, kopf, analysis-ik], sites [elasticsearch-analysis-ansj, kopf]

可以看到,该插件是正常加载的。

  • curl查看节点plugins信息,查看插件是否安装正确
[xxxx@hostname estest]$ curl -XGET 88.88.88.88:9200/_cat/plugins?v
name               component                   version type url                                                                     
node-es-xxx-pub01 analysis-ik                 1.9.4   j                                          
node-es-xxx-pub01 gui                         2.0.0   s    /_plugin/gui/                         
node-es-xxx-pub01 kopf                        2.0.1   s    /_plugin/kopf/                        
node-es-xxx-pub01 mapper-attachments          2.3.4   j 
……
……

可以看到,我们的插件是安装正确的。

  • 是否是集群?集群需要集群重启(还有一种可能是master节点必须重启)

集群所有节点都重启有可能不需要,时间紧张我也没时间去测了,反正我都重启了一遍。

这里我觉得只需要对master节点重启。因为如果调用es集群中的slave节点的es服务,对应它也会转到master节点来处理任务,毕竟只有master节点的log在刷新。

 

----------------------------------------------------------------------

至此,问题解决,重启了集群

 

posted @ 2016-11-29 15:04  油焖大黄瓜  阅读(3690)  评论(0编辑  收藏  举报