当前位置: 首页 > article >正文

es 安装ik分词器

下载

Index of: analysis-ik/stable/

查找对应版本下载

安装

将压缩包上传到服务器es安装路径下plugin目录,如我的安装在/usr/local下。

在plugin下新建analysis-ik文件夹,将zip文件解压到analysis-ik目录下.

修改目录及目录下所有文件的用户和用户组,chown -R /usr/local/elasticsearch

重启es

找到elasticsearch的bin文件,使用./elasticsearch启动,可以看到类似输出。

使用./elasticsearch -d代表后台启动

校验

找到elasticsearch的bin文件,使用./elasticsearch-plugin list 查看

或者在可视化客户端,执行

 索引字段设置ik分词器

注意:如果此索引已存在数据,则不能通过次方式修改分词器

PUT /esb-m-produce-logs-000029/_mapping

{

  "properties": {

    "msgContent": {

      "type": "text",

      "analyzer": "ik_max_word",

      "search_analyzer": "ik_smart"

    }

  }

}

可选方式:

1.删除并重新创建索引

如果你可以删除现有的索引并重新创建它,这是最简单的方法。请注意,这将导致所有现有数据丢失。

DELETE /your_index

PUT /your_index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "ik_max_word": {
          "type": "ik_max_word"
        },
        "ik_smart": {
          "type": "ik_smart"
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "msgContent": {
        "type": "text",
        "analyzer": "ik_max_word",
        "search_analyzer": "ik_smart"
      }
    }
  }
}

2. 使用新的索引和重索引数据

如果不能删除现有索引,你可以创建一个新索引,并将数据从旧索引重索引到新索引。

PUT /new_index
{
  "settings": {
    "analysis": {
      "analyzer": {
        "ik_max_word": {
          "type": "ik_max_word"
        },
        "ik_smart": {
          "type": "ik_smart"
        }
      }
    }
  },
  "mappings": {
    "properties": {
      "msgContent": {
        "type": "text",
        "analyzer": "ik_max_word",
        "search_analyzer": "ik_smart"
      }
    }
  }
}

POST /_reindex
{
  "source": {
    "index": "old_index"
  },
  "dest": {
    "index": "new_index"
  }
}

3. 更新映射(仅适用于某些情况)

在某些情况下,你可能能够更新映射而不会导致冲突。这通常适用于添加新的字段或更新非冲突的设置。然而,对于更改现有字段的分词器,这种方法可能不适用。

4. 使用别名(Alias)

如果你不想删除旧索引,可以使用别名来切换到新索引。首先创建新索引并重索引数据,然后将别名指向新索引。

POST /_aliases
{
  "actions": [
    { "remove": { "index": "old_index", "alias": "my_alias" }},
    { "add":    { "index": "new_index", "alias": "my_alias" }}
  ]
}


http://www.kler.cn/a/572108.html

相关文章:

  • Spring Bean 作用域设置为prototype在并发场景下是否是线程安全的
  • 【第14节】C++设计模式(行为模式)-Strategy (策略)模式
  • http 状态码秒记速查(附速记口诀)
  • 【redis】redis持久化
  • 京东Hive SQL面试题实战:APP路径分析场景解析与幽默生存指南
  • 爬虫:一文掌握 Celery 分布式爬虫,及对应实战案例
  • 【应急响应工具教程】一款自动化分析网络安全应急响应工具--FindAll
  • ArcGIS操作:12 矢量shp属性筛选并导出
  • 盛元广通中小型科技创新实验室LIMS系统
  • 基于SpringBoot+Vue的医院挂号管理系统+LW示例参考
  • DeepSeek 助力 Vue3 开发:打造丝滑的表格(Table)示例2: 分页和排序
  • Python----数据分析(Matplotlib三:绘图二:箱图,散点图,饼图,热力图,3D图)
  • anolis8.9-k8s1.32-系统基本配置
  • Tomcat原理:HTTP协议与HTTPS协议
  • FastGPT 源码:RRF、Rerank 相关代码
  • Spring Boot 中短时间连续请求时出现Cookie获取异常问题
  • uniapp+vue3搭建项目
  • 【powerjob】 powerjobserver注册服务IP错误
  • .h264/.h265文件 前端直接播放
  • 2 Redis 字符串(String) 命令大全