Elasticsearch:由於之前創建的Index Templates未刪除,導致創建Index時報錯Root type mapping not empty after parsing

Elasticsearch版本:

1.7.1


故障

執行新建Index命令:
PUT /hrms

報錯:
{
   "error": "MapperParsingException[mapping [candidate]]; nested: MapperParsingException[
Root type mapping not empty after parsing! Remaining fields:   [experience : {type=float}
]]; ",
   "status": 400
}

原因分析

難道是Index已經存在嗎?
於是嘗試刪除Index:
DELETE /hrms

報錯:Index不存在?!
{
   "error": "IndexMissingException[[hrms] missing]",
   "status": 404
}


創建Index,報錯信息中的“Remaining fields:   [experience : {type=float}]”十分詭異,原因查找了很久,原來是之前創建的Index Templates沒有刪除。


附:之前創建的之前創建的Index template的命令:
PUT /_template/hrms-template
{
  "template": "hrms*",
  "mappings": {
    "candidate": {
      "experience": {
        "type": "float"
      }
    }
  }
}


解決方案

執行以下命令刪除Index templates即可:

DELETE /_template/hrms-template

總結

Index templates有點類似於數據庫中的觸發器,會被隱蔽地自動執行,再加上ES報錯不夠清晰,因此容易引發一些問題。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章