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

报错原因
我使用的Elasticsearch是7.7.0版本,按照学习文档创建字段时,使用了{"type":"string","index":"not_analyzed"}

原因分析
检查拼写无误之后,我决定去查Elasticsearch新版本特性,因为之前也踩过head插件的安装方法的坑,就是因为版本问题。
果不其然,Elasticsearch从5.X就引入了text和keyword,其中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

posted @ 2021-05-07 13:27  a-du  阅读(1532)  评论(0编辑  收藏  举报