KennFalcon / elasticsearch-analysis-hanlp

HanLP Analyzer for Elasticsearch
Apache License 2.0
825 stars 225 forks source link

7.10.2开启enable_stop_dictionary停用词报错 #110

Open 874808039 opened 3 years ago

874808039 commented 3 years ago

按照教程:

PUT test { "settings": { "analysis": { "analyzer": { "my_hanlp_analyzer": { "tokenizer": "my_hanlp" } }, "tokenizer": { "my_hanlp": { "type": "hanlp", "enable_stop_dictionary": true, "enable_custom_config": true } } } } }

POST test/_analyze { "text": "美国,|=阿拉斯加州发生8.0级地震", "analyzer": "my_hanlp_analyzer" }

结果: { "error" : { "root_cause" : [ { "type" : "null_pointer_exception", "reason" : "Cannot invoke \"com.hankcs.hanlp.dictionary.stopword.StopWordDictionary.contains(String)\" because \"com.hankcs.dic.CoreStopWordDictionary.dictionary\" is null" } ], "type" : "null_pointer_exception", "reason" : "Cannot invoke \"com.hankcs.hanlp.dictionary.stopword.StopWordDictionary.contains(String)\" because \"com.hankcs.dic.CoreStopWordDictionary.dictionary\" is null" }, "status" : 500 }

DawnPhantom commented 6 months ago

经过几天的摸索,大概找到一个可能解决的方式: 具体环境:由于我按照网上教程一步一步做,但是用elasticsearch的plugin插件直接install插件的时候会报java.net.UnknownHostException错误并且没找到解决方法,所以是通过直接解压elasticsearch-analysis-hanlp-7.10.1.zip到挂载的文件夹中来添加插件的。 解决方式: 通过搜索elasticsearch-plugins找到容器位置。 image 如图中如果有多个相似的路径,那么路径中带merge的就是要找的。由于本人也是新手,可能会有其他情况未考虑到,请谅解。 把hanlp-remote.xml和hanlp.properties复制到/usr/share/elasticsearch/config/analysis-hanlp/的位置: image image 再把analysis-hanlp整个文件夹复制到plugins下: image 重启容器。 image 现在已经可以了。 由于摸索得实在太痛苦,决定在这个问题下贴一下我的解决方法,希望能帮到电脑不行虚拟机出各种奇奇怪怪的错误而不知道怎么解决的小白