2、elasticsearch安装ik中文分词器

elasticsearch-ik中文分词器下载地址:

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

需要注意es版本和ik版本需要安装ik的README.md对比说明进行下载。

 

我当前使用的es是5.6.0那么我需要下载

170216_tuXh_1993676.png

下载完成后解压:

170316_73Vy_1993676.png

直接将解压后的elasticsearch文件夹复制到 es的plugins文件夹里

170504_AnxZ_1993676.png

170522_uESY_1993676.png

完成后启动es

 

验证ik分词器是否生效,使用postman或者curl工具发送

171234_Q1Vb_1993676.png

分词使用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": 3,
            "type": "CN_CHAR",
            "position": 2
        },
        {
            "token": "开源",
            "start_offset": 3,
            "end_offset": 5,
            "type": "CN_WORD",
            "position": 3
        },
        {
            "token": "中国",
            "start_offset": 5,
            "end_offset": 7,
            "type": "CN_WORD",
            "position": 4
        },
        {
            "token": "社区",
            "start_offset": 7,
            "end_offset": 9,
            "type": "CN_WORD",
            "position": 5
        },
        {
            "token": "博客",
            "start_offset": 9,
            "end_offset": 11,
            "type": "CN_WORD",
            "position": 6
        }
    ]
}

分词使用ik_smart的结果

171548_HNit_1993676.png

{
    "tokens": [
        {
            "token": "这里是",
            "start_offset": 0,
            "end_offset": 3,
            "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": 7,
            "end_offset": 9,
            "type": "CN_WORD",
            "position": 3
        },
        {
            "token": "博客",
            "start_offset": 9,
            "end_offset": 11,
            "type": "CN_WORD",
            "position": 4
        }
    ]
}

 

转载于:https://my.oschina.net/u/1993676/blog/1539977

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值