elasticsearch 8.x 插件安装(四)之简繁体插件
elasticsearch插件安装合集
elasticsearch插件安装(一)之ik分词器安装(含MySQL更新)
elasticsearch 8.x插件(二)之同义词安装如何解决jdk权限问题
elasticsearch插件安装(二)之dynamic-synonym插件
elasticsearch 8.x 插件安装(三)之拼音插件
elasticsearch 8.x 插件安装(四)之简繁体插件
es 分词器(五)之elasticsearch-analysis-jieba 8.7.0
elasticsearch 8.x 插件安装(六)之Hanlp插件
一、拉取代码
代码地址:https://github.com/infinilabs/analysis-stconvert
二、打包插件
打开pom文件,将elasticsearch.version修改为需要的版本,此处修改为8.7.0。
在elasticsearch/target/release目录下会找到对应版本的插件
三、安装插件
将压缩包解压并复制到es plugins目录下,然后重启es。
四、验证插件
4.1 创建索引
json
PUT /stconvert/
{
"settings" : {
"analysis" : {
"analyzer" : {
"tsconvert" : {
"tokenizer" : "tsconvert"
}
},
"tokenizer" : {
"tsconvert" : {
"type" : "stconvert",
"delimiter" : "#",
"keep_both" : false,
"convert_type" : "t2s"
}
},
"filter": {
"tsconvert" : {
"type" : "stconvert",
"delimiter" : "#",
"keep_both" : false,
"convert_type" : "t2s"
}
},
"char_filter" : {
"tsconvert" : {
"type" : "stconvert",
"convert_type" : "t2s"
}
}
}
}
}
4.2 搜索
json
GET stconvert/_analyze
{
"tokenizer" : "keyword",
"filter" : ["lowercase"],
"char_filter" : ["tsconvert"],
"text" : "国际國際"
}
Output:
{
"tokens": [
{
"token": "国际国际",
"start_offset": 0,
"end_offset": 4,
"type": "word",
"position": 0
}
]
}
4.3 简繁体互搜
json
DELETE index
PUT index
{
"settings": {
"analysis": {
"char_filter": {
"tsconvert": {
"type": "stconvert",
"convert_type": "t2s"
}
},
"normalizer": {
"my_normalizer": {
"type": "custom",
"char_filter": [
"tsconvert"
],
"filter": [
"lowercase"
]
}
}
}
},
"mappings": {
"properties": {
"foo": {
"type": "keyword",
"normalizer": "my_normalizer"
}
}
}
}
PUT index/_doc/1
{
"foo": "國際"
}
PUT index/_doc/2
{
"foo": "国际"
}
GET index/_search
{
"query": {
"term": {
"foo": "国际"
}
}
}
GET index/_search
{
"query": {
"term": {
"foo": "國際"
}
}
}