|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

 

posted on   yanqi_vip  阅读(24)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· DeepSeek 开源周回顾「GitHub 热点速览」
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

导航

统计

点击右上角即可分享
微信分享提示