二、elasticsearch安裝ik中文分詞器

elasticsearch-ik中文分詞器下載地址:git

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

須要注意es版本和ik版本須要安裝ik的README.md對比說明進行下載。json

 

我當前使用的es是5.6.0那麼我須要下載curl

下載完成後解壓:elasticsearch

直接將解壓後的elasticsearch文件夾複製到 es的plugins文件夾裏工具

完成後啓動espost

 

驗證ik分詞器是否生效,使用postman或者curl工具發送url

分詞使用ik_max_wordcode

驗證分詞的結果:token

{
    "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的結果

{
    "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
        }
    ]
}
相關文章
相關標籤/搜索