"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在刷新。

 

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

至此,問題解決,重啟了集群

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM