|
报错原因
{
"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
}
我使用的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# 代码如何实现让你的电脑关机,重启,注销,锁定,休...
|