ik

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

中文分词器下载
$elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.4/elasticsearch-analysis-ik-6.2.4.zip



-> Downloading https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.4/elasticsearch-analysis-ik-6.2.4.zip
Exception in thread “main” java.net.UnknownHostException: github.com



下载elasticsearch-analysis-ik-6.1.1.zip
解压
$mkdir -p /usr/local/Cellar/elasticsearch/6.2.4/libexec/plugins/ik
$mv elasticsearch /usr/local/Cellar/elasticsearch/6.2.4/libexec/plugins/ik
重启es失败
原因 多了层目录
/usr/local/Cellar/elasticsearch/6.2.4/libexec/plugins/ik/elasticsearch 内部的东西移动到
/usr/local/Cellar/elasticsearch/6.2.4/libexec/plugins/ik
即可
重启



kibana 可以测试分词
GET _analyze?pretty
{
“analyzer”: “ik_smart”,
“text”:”安徽省长江流域”
}
分词结果



{
“tokens”: [
{
“token”: “安徽省”,
“start_offset”: 0,
“end_offset”: 3,
“type”: “CN_WORD”,
“position”: 0
},
{
“token”: “长江流域”,
“start_offset”: 3,
“end_offset”: 7,
“type”: “CN_WORD”,
“position”: 1
}
]
}

查看已有词典
vi /usr/local/Cellar/elasticsearch/6.2.4/libexec/plugins/ik/config/main.dic



自定义词典
$ mkdir custom
$ vi custom/new_word.dic
$ cat custom/new_word.dic
老铁
王者荣耀
洪荒之力
共有产权房
一带一路



更新配置
$vi /usr/local/Cellar/elasticsearch/6.2.4/libexec/plugins/ik/config/IKAnalyzer.cfg.xml
$ cat IKAnalyzer.cfg.xml
<?xml version=”1.0” encoding=”UTF-8”?>
<!DOCTYPE properties SYSTEM “http://java.sun.com/dtd/properties.dtd”>



IK Analyzer 扩展配置

custom/new_word.dic







重启elasticsearch
从输出信息中可以看到
[Dict Loading] custom/new_word.dic



重启Kibana
重启Kibana后,从新执行下面命令



GET _analyze?pretty
{
“analyzer”: “ik_smart”,
“text”:”王者荣耀”
}
可以看到新结果


Category elasticsearch