大数据 ELK(九):使用 VSCode 测试分词器

使用 VSCode 测试分词器
一、准备 VSCode 开发环境
在 VScode 中安装 Elasticsearch for VScode 插件。该插件可以直接与 Elasticsearch 交互,开发起来非常方便。
1、打开 VSCode,在应用商店中搜索 elasticsearch,找到 Elasticsearch for VSCode

2、点击安装即可

二、测试分词器
1、打开 VSCode
2、新建一个文件,命名为 0.IK 分词器测试.es
3、右键点击 命令面板 菜单

4、选择 ES:Elastic: Set Host,然后输入 Elasticsearch 的机器名和端口号


5、将以下内容复制到 ES 中,并测试。
Standard 标准分词器:
复制代码

能看出来 Standard 标准分词器,是一个个将文字切分。并不是我们想要的结果。
IK 分词器:
复制代码

IK 分词器,切分为了“我爱你”、“爱你”、“中国”,这是我们想要的效果。
注意:
analyzer 中的单词一定要写对,不能带有多余的空格,否则会报错:找不到对应名字的解析器。
版权声明: 本文为 InfoQ 作者【Lansonli】的原创文章。
原文链接:【http://xie.infoq.cn/article/9b6b4206c7ec3fc7aca62107e】。文章转载请联系作者。
评论