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

来源:互联网 发布:java电商项目源码 编辑:程序博客网 时间:2024/06/05 05:16

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

本人是初学者,以上方法仅供参考。

0 0
原创粉丝点击