第一种方法:java
1.HanLP分词器插件下载地址
https://github.com/pengcong90/elasticsearch-analysis-hanlp/releases
下载analysis-hanlp.zipgit
2.解压到ElasticSearch下plugins目录下github
3.配置
修改analysis-hanlp目录下的hanlp.properties文件,修改root的属性,值为analysis-hanlp下的data 目录的地址
修改analysis-hanlp目录下的plugin-descriptor.properties文件,elasticsearch.version=你的es版本号(like:5.5.1)jvm
修改es config目录下的jvm.options文件,最后一行添加
-Djava.security.policy=../plugins/analysis-hanlp/plugin-security.policyelasticsearch
4.HanLP有如下两种分词器
hanlp-index:尽量的切分多的结果
hanlp-smart:切分少的词
---------------------
第二种方法:插件
安装方式:code
方式一索引
a. 下载对应的release安装包ip
b. 将相关内容解压至ES_HOME/plugins/analysis-hanlpget
c. 将config目录下的文件移动至ES_HOME/config/analysis-hanlp
d. 解压出的data目录为词典目录
方式二
a. 使用elasticsearch插件脚本安装command以下:
./bin/elasticsearch-plugin install https://github.com/KennFalcon/elasticsearch-analysis-hanlp/releases/download/v6.5.4/elasticsearch-analysis-hanlp-6.5.4.zip
release包中存放的为HanLP源码中默认的分词数据,若要下载完整版数据包,请查看HanLP Release。
数据包目录:ES_HOME/analysis-hanlp
注:因原版数据包自定义词典部分文件名为中文,这里的hanlp.properties中已修改成英文,请对应修改文件名
注:上述说明中的ES_HOME为本身的ES安装路径,须要绝对路径
在本版本中,增长了词典热更新,修改步骤以下:
a. 在ES_HOME/analysis-hanlp/data/dictionary/custom目录中新增自定义词典
b. 修改hanlp.properties,修改CustomDictionaryPath,增长自定义词典配置
c. 等待1分钟后,词典自动加载
注:每一个节点都须要作上述更改
hanlp: hanlp默认分词
hanlp_standard: 标准分词
hanlp_index: 索引分词
hanlp_nlp: NLP分词
hanlp_n_short: N-最短路分词
hanlp_dijkstra: 最短路分词
hanlp_crf: CRF分词(在hanlp 1.6.6已开始废弃)
hanlp_speed: 极速词典分词