架构师_程序员_码农网

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 5171|回复: 0

Elasticsearch:No handler for type [string] declared on field[XX]的解决办法

[复制链接]
发表于 2019-1-9 10:29:11 | 显示全部楼层 |阅读模式
报错原因

{
"error": {
"root_cause": [
{
"type": "mapper_parsing_exception",
"reason": "No handler for type [string] declared on field [upload_status]"
}
],
"type": "mapper_parsing_exception",
"reason": "No handler for type [string] declared on field [upload_status]"
},
"status": 400
}
QQ截图20190109101822.jpg

我使用的Elasticsearch是6.2.2版本,按照学校文档创建字段时,使用了{"type":"string","index":"not_analyzed"}。

原因分析

检查拼写无误之后,我决定去查Elasticsearch新版本特性,因为之前也踩过head插件的安装方法的坑,就是因为版本问题。
果不其然,Elasticsearch从5.X就引入了text和keyword,其中keyword适用于不分词字段,搜索时只能完全匹配,这时string还保留着。

到了6.X就彻底移除string了。

另外,"index"的值只能是boolean变量了

解决方法

{"type":"text","index":false}

所以,json修改如下:

但是又有新的错误出现,如下:

{
"error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [restraunt] as the final mapping would have more than 1 type: [record, info]"
}
],
"type": "illegal_argument_exception",
"reason": "Rejecting mapping update to [restraunt] as the final mapping would have more than 1 type: [record, info]"
},
"status": 400
}
这是由于Elasticsearch 6.x中的一个重大变化,其中Mapping只允许一种类型。在具有多种映射类型的5.x中创建的索引将继续像以前一样在Elasticsearch 6.x中运行。映射类型将在Elasticsearch 7.0.0中完全删除。

Elasticsearch 7.x 版本后 typeURL中 的参数是可选的。例如,索引文档不再需要文档type

参考资料:

https://github.com/sirensolutions/sentinl/issues/257
https://www.elastic.co/guide/en/ ... moval-of-types.html







上一篇:MD5加密
下一篇:C# 代码如何实现让你的电脑关机,重启,注销,锁定,休...
码农网,只发表在实践过程中,遇到的技术难题,不误导他人。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

免责声明:
码农网所发布的一切软件、编程资料或者文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:help@itsvse.com

QQ|手机版|小黑屋|架构师 ( 鲁ICP备14021824号-2 )|网站地图

GMT+8, 2024-3-29 17:31

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表