elasticsearch7插入数据报错
{ "error": { "root_cause": [ { "type": "illegal_argument_exception", "reason": "Rejecting mapping update to [mysort] as the final mapping would have more than 1 type: [_doc, article]" } ], "type": "illegal_argument_exception", "reason": "Rejecting mapping update to [mysort] as the final mapping would have more than 1 type: [_doc, article]" }, "status": 400 }
如果是自己新建的mapping,用put /index名/type名/id的方式添加数据时就会报错。原因是elsaticsearch7.x开始就取消了type这个概念。。至于为什么要取消,简单的了解了下,好像是如果多个type里都有相同字段的话处理效率低。
解决方法:
将type名改为_doc,例如:put /index名/_doc/1即可。