Elasticsearch:由于之前创建的Index Templates未删除,导致创建Index时报错Root type mapping not empty after parsing

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/winx_coder/article/details/53202974

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报错不够清晰,因此容易引发一些问题。

猜你喜欢

转载自blog.csdn.net/winx_coder/article/details/53202974