@[TOC] 解决elasticsearch里拒绝更新mapping设置的错误
错误现象
对一个es上已经创建的索引,使用python的elasticsearch_dsl 库,
Rejecting mapping update to [] as the final mapping would have more than 1 type: [ _doc,]
环境版本 elasticsearch 6.3
从原因分析,应该6以后的较高版本都会出现
原因浅层分析
elasticsearch 6对mapping的一个基础设定做了重大改变(Breaking Change),用官方文档原文来描述是这样的
Indices created in Elasticsearch 6.0.0 or later may only contain a single mapping type. Indices created in 5.x with multiple mapping types will continue to function as before in Elasticsearch 6.x. Types will be deprecated in APIs in Elasticsearch 7.0.0, and completely removed in 8.0.0.
不完全也不精确地理解,一个索引(Index)内部曾经允许动态创建多个mapping type,新版本里不允许了。
同时修改的还有对_doc这个默认值的处理。
如果在创建mapping时没设对参数值,就会一直报错。
简单绕开问题的办法
PUT http://localhost:9200/index_name/
用api创建名为index_nam