天天看點

elasticsearch中配置ik中文分詞器(LINUX)一、安裝ES二、配置ik三、測試

一、安裝ES

二、配置ik

1.下載下傳ik

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

(注意:版本最好與es對應)

2.打包(如果是下載下傳zip,則跳過這一步)

使用maven對下載下傳的es-ik源碼(tar.gz)進行編譯

3.解壓

将壓縮包複制到es安裝目錄下的/plugins/ik目錄下面,然後使用unzip指令解壓

三、測試

1.重新開機es

2.測試 ip/索引/_analyze

{

“analyzer”:“ik_max_word”, //ik_max_word:最細粒度劃分;ik_smart:最少切分

“text”:“公安部:各地校車将享最高路權”

}

我是用的POSTMAN,在頁面也可以直接操作

elasticsearch中配置ik中文分詞器(LINUX)一、安裝ES二、配置ik三、測試

測試結果如下:

{
    "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": 4,
            "end_offset": 6,
            "type": "CN_WORD",
            "position": 3
        },
        {
            "token": "校車",
            "start_offset": 6,
            "end_offset": 8,
            "type": "CN_WORD",
            "position": 4
        },
        {
            "token": "将",
            "start_offset": 8,
            "end_offset": 9,
            "type": "CN_CHAR",
            "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": 12,
            "end_offset": 13,
            "type": "CN_CHAR",
            "position": 8
        },
        {
            "token": "權",
            "start_offset": 13,
            "end_offset": 14,
            "type": "CN_CHAR",
            "position": 9
        }
    ]
}
           

繼續閱讀