配置ES IK分词器自定义字典

1.编辑IKAnalyzer.cfg.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
    <comment>IK Analyzer 扩展配置</comment>
    <!--用户可以在这里配置自己的扩展字典 -->
    <entry key="ext_dict">ext.dic</entry>
     <!--用户可以在这里配置自己的扩展停止词字典-->
    <entry key="ext_stopwords"></entry>
    <!--用户可以在这里配置远程扩展字典 -->
    <!-- <entry key="remote_ext_dict">words_location</entry> -->
    <!--用户可以在这里配置远程扩展停止词字典-->
    <!-- <entry key="remote_ext_stopwords">words_location</entry> -->
</properties>

添加ext.dic

2.在config目录下新建ext.dic文件

 警告:这里一定要注意文件编码设置成UTF-8不然会不生效!!!

我用的 editPlus

 3.然后重启ES调用分词接口

原文地址:https://www.cnblogs.com/guanxiaohe/p/12365882.html