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

报错原因

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

原因分析

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

解决方法

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

参考文档

https://segmentfault.com/a/1190000008897731
https://www.cnblogs.com/zlslch/p/6619089.html
https://www.elastic.co/guide/en/elasticsearch/reference/6.2/breaking-changes-6.0.html

猜你喜欢

转载自blog.csdn.net/Mr_OOO/article/details/79518978