环境信息
ES=IK=7.9.2
原来的配置
- Index如下:
PUT /demo
{
"settings": {
"number_of_shards" : 12,
"number_of_replicas" : 1,
"analysis":{
"analyzer":{
"ik":{
"tokenizer":"ik_max_word"
}
}
}
},
"mappings":{
"properties":{
"query":{
"type":"text",
"analyzer": "ik_max_word"
}
}
}
}
- 新增文档如下:
POST /demo/_doc/1
{
"query":"记者从直播电商与短视频发展年会上获悉,中国演出行业协会网络表演(直播)分会将在年内针对网络直播打赏行为出台指导规范,预计最快12月出台。除此之外,协会还将推出网络主播的分类分级管理规范,对非电商类主播进行评级。"
}
- 报错内容如下:
{
"error" : {
"root_cause" : [
{
"type" : "null_pointer_exception",
"reason" : "Cannot invoke \"org.wltea.analyzer.dic.DictSegment.match(char[], int, int)\" because \"org.wltea.analyzer.dic.Dictionary.singleton._StopWords\" is null"
}
],
"type" : "null_pointer_exception",
"reason" : "Cannot invoke \"org.wltea.analyzer.dic.DictSegment.match(char[], int, int)\" because \"org.wltea.analyzer.dic.Dictionary.singleton._StopWords\" is null"
},
"status" : 500
}
解决方法
查了很久,原因是:
在安装IK时缺少了文件,进入ES/plugins/analysis-ik 路径,config目录不存在。
elasticsearch-plugin install 方式安装,配置及数据文件未安装仅plugins目录下。
所以接下来,手动copy一下即可。
github下载路径:
https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.9.2/elasticsearch-analysis-ik-7.9.2.zip
注意版本号需要相同,否则无法启用IK。