elasticsearch 安装hanlp插件

第一种方法:

1.HanLP分词器插件下载地址
https://github.com/pengcong90/elasticsearch-analysis-hanlp/releases
下载analysis-hanlp.zip


2.解压到ElasticSearch下plugins目录下


3.配置
修改analysis-hanlp目录下的hanlp.properties文件,修改root的属性,值为analysis-hanlp下的data 目录的地址
修改analysis-hanlp目录下的plugin-descriptor.properties文件,elasticsearch.version=你的es版本号(like:5.5.1)


修改es config目录下的jvm.options文件,最后一行添加
-Djava.security.policy=../plugins/analysis-hanlp/plugin-security.policy


4.HanLP有以下两种分词器
hanlp-index:尽可能的切分多的结果
hanlp-smart:切分少的词
---------------------
 
第二种方法:

安装步骤

1. 下载安装ES对应Plugin Release版本

安装方式:

方式一

a. 下载对应的release安装包

b. 将相关内容解压至ES_HOME/plugins/analysis-hanlp

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

2. 安装数据包

release包中存放的为HanLP源码中默认的分词数据,若要下载完整版数据包,请查看HanLP Release

数据包目录:ES_HOME/analysis-hanlp

注:因原版数据包自定义词典部分文件名为中文,这里的hanlp.properties中已修改为英文,请对应修改文件名

3. 重启Elasticsearch

注:上述说明中的ES_HOME为自己的ES安装路径,需要绝对路径

4. 热更新

在本版本中,增加了词典热更新,修改步骤如下:

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: 极速词典分词

 

posted @ 2019-03-12 09:07  蚂蚁的天空  阅读(6356)  评论(0编辑  收藏  举报