适用于 Elasticsearch 的 thulac 分析插件
采用THULAC实现的Elasticsearch中文分词插件。
| Plugin 版本 | ES 版本 | THULAC 版本 | Link |
|---|---|---|---|
| master | 7.x -> master | lite | |
| 7.9.1 | 7.9.1 | lite | 下载 |
| 6.4.1-181027 | 6.4.1 | lite | 下载 |
| 6.4.0-181027 | 6.4.0 | lite | 下载 |
| 6.3.0-181027 | 6.3.0 | lite | 下载 |
| 6.2.0-181027 | 6.2.0 | lite | 下载 |
| 6.1.0-181027 | 6.1.0 | lite | 下载 |
直接下载已经打包好的插件,解压到elasticsearch的plugins目录下即可。
1.编译打包
git clone [email protected]:microbun/elasticsearch-thulac-plugin.git
cd elasticsearch-thulac-plugin
./gradlew release2.安装到elasticsearch
cp build/distributions/elasticsearch-thulac-plugin-7.9.1.zip ${ES_HOME}/plugins
cd ${ES_HOME}/plugins
unzip elasticsearch-thulac-plugin-7.9.1.zip
rm elasticsearch-thulac-plugin-7.9.1.zip解压后在plugins目录下会有一个thulac文件夹。
thulac
|-elasticsearch-thulac-plugin-7.9.1.jar
|-models #算法模型目录
|-plugin-descriptor.properties
|-plugin.xml3.由于THULAC的模型太大,插件中没有包含模型数据,可以在THULAC 下载模型(lite),将模型拷贝到models中。
1.1 使用默认分词方式
curl -H "Content-Type:application/json" -XPUT http://localhost:9200/index -d'
{
"mappings": {
"properties": {
"text": {
"type": "text",
"analyzer": "thulac"
}
}
}
}
'1.2 自定义分词器
…| 参数名称 | 含义 | 值 |
|---|---|---|
| t2s | 将句子从繁体转化为简体。默认:true | false/true |
| filter | 使用过滤器去除一些没有意义的词语,例如“可以”。默认:false | false/true |
| user_dict | 自定义词典路径,每一个词一行,UTF8编码,相对路径和绝对路径.相对路径:userdict.txt 会加载 ${ES_HOME}/plugins/module/userdict.txt文件绝对路径:/home/elasticsearch/userdict.txt默认:userdict.txt |
curl http://localhost:9200/indexcurl -H "Content-Type:application/json" -XPOST http://localhost:9200/index/_analyze -d'
{
"analyzer":"thulac",
"text":"我是中国人"
}
'curl -XDELETE http://localhost:9200/index暂无开放 Issues,或尚未同步最近议题。