ES安装中文IK分词器
之前自己一个人折腾ES的时候,安装IK分词器都会失败,以为没有8.x的支持,只有7.x的版本。其实不是,这里将步骤记录下来。
1,访问IK分词器项目地址
查看相应的Readme内容,当前已经支持到ES 8.4.1版本,也就是说一直在更新。
readme
2, 安装方式选择
有两种,安装都比较简单,可以任意选择一种。
3, 选择elasticsearch plug命令的方式安装。
查看具体ES版本对应的IK分词器链接地址。通过这个link查看:
例如我现在需要安装针对ES8.1.0的
拷贝下link地址以备后用。
登录ES服务器,使用elasticsearch-plugin命令安装:
[es@localhost ~]$ cd /app/es/bin/
[es@localhost bin]$ ./elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.1.0/elasticsearch-analysis-ik-8.1.0.zip
-> Installing https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.1.0/elasticsearch-analysis-ik-8.1.0.zip
-> Downloading https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v8.1.0/elasticsearch-analysis-ik-8.1.0.zip
[=================================================] 100%
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: plugin requires additional permissions @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.net.SocketPermission * connect,resolve
See https://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.
Continue with installation? [y/N]y
-> Installed analysis-ik
-> Please restart Elasticsearch to activate any plugins installed
重启ES
安装完成。
4,使用IK分词器。
自 v5.0.0 起移除名为 ik 的analyzer和tokenizer,请分别使用 ik_smart 和 ik_max_word
下面我使用官方的实例进行测试。
1.create a index
[es@localhost bin]$ curl -H "Content-Type:application/json" --cacert /app/es/config/certs/http_ca.crt -u elastic:elastic123 -XPUT "https://192.168.88.8:9200/index"
{"acknowledged":true,"shards_acknowledged":true,"index":"index"}
2.create a mapping
curl -H "Content-Type:application/json" --cacert /app/es/config/certs/http_ca.crt -u elastic:elastic123 -XPOST "https://192.168.88.8:9200/index/_mapping" -d'
{
"properties": {
"content": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
}
}
}'
如果有"analyzer [ik_smart] has not been configured in mappings"的报错,要注意,如果是ES集群,需要每个集群都安装IK分词器。我只在一个节点运行了,因此我在节点2上也运行ik分词器的安装:
最后,需要重启ES才能将安装的插件生效。
3.index some docs
curl -H "Content-Type:application/json" --cacert /app/es/config/certs/http_ca.crt -u elastic:elastic123 -XPOST https://192.168.88.8:9200/index/_create/1 -d'
{"content":"内容参考github上的原文"}
'
curl -H "Content-Type:application/json" --cacert /app/es/config/certs/http_ca.crt -u elastic:elastic123 -XPOST https://192.168.88.8:9200/index/_create/2 -d'
{"content":"内容参考github上的原文"}
'
curl -H "Content-Type:application/json" --cacert /app/es/config/certs/http_ca.crt -u elastic:elastic123 -XPOST https://192.168.88.8:9200/index/_create/3 -d'
{"content":"内容参考github上的原文"}
'
curl -H "Content-Type:application/json" --cacert /app/es/config/certs/http_ca.crt -u elastic:elastic123 -XPOST https://192.168.88.8:9200/index/_create/4 -d'
{"content":"中内容参考github上的原文"}
'
4.query with highlighting
curl -H "Content-Type:application/json" --cacert /app/es/config/certs/http_ca.crt -u elastic:elastic123 -XPOST https://192.168.88.8:9200/index/_search -d'
{
"query" : { "match" : { "content" : "内容参考github上的原文" }},
"highlight" : {
"pre_tags" : ["<tag1>", "<tag2>"],
"post_tags" : ["</tag1>", "</tag2>"],
"fields" : {
"content" : {}
}
}
}
'
输出结果:
如果嫌上面的输出格式不清楚,可以使用Kibana的Dev Tools进行查询:
ES安装中文IK分词器相关推荐
- Elasticsearch8.4.3安装最新ik分词器elasticsearch-analysis-ik【v8.4.3版本】(参考官方文档)
一.前言 ik分词器官方源码版下载地址: https://github.com/medcl/elasticsearch-analysis-ik ik分词器官方发行版下载地址: ht ...
- solr两种安装、ik分词器设置、DIH导入mysql数据
文章目录 solr 安装(内置方式) solr 安装(tomcat方式) IK中文分词器设置 solr数据操作 使用dataimport导入数据库数据 solr 安装(内置方式) 安装包 官网下载安装 ...
- docker之es+es-head+kibana+ik分词器安装
一.es 第一步:搜索 docker search elasticsearch 第二步:下载镜像 第三步:创建数据文件夹和配置文件 宿主服务器创建文件夹 mkdir -p /docker/es1/da ...
- elasticsearch-7.15.2 同时支持中文ik分词器和pinyin分词器
文章目录 1. 自定义分词器 2. 映射模型 3. 效果图 1. 自定义分词器 ES如何支持拼音和中文分词 ? 自定义分词器 支持拼音和中文分词 PUT /jd_goods {"settin ...
- Elasticsearch 中文IK分词器
Elasticsearch实战 step1 前往https://github.com/medcl/elasticsearch-analysis-ik下载如下插件 step2 es的plugins目录下 ...
- ES语法及-IK分词器
{"query": {"query_string": {"default_field": "title",//全文搜索& ...
- elasticsearch IK分词器的安装、使用与扩展
ES 的默认分词器(standard)不支持中文分词,满足不了平时的需求,所以需要用能够支持中文分词的 IK 分词器.而且 IK 分词器也是支持英文分词的. 本文介绍下IK分词器的安装.基本使用方法: ...
- ES入门学习:ElasticSearch、Kibana、ik分词器的安装、简单使用及SpringBoot集成
前言 es是采用Java语言开发,因此,想要安装运行es需要提前准备好jdk环境,关于linux配置jdk在前文linux配置jdk 本文主要介绍es的安装.kibana的安装和简单使用及ik分词器的 ...
- ElasticSearch入门简介、安装ES(安装Kibana和IK分词器)使用 Postman连接ES进行测、ESRestAPI(操作索引CRUD操作文档CRUD)、练习
要理解倒排索引 要能够使用DSL命令操作索引库 要能够使用DSL命令操作文档 要能够使用RestAPI操作索引库.文档 一.ES简介 理解倒排索引的概念和作用 理解es和MySql的区别和使用场景 1 ...
- Elasticsearch入门之从零开始安装ik分词器
起因 需要在ES中使用聚合进行统计分析,但是聚合字段值为中文,ES的默认分词器对于中文支持非常不友好:会把完整的中文词语拆分为一系列独立的汉字进行聚合,显然这并不是我的初衷.我们来看个实例: POST ...
最新文章
- 第六章 非编码RNA鉴定
- 智能车竞赛技术报告 | 全向行进组 - 沈阳工业大学 - 找不到北队
- java 获取聚合vo_NC57聚合VO写法
- LOJ#2230. 「BJOI2014」大融合
- python必读5本书籍_免费下载!5本从Python入手机器学习的必备电子书!(附链接)...
- 浅拷贝+引用计数--写时拷贝---模拟实现string容器
- 【Python学习】内置函数(不断更新)
- 微信公众号——永久素材的上传
- gevent开发http服务器与tcp服务器(WSGIServer、StreamServer)
- Ubuntu ibus 输入法之Skype不能输入中文
- 2018年北京市POI数据各类型POI
- WINCE 矩阵键盘 介绍
- csb反编译_GitHub - lyzz0612/csb2csd: cocostudio csb反编成csd
- osgearth加载倾斜摄影数据
- pycharm如何设置官方中文?pycharm如何汉化?pycharm终于支持官中了!!!
- js html body onload,动态添加页面body OnLoad事件的简单js代码
- 分析一种简单的提高功率因数的电路——填谷电路
- Linux 运维安全策略(一)
- 艾粽飘香,空相古寺钟声扬
- iOS 在地图上绘制运动轨迹