|NO.Z.00007|——————————|Deployment|——|Hadoop&ElasticSearch集中式日志分析系统.v07|——|Elasticsearch.v07|索引管理&IK分词器部署.V1|
一、安装IK分词器
### --- 安装IK分词器
~~~ # hadoop01~03:使用root用户部署IK分词器,然后重启ES服务
~~~ # 在elasticsearch安装目录的plugins目录下新建 analysis-ik 目录
[root@hadoop02 ~]# mkdir /opt/yanqi/servers/es/elasticsearch/plugins/analysis-ik
~~~ # 解压analysis-ik版本包
[root@hadoop02 ~]# cd /opt/yanqi/servers/es/elasticsearch/plugins/analysis-ik
[root@hadoop02 analysis-ik]# unzip elasticsearch-analysis-ik-7.3.0.zip
~~~ # 删除.zip版本包
[root@hadoop02 analysis-ik]# rm -rf elasticsearch-analysis-ik-7.3.0.zip
~~~ # 授予plugin目录所有者为es
[root@hadoop02 plugins]# chown -R es:es analysis-ik/
### --- 分发到其它节点
~~~ # 分发到其它节点
[root@hadoop02 ~]# rsync-script /opt/yanqi/servers/es/elasticsearch/plugins/
二、重启Elasticsearch和Kibana服务
### --- 重启Elasticsearch服务
~~~ # hadoop01~03:使用es用户杀死es服务
[es@hadoop02 ~]$ ps -ef|grep elasticsearch|grep bootstrap |awk '{print $2}' |xargs kill -9
~~~ # hadoop01~03:启动es服务
[es@hadoop02 ~]$ nohup /opt/yanqi/servers/es/elasticsearch/bin/elasticsearch >/dev/null 2>&1 &
### --- 重启kibana服务
~~~ # hadoop02:使用es用户启动kibana服务
[es@hadoop02 ~]$ nohup /opt/yanqi/servers/es/kibana/bin/kibana >/dev/null 2>&1 &
三、IK分词器测试
### --- IK分词器测试
~~~ # IK分词器有两种分词模式:ik_max_word和ik_smart模式。
ik_max_word (常用)
~~~ # 会将文本做最细粒度的拆分
ik_smart
~~~ # 会做最粗粒度的拆分
### --- Kibana测试一:ik_max_word
~~~ # 测试示例:ik_max_word
POST _analyze
{
"analyzer": "ik_max_word",
"text": "南京市长江大桥"
}
~~~ # ik_max_word 分词模式运行得到结果:
{
"tokens" : [
{
"token" : "南京市",
"start_offset" : 0,
"end_offset" : 3,
"type" : "CN_WORD",
"position" : 0
},
{
"token" : "南京",
"start_offset" : 0,
"end_offset" : 2,
"type" : "CN_WORD",
"position" : 1
},
{
"token" : "市长",
"start_offset" : 2,
"end_offset" : 4,
"type" : "CN_WORD",
"position" : 2
},
{
"token" : "长江大桥",
"start_offset" : 3,
"end_offset" : 7,
"type" : "CN_WORD",
"position" : 3
},
{
"token" : "长江",
"start_offset" : 3,
"end_offset" : 5,
"type" : "CN_WORD",
"position" : 4
},
{
"token" : "大桥",
"start_offset" : 5,
"end_offset" : 7,
"type" : "CN_WORD",
"position" : 5
}
]
}
### --- Kibana测试二:ik_smart
~~~ # 测试示例:ik_smart
POST _analyze
{
"analyzer": "ik_smart",
"text": "南京市长江大桥"
}
~~~ # ik_smart分词模式运行得到结果:
~~~ # 如果现在假如江大桥是一个人名,是南京市市长,那么上面的分词显然是不合理的,该怎么办?
{
"tokens" : [
{
"token" : "南京市",
"start_offset" : 0,
"end_offset" : 3,
"type" : "CN_WORD",
"position" : 0
},
{
"token" : "长江大桥",
"start_offset" : 3,
"end_offset" : 7,
"type" : "CN_WORD",
"position" : 1
}
]
}
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
——W.S.Landor
分类:
dov006-elk
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」