IK分词器的使用

时间:2023-03-09 00:54:34
IK分词器的使用

1.下载 根据自己的版本进行下载

https://github.com/medcl/elasticsearch-analysis-ik/releases

wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.2/elasticsearch-analysis-ik-6.2.2.zip

2.安装 解压到 当前elasticsearch的插件目录

unzip elasticsearch-analysis-ik-6.2.2.zip -d ik

3.自定义分词 IK分词器的词库

vim /usr/local/elasticsearch/plugins/ik/config/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">/asdf/asdf/asdf/asdf.dtd</entry>
<!--用户可以在这里配置自己的扩展停止词字典-->
<entry key="ext_stopwords"></entry>
<!--用户可以在这里配置远程扩展字典 -->
<entry key="remote_ext_dict">http://192.168.65.131/remote.php</entry>
<!--用户可以在这里配置远程扩展停止词字典-->
<!-- <entry key="remote_ext_stopwords">words_location</entry> -->
</properties>

4.创建远程文件库:[检测时间的变动]

<?php
$dict=<<<DICT
逼格
DICT;
header('Last-Modified: Sun, 30 Apr 2017 14:19:15 GMT', true, 200);
//header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT', true, 200);
echo $dict;