elasticsearch 8.x 插件安装(四)之简繁体插件

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": "國際"
    }
  }
}
相关推荐
qq_2518364576 小时前
springboot vue3 开发实现 拼豆管理系统
java·开发语言·ai编程
caoerzhong6 小时前
JeeWMS 开源仓库管理系统全景解读:一套 Java WMS 如何把 WMS/OMS/BMS/TMS 装进同一个系统
java·开源
曹牧6 小时前
Java集合框架:List、ArrayList、Map 和 HashMap
java
顾城猿6 小时前
STOMP 协议
java
+VX:Fegn08957 小时前
计算机毕业设计|基于springboot + vue旅游管理系统(源码+数据库+文档)
java·开发语言·vue.js·spring boot·课程设计
需要8267 小时前
MySQL 索引 B+ 树与“查询为什么变慢了
java·spring boot·spring·spring cloud·tomcat
一 乐7 小时前
二手交易平台|基于springboot + vue二手交易平台(源码+数据库+文档)
java·数据库·vue.js·spring boot·小程序
万年咸鱼7 小时前
编译Java源程序
java
Wang's Blog8 小时前
Java 项目实战: 外卖平台-删除分类的关联校验与自定义业务异常
java·服务器·项目开发
hai_android8 小时前
Kotlin / Android 常用函数使用示例手册
android·java·kotlin