一,安装插件
1,查看已安装的插件:
[lhdop@blog ~]$ curl -X GET "localhost:9200/_cat/plugins?v&s=component"
name component version
2,从命令行安装smartcn分词插件:
[lhdop@blog bin]$ ./elasticsearch-plugin install analysis-smartcn
warning: ignoring JAVA_HOME=/usr/local/soft/jdk-17.0.11; using ES_JAVA_HOME
-> Installing analysis-smartcn
-> Downloading analysis-smartcn from elastic
[=================================================] 100%
-> Installed analysis-smartcn
-> Please restart Elasticsearch to activate any plugins installed
3,smartcn安装到了plugins目录下,查看文件:
[lhdop@blog elasticsearch-8.14.2]$ ls plugins/analysis-smartcn/
analysis-smartcn-8.14.2.jar lucene-analysis-smartcn-9.10.0.jar plugin-descriptor.properties
安装完后,如果想让插件生效,需要重启elasticsearch服务
关闭
[root@blog ~]# kill 260903
启动:
[root@blog ~]# /usr/local/soft/elasticsearch-8.14.2/bin/elasticsearch -d
4,试用smartcn分词,效果不怎么理想,把'海鲜味'给分成了'海'和'鲜味'两个词
[lhdop@blog elasticsearch-8.14.2]$ curl -X GET "localhost:9200/_analyze?pretty" -H 'Content-Type: application/json' -d'
{
"analyzer": "smartcn",
"text": "这是一碗海鲜味方便面"
}
'
{
"tokens" : [
{
"token" : "这",
"start_offset" : 0,
"end_offset" : 1,
"type" : "word",
"position" : 0
},
{
"token" : "是",
"start_offset" : 1,
"end_offset" : 2,
"type" : "word",
"position" : 1
},
{
"token" : "一",
"start_offset" : 2,
"end_offset" : 3,
"type" : "word",
"position" : 2
},
{
"token" : "碗",
"start_offset" : 3,
"end_offset" : 4,
"type" : "word",
"position" : 3
},
{
"token" : "海",
"start_offset" : 4,
"end_offset" : 5,
"type" : "word",
"position" : 4
},
{
"token" : "鲜味",
"start_offset" : 5,
"end_offset" : 7,
"type" : "word",
"position" : 5
},
{
"token" : "方便面",
"start_offset" : 7,
"end_offset" : 10,
"type" : "word",
"position" : 6
}
]
}
5,查看已安装的插件,已经可以看到安装后的smartcn插件了:
[lhdop@blog elasticsearch-8.14.2]$ curl -X GET "localhost:9200/_cat/plugins?v&s=component"
name component version
iZ2zejc9t0hf6pnw6sewrxZ analysis-smartcn 8.14.2
二,删除插件
1,删除前查看插件列表:
[lhdop@blog elasticsearch-8.14.2]$ ./bin/elasticsearch-plugin list
warning: ignoring JAVA_HOME=/usr/local/soft/jdk-17.0.11; using ES_JAVA_HOME
analysis-ik
analysis-smartcn
查看插件目录:
[lhdop@blog elasticsearch-8.14.2]$ ls plugins/
analysis-ik analysis-smartcn
2,删除:
[lhdop@blog elasticsearch-8.14.2]$ ./bin/elasticsearch-plugin remove analysis-smartcn --purge
warning: ignoring JAVA_HOME=/usr/local/soft/jdk-17.0.11; using ES_JAVA_HOME
-> removing [analysis-smartcn]...
3, 删除后查看插件列表:
[lhdop@blog elasticsearch-8.14.2]$ ./bin/elasticsearch-plugin list
warning: ignoring JAVA_HOME=/usr/local/soft/jdk-17.0.11; using ES_JAVA_HOME
analysis-ik
查看插件目录:
[lhdop@blog elasticsearch-8.14.2]$ ls plugins/
analysis-ik
三,查看es版本:
[lhdop@blog ~]$ /usr/local/soft/elasticsearch-8.14.2/bin/elasticsearch --version
warning: ignoring JAVA_HOME=/usr/local/soft/jdk-17.0.11; using ES_JAVA_HOME
Version: 8.14.2, Build: tar/2afe7caceec8a26ff53817e5ed88235e90592a1b/2024-07-01T22:06:58.515911606Z, JVM: 17.0.11
标签:插件,删除,analysis,elasticsearch,offset,8.14,smartcn From: https://www.cnblogs.com/architectforest/p/18295860