elasticsearch5 插件ik安装

Ik安装文档如下:

1.下载安装包

https://github.com/medcl/elasticsearch-analysis-ik/releases

 wget https://github.com/medcl/elasticsearch-analysis-ik/releases/tag/v5.0.2/elasticsearch-analysis-ik-5.0.2.zip

elasticsearch中创建ik的安装目录

[root@es02 opt]#  mkdir /usr/local/elasticsearch/plugins/ik

[root@es02 opt]# cd  /usr/local/elasticsearch/plugins/ik

[root@es02 ik]# cp /opt/elasticsearch-analysis-ik-5.0.2.zip .

[root@es02 ik]# unzip -x elasticsearch-analysis-ik-5.0.2.zip

[root@es02 ik]#  tree -F -t -L 3

 .
├── commons-codec-1.9.jar
├── commons-logging-1.2.jar
├── config/
│   ├── custom/
│   │   ├── ext_stopword.dic
│   │   ├── mydict.dic
│   │   ├── single_word.dic
│   │   ├── single_word_full.dic
│   │   ├── single_word_low_freq.dic
│   │   └── sougou.dic
│   ├── IKAnalyzer.cfg.xml

│   ├── main.dic
│   ├── preposition.dic
│   ├── quantifier.dic
│   ├── stopword.dic
│   ├── suffix.dic
│   └── surname.dic
├── elasticsearch-analysis-ik-5.0.2.jar
├── elasticsearch-analysis-ik-5.0.2.zip
├── httpclient-4.5.2.jar
├── httpcore-4.4.4.jar
└── plugin-descriptor.properties

 

2.重启elasticsearch 

[elasticsearch@es03 ~]$  su - elasticsearch

[elasticsearch@es02 ~]$  ps aux|grep elasticsearch

502       32614  0.4  2.1 14743052 2845596 ?    Sl   Jan05  77:43 /usr/java/jdk1.8.0_91/bin/java -Xms2g -Xmx2g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -XX:+DisableExplicitGC -XX:+AlwaysPreTouch -server -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -Djdk.io.permissionsUseCanonicalPath=true -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j.skipJansi=true -XX:+HeapDumpOnOutOfMemoryError -Des.path.home=/opt/elasticsearch-5.0.2 -cp /opt/elasticsearch-5.0.2/lib/elasticsearch-5.0.2.jar:/opt/elasticsearch-5.0.2/lib/* org.elasticsearch.bootstrap.Elasticsearch

[elasticsearch@es02 ~]$ kill -9 32614

[elasticsearch@es02 ~]$ cd /opt/elasticsearch-5.0.2/bin/

[elasticsearch@es02 bin]$ ./elasticsearch -d

3.验证ik是否可用

[root@es02 logs]# curl -XGET 'http://es02:9200/_analyze?pretty&analyzer=ik_max_word' -d '联想是全球最大的笔记本厂商'

{
  "tokens" : [
    {
      "token" : "联想",
      "start_offset" : 0,
      "end_offset" : 2,
      "type" : "CN_WORD",
      "position" : 0
    },
    {
      "token" : "全球",
      "start_offset" : 3,
      "end_offset" : 5,
      "type" : "CN_WORD",
      "position" : 1
    },
    {
      "token" : "最大",
      "start_offset" : 5,
      "end_offset" : 7,
      "type" : "CN_WORD",
      "position" : 2
    },
    {
      "token" : "笔记本",
      "start_offset" : 8,
      "end_offset" : 11,
      "type" : "CN_WORD",
      "position" : 3
    },
    {
      "token" : "笔记",
      "start_offset" : 8,
      "end_offset" : 10,
      "type" : "CN_WORD",
      "position" : 4
    },
    {
      "token" : "笔",
      "start_offset" : 8,
      "end_offset" : 9,
      "type" : "CN_WORD",
      "position" : 5
    },
    {
      "token" : "记",
      "start_offset" : 9,
      "end_offset" : 10,
      "type" : "CN_CHAR",
      "position" : 6
    },
    {
      "token" : "本厂",
      "start_offset" : 10,
      "end_offset" : 12,
      "type" : "CN_WORD",
      "position" : 7
    },
    {
      "token" : "厂商",
      "start_offset" : 11,
      "end_offset" : 13,
      "type" : "CN_WORD",
      "position" : 8
    }
  ]
}


[root@es02 logs]# curl -XGET 'http://es02:9200/_analyze?pretty&analyzer=ik_smart' -d '联想是全球最大的笔记本厂商'

{
  "tokens" : [
    {
      "token" : "联想",
      "start_offset" : 0,
      "end_offset" : 2,
      "type" : "CN_WORD",
      "position" : 0
    },
    {
      "token" : "全球",
      "start_offset" : 3,
      "end_offset" : 5,
      "type" : "CN_WORD",
      "position" : 1
    },
    {
      "token" : "最大",
      "start_offset" : 5,
      "end_offset" : 7,
      "type" : "CN_WORD",
      "position" : 2
    },
    {
      "token" : "笔记本",
      "start_offset" : 8,
      "end_offset" : 11,
      "type" : "CN_WORD",
      "position" : 3
    },
    {
      "token" : "厂商",
      "start_offset" : 11,
      "end_offset" : 13,
      "type" : "CN_WORD",
      "position" : 4
    }
  ]
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值