国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Elasticsearch07:ES中文分詞插件(es-ik)安裝部署

這篇具有很好參考價值的文章主要介紹了Elasticsearch07:ES中文分詞插件(es-ik)安裝部署。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

一、ES中文分詞插件(es-ik)

在中文數(shù)據(jù)檢索場景中,為了提供更好的檢索效果,需要在ES中集成中文分詞器,因為ES默認是按照英文的分詞規(guī)則進行分詞的,基本上可以認為是單字分詞,對中文分詞效果不理想。

ES之前是沒有提供中文分詞器的,現(xiàn)在官方也提供了一些,但是在中文分詞領(lǐng)域,IK分詞器是不可撼動的,所以在這里我們主要講一下如何在ES中集成IK這個中文分詞器。

1、下載

首先下載es-ik插件,需要到github上下載。

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

Elasticsearch07:ES中文分詞插件(es-ik)安裝部署
Elasticsearch07:ES中文分詞插件(es-ik)安裝部署
最終的下載地址為:

https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.13.4/elasticsearch-analysis-ik-7.13.4.zip

百度網(wǎng)盤地址:

鏈接:https://pan.baidu.com/s/1KgBGetSvLpIUPtDz5fUM5Q?pwd=eh35 
提取碼:eh35 

注意:在ES中安裝IK插件的時候,需要在ES集群的所有節(jié)點中都安裝。

2、上傳

將下載好的elasticsearch-analysis-ik-7.13.4.zip上傳到bigdata01的/data/soft/ elasticsearch-7.13.4目錄中。

[root@bigdata01 elasticsearch-7.13.4]# ll elasticsearch-analysis-ik-7.13.4.zip 
-rw-r--r--. 1 root root 4504502 Sep  3  2021 elasticsearch-analysis-ik-7.13.4.zip

3、遠程拷貝到其他節(jié)點

將elasticsearch-analysis-ik-7.13.4.zip遠程拷貝到bigdata02和bigdata03上。

[root@bigdata01 elasticsearch-7.13.4]# scp -rq elasticsearch-analysis-ik-7.13.4.zip  bigdata02:/data/soft/elasticsearch-7.13.4
[root@bigdata01 elasticsearch-7.13.4]# scp -rq elasticsearch-analysis-ik-7.13.4.zip  bigdata03:/data/soft/elasticsearch-7.13.4

4、安裝

在bigdata01節(jié)點離線安裝IK插件。

[root@bigdata01 elasticsearch-7.13.4]# bin/elasticsearch-plugin install file:///data/soft/elasticsearch-7.13.4/elasticsearch-analysis-ik-7.13.4.zip 

注意:在安裝的過程中會有警告信息提示需要輸入y確認繼續(xù)向下執(zhí)行。

[=================================================] 100%   
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@     WARNING: plugin requires additional permissions     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
* java.net.SocketPermission * connect,resolve
See http://docs.oracle.com/javase/8/docs/technotes/guides/security/permissions.html
for descriptions of what these permissions allow and the associated risks.

Continue with installation? [y/N]y

最后看到如下內(nèi)容就表示安裝成功了。

-> Installed analysis-ik
-> Please restart Elasticsearch to activate any plugins installed

注意:插件安裝成功之后在elasticsearch-7.13.4的config和plugins目錄下會產(chǎn)生一個analysis-ik目錄。

config目錄下面的analysis-ik里面存儲的是ik的配置文件信息。

[root@bigdata01 elasticsearch-7.13.4]# cd config/
[root@bigdata01 config]# ll analysis-ik/
total 8260
-rwxrwxrwx. 1 root root 5225922 Feb 27 20:57 extra_main.dic
-rwxrwxrwx. 1 root root   63188 Feb 27 20:57 extra_single_word.dic
-rwxrwxrwx. 1 root root   63188 Feb 27 20:57 extra_single_word_full.dic
-rwxrwxrwx. 1 root root   10855 Feb 27 20:57 extra_single_word_low_freq.dic
-rwxrwxrwx. 1 root root     156 Feb 27 20:57 extra_stopword.dic
-rwxrwxrwx. 1 root root     625 Feb 27 20:57 IKAnalyzer.cfg.xml
-rwxrwxrwx. 1 root root 3058510 Feb 27 20:57 main.dic
-rwxrwxrwx. 1 root root     123 Feb 27 20:57 preposition.dic
-rwxrwxrwx. 1 root root    1824 Feb 27 20:57 quantifier.dic
-rwxrwxrwx. 1 root root     164 Feb 27 20:57 stopword.dic
-rwxrwxrwx. 1 root root     192 Feb 27 20:57 suffix.dic
-rwxrwxrwx. 1 root root     752 Feb 27 20:57 surname.dic

plugins目錄下面的analysis-ik里面存儲的是ik的核心jar包。

[root@bigdata01 elasticsearch-7.13.4]# cd plugins/
[root@bigdata01 plugins]# ll analysis-ik/
total 1428
-rwxrwxrwx. 1 root root 263965 Feb 27 20:56 commons-codec-1.9.jar
-rwxrwxrwx. 1 root root  61829 Feb 27 20:56 commons-logging-1.2.jar
-rwxrwxrwx. 1 root root  54626 Feb 27 20:56 elasticsearch-analysis-ik-7.13.4.jar
-rwxrwxrwx. 1 root root 736658 Feb 27 20:56 httpclient-4.5.2.jar
-rwxrwxrwx. 1 root root 326724 Feb 27 20:56 httpcore-4.4.4.jar
-rwxrwxrwx. 1 root root   1807 Feb 27 20:56 plugin-descriptor.properties
-rwxrwxrwx. 1 root root    125 Feb 27 20:56 plugin-security.policy

5、在bigdata02節(jié)點離線安裝IK插件

[root@bigdata02 elasticsearch-7.13.4]# bin/elasticsearch-plugin install file:///data/soft/elasticsearch-7.13.4/elasticsearch-analysis-ik-7.13.4.zip 

6、在bigdata03節(jié)點離線安裝IK插件

[root@bigdata03 elasticsearch-7.13.4]# bin/elasticsearch-plugin install file:///data/soft/elasticsearch-7.13.4/elasticsearch-analysis-ik-7.13.4.zip 

7、如果集群正在運行,則需要停止集群

在bigdata01上停止。

[root@bigdata01 elasticsearch-7.13.4]# jps
1680 Elasticsearch
2047 Jps
[root@bigdata01 elasticsearch-7.13.4]# kill 1680

在bigdata02上停止。

[root@bigdata02 elasticsearch-7.13.4]# jps
1682 Elasticsearch
1866 Jps
[root@bigdata02 elasticsearch-7.13.4]# kill 1682

在bigdata03上停止。

[root@bigdata03 elasticsearch-7.13.4]# jps
1683 Elasticsearch
1803 Jps
[root@bigdata03 elasticsearch-7.13.4]# kill 1683

8、修改目錄權(quán)限

修改elasticsearch-7.13.4的plugins目錄下analysis-ik子目錄的權(quán)限
直接修改elasticsearch-7.13.4目錄的權(quán)限即可。

在bigdata01上執(zhí)行。

[root@bigdata01 elasticsearch-7.13.4]# cd ..
[root@bigdata01 soft]# chmod -R 777 elasticsearch-7.13.4

在bigdata02上執(zhí)行。

[root@bigdata02 elasticsearch-7.13.4]# cd ..
[root@bigdata02 soft]# chmod -R 777 elasticsearch-7.13.4

在bigdata03上執(zhí)行。

[root@bigdata03 elasticsearch-7.13.4]# cd ..
[root@bigdata03 soft]# chmod -R 777 elasticsearch-7.13.4

9、重新啟動ES集群

在bigdata01上執(zhí)行。

[root@bigdata01 soft]# su es
[es@bigdata01 soft]$ cd /data/soft/elasticsearch-7.13.4
[es@bigdata01 elasticsearch-7.13.4]$ bin/elasticsearch -d

在bigdata02上執(zhí)行。

[root@bigdata02 soft]# su es
[es@bigdata02 soft]$ cd /data/soft/elasticsearch-7.13.4
[es@bigdata02 elasticsearch-7.13.4]$ bin/elasticsearch -d

在bigdata03上執(zhí)行。

[root@bigdata03 soft]# su es
[es@bigdata03 soft]$ cd /data/soft/elasticsearch-7.13.4
[es@bigdata03 elasticsearch-7.13.4]$ bin/elasticsearch -d

10、驗證IK的分詞效果

首先使用默認分詞器測試中文分詞效果。

[root@bigdata01 soft]# curl -H "Content-Type: application/json" -XPOST  'http://bigdata01:9200/emp/_analyze?pretty' -d '{"text":"我們是中國人"}'
{
  "tokens" : [
    {
      "token" : "我",
      "start_offset" : 0,
      "end_offset" : 1,
      "type" : "<IDEOGRAPHIC>",
      "position" : 0
    },
    {
      "token" : "們",
      "start_offset" : 1,
      "end_offset" : 2,
      "type" : "<IDEOGRAPHIC>",
      "position" : 1
    },
    {
      "token" : "是",
      "start_offset" : 2,
      "end_offset" : 3,
      "type" : "<IDEOGRAPHIC>",
      "position" : 2
    },
    {
      "token" : "中",
      "start_offset" : 3,
      "end_offset" : 4,
      "type" : "<IDEOGRAPHIC>",
      "position" : 3
    },
    {
      "token" : "國",
      "start_offset" : 4,
      "end_offset" : 5,
      "type" : "<IDEOGRAPHIC>",
      "position" : 4
    },
    {
      "token" : "人",
      "start_offset" : 5,
      "end_offset" : 6,
      "type" : "<IDEOGRAPHIC>",
      "position" : 5
    }
  ]
}

然后使用IK分詞器測試中文分詞效果。

[root@bigdata01 soft]# curl -H "Content-Type: application/json" -XPOST  'http://bigdata01:9200/emp/_analyze?pretty' -d '{"text":"我們是中國人","tokenizer":"ik_max_word"}'
{
  "tokens" : [
    {
      "token" : "我們",
      "start_offset" : 0,
      "end_offset" : 2,
      "type" : "CN_WORD",
      "position" : 0
    },
    {
      "token" : "是",
      "start_offset" : 2,
      "end_offset" : 3,
      "type" : "CN_CHAR",
      "position" : 1
    },
    {
      "token" : "中國人",
      "start_offset" : 3,
      "end_offset" : 6,
      "type" : "CN_WORD",
      "position" : 2
    },
    {
      "token" : "中國",
      "start_offset" : 3,
      "end_offset" : 5,
      "type" : "CN_WORD",
      "position" : 3
    },
    {
      "token" : "國人",
      "start_offset" : 4,
      "end_offset" : 6,
      "type" : "CN_WORD",
      "position" : 4
    }
  ]
}

在這里我們發(fā)現(xiàn)分出來的單詞里面有一個 是,這個單詞其實可以認為是一個停用詞,在分詞的時候是不需要切分出來的。
在這被切分出來了,那也就意味著在進行停用詞過濾的時候沒有過濾掉。

針對ik這個詞庫而言,它的停用詞詞庫里面都有哪些單詞呢?

[root@bigdata01 elasticsearch-7.13.4]# cd config/analysis-ik/
[root@bigdata01 analysis-ik]# ll
total 8260
-rwxrwxrwx. 1 root root 5225922 Feb 27 20:57 extra_main.dic
-rwxrwxrwx. 1 root root   63188 Feb 27 20:57 extra_single_word.dic
-rwxrwxrwx. 1 root root   63188 Feb 27 20:57 extra_single_word_full.dic
-rwxrwxrwx. 1 root root   10855 Feb 27 20:57 extra_single_word_low_freq.dic
-rwxrwxrwx. 1 root root     156 Feb 27 20:57 extra_stopword.dic
-rwxrwxrwx. 1 root root     625 Feb 27 20:57 IKAnalyzer.cfg.xml
-rwxrwxrwx. 1 root root 3058510 Feb 27 20:57 main.dic
-rwxrwxrwx. 1 root root     123 Feb 27 20:57 preposition.dic
-rwxrwxrwx. 1 root root    1824 Feb 27 20:57 quantifier.dic
-rwxrwxrwx. 1 root root     164 Feb 27 20:57 stopword.dic
-rwxrwxrwx. 1 root root     192 Feb 27 20:57 suffix.dic
-rwxrwxrwx. 1 root root     752 Feb 27 20:57 surname.dic
[root@bigdata01 analysis-ik]# more stopword.dic 
a
an
and
are
as
at
be
but
by
for
if
in
into
is
it
no
not
of
on
or

ik的停用詞詞庫是stopword.dic這個文件,這個文件里面目前都是一些英文停用詞。
我們可以手工在這個文件中把中文停用詞添加進去,先添加 是 這個停用詞。

[root@bigdata01 analysis-ik]# vi stopword.dic 
.....
是

然后把這個文件的改動同步到集群中的所有節(jié)點上。

[root@bigdata01 analysis-ik]# scp -rq stopword.dic bigdata02:/data/soft/elasticsearch-7.13.4/config/analysis-ik/
[root@bigdata01 analysis-ik]# scp -rq stopword.dic bigdata03:/data/soft/elasticsearch-7.13.4/config/analysis-ik/

重啟集群讓配置生效。
先停止bigdata01、bigdata02、bigdata03上的ES服務(wù)。

[root@bigdata01 analysis-ik]# jps
3051 Elasticsearch
3358 Jps
[root@bigdata01 analysis-ik]# kill 3051

[root@bigdata02 analysis-ik]$ jps
2496 Elasticsearch
2570 Jps
[root@bigdata02 analysis-ik]$ kill 2496

[root@bigdata03 analysis-ik]$ jps
2481 Jps
2412 Elasticsearch
[root@bigdata03 analysis-ik]$ kill 2412

啟動bigdata01、bigdata02、bigdata03上的ES服務(wù)。

[es@bigdata01 elasticsearch-7.13.4]$ bin/elasticsearch -d

[es@bigdata02 elasticsearch-7.13.4]$ bin/elasticsearch -d

[es@bigdata03 elasticsearch-7.13.4]$ bin/elasticsearch -d

再使用IK分詞器測試一下中文分詞效果。

[root@bigdata01 analysis-ik]# curl -H "Content-Type: application/json" -XPOST  'http://bigdata01:9200/test/_analyze?pretty' -d '{"text":"我們是中國人","tokenizer":"ik_max_word"}'
{
  "tokens" : [
    {
      "token" : "我們",
      "start_offset" : 0,
      "end_offset" : 2,
      "type" : "CN_WORD",
      "position" : 0
    },
    {
      "token" : "中國人",
      "start_offset" : 3,
      "end_offset" : 6,
      "type" : "CN_WORD",
      "position" : 1
    },
    {
      "token" : "中國",
      "start_offset" : 3,
      "end_offset" : 5,
      "type" : "CN_WORD",
      "position" : 2
    },
    {
      "token" : "國人",
      "start_offset" : 4,
      "end_offset" : 6,
      "type" : "CN_WORD",
      "position" : 3
    }
  ]
}

此時再查看會發(fā)現(xiàn)沒有"是" 這個單詞了,相當(dāng)于在過濾停用詞的時候把它過濾掉了。文章來源地址http://www.zghlxwxcb.cn/news/detail-435155.html

到了這里,關(guān)于Elasticsearch07:ES中文分詞插件(es-ik)安裝部署的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • es安裝中文分詞器 IK

    es安裝中文分詞器 IK

    1.下載 https://github.com/medcl/elasticsearch-analysis-ik 這個是官方的下載地址,下載跟自己es版本對應(yīng)的即可 那么需要下載 7.12.0版本的分詞器 2.安裝 1.在es的 plugins 的文件夾下先創(chuàng)建一個ik目錄 bash cd /home/apps/elasticsearch/plugins/ mkdir ik 2.然后將下載解壓后的文件放入到ik文件夾下 3.重啟

    2024年02月21日
    瀏覽(21)
  • docker-compose安裝es以及ik分詞同義詞插件

    docker-compose安裝es以及ik分詞同義詞插件

    目錄 1 前言 2 集成利器Docker 2.1 Docker環(huán)境安裝 2.1.1 環(huán)境檢查 2.1.2 在線安裝 2.1.3 離線安裝 2.2 Docker-Compose的安裝 2.2.1 概念簡介 2.2.2 安裝步驟 2.2.2.1 二進制文件安裝 2.2.2.2 離線安裝 2.2.2.3 yum安裝 3 一鍵安裝ES及Kibana 3.1 yml文件的編寫 3.1.1 elasticsearch.yml配置 3.1.2 kibana.yml配置 3.2 一鍵

    2024年04月23日
    瀏覽(24)
  • 搜索引擎elasticsearch :安裝elasticsearch (包含安裝組件kibana、IK分詞器、部署es集群)

    搜索引擎elasticsearch :安裝elasticsearch (包含安裝組件kibana、IK分詞器、部署es集群)

    kibana可以幫助我們方便地編寫DSL語句,所以還要裝kibana 因為我們還需要部署kibana容器,因此需要讓es和kibana容器互聯(lián)。這里先創(chuàng)建一個網(wǎng)絡(luò): 這里我們采用elasticsearch的7.12.1版本的鏡像,這個鏡像體積非常大,接近1G。不建議大家自己pull。 課前資料提供了鏡像的tar包: 大家將

    2024年02月16日
    瀏覽(26)
  • Docker安裝ElasticSearch、Kibana、IK分詞器以及設(shè)置ES賬戶密碼

    Docker安裝ElasticSearch、Kibana、IK分詞器以及設(shè)置ES賬戶密碼

    版本聲明: 系統(tǒng) :CentOS 7.9(云服務(wù)器) ES版本 :7.6.1 Kibana :7.6.1 Ik分析器版本 :7.6.1 1、拉取鏡像 2、創(chuàng)建掛載目錄 設(shè)置所有用戶讀寫執(zhí)行權(quán)限 : sudo chmod -R 777 /docker_config/elasticsearch/ 3、創(chuàng)建elasticsearch.yml 配置文件 4、創(chuàng)建容器 參數(shù)說明 : -p 端口映射 -e discovery.type=single

    2023年04月09日
    瀏覽(34)
  • Linux下安裝ElasticSearch-analysis-ik中文分詞器插件,以及可能出現(xiàn)的異常處理

    Linux下安裝ElasticSearch-analysis-ik中文分詞器插件,以及可能出現(xiàn)的異常處理

    ? ? ? ? 注意:安裝可以采用在線方式、離線方式,但是不建議在線安裝,速度超級慢,本文只介紹離線安裝方式 ? ? ? ? ????????下載地址:https://github.com/medcl/elasticsearch-analysis-ik ? ? ? ? ? ? ? ? 切記選擇版本需要跟ElasticSearch保持一致,否則可能會出現(xiàn)一些未知的異

    2024年02月07日
    瀏覽(35)
  • ElasticSearch的使用,安裝ik分詞器,自定義詞庫,SpringBoot整合ES(增、刪、改、查)

    ElasticSearch的使用,安裝ik分詞器,自定義詞庫,SpringBoot整合ES(增、刪、改、查)

    保存一個數(shù)據(jù),保存在哪個索引的哪個類型下,指定用哪個唯一標(biāo)識(相當(dāng)于,保存一個數(shù)據(jù),保存在那個數(shù)據(jù)庫中的哪個表中,指定主鍵ID) 例:PUT customer/external/1;在customer索引下的external類型下保存1號數(shù)據(jù)name為John Doe的數(shù)據(jù) POST和PUT都可以新增數(shù)據(jù) 注意: POST 新增。如果

    2023年04月25日
    瀏覽(59)
  • es筆記四之中文分詞插件安裝與使用

    es筆記四之中文分詞插件安裝與使用

    本文首發(fā)于公眾號:Hunter后端 原文鏈接:es筆記四之中文分詞插件安裝與使用 前面我們介紹的操作及演示都是基于英語單詞的分詞,但我們大部分使用的肯定都是中文,所以如果需要使用分詞的操作肯定也是需要使用中分分詞。 這里我們介紹一下如何安裝中文分詞插件。 在

    2024年02月05日
    瀏覽(21)
  • Elasticsearch安裝分詞插件[ES系列] - 第499篇

    Elasticsearch安裝分詞插件[ES系列] - 第499篇

    歷史文章( 文章 累計490+) 《 國內(nèi)最全的Spring?Boot系列之一 》 《 國內(nèi)最全的Spring?Boot系列之二 》 《 國內(nèi)最全的Spring?Boot系列之三 》 《 國內(nèi)最全的Spring?Boot系列之四 》 《 國內(nèi)最全的Spring?Boot系列之 五 》 《 國內(nèi)最全的Spring?Boot系列之六 》 ElasticSearch應(yīng)用場景以及技術(shù)

    2024年02月02日
    瀏覽(22)
  • elasticsearch 安裝 IK 中文分詞器插件提示找不到文件的異常(Exception in thread “main“ java.nio.file.NoSuchFileException)

    elasticsearch 安裝 IK 中文分詞器插件提示找不到文件的異常(Exception in thread “main“ java.nio.file.NoSuchFileException)

    錯誤截圖 在命令行窗口,執(zhí)行如下命令安裝 IK 中文分詞器 失敗。 錯誤日志 1、自己到github下載對應(yīng)版本的ik中文分詞器 上面命令中兩個插件版本號應(yīng)該和 Elasticsearch 的版本保持一致,我現(xiàn)在用的是 7.14.1 版本。 首先版本和命令是對得上的。 命令行窗口通過命令下載失敗的話

    2024年04月11日
    瀏覽(29)
  • es安裝ik分詞器

    es安裝ik分詞器

    IK分詞器下載地址: https://github.com/medcl/elasticsearch-analysis-ik/releases 下載ES版本對應(yīng)的分詞器即可 安裝ik分詞器 將下載好的zip包解壓,生成一個ik文件夾 將ik文件夾移動到ES安裝目錄下的 plugins 文件夾下(每臺ES節(jié)點都要執(zhí)行相同的操作) 重啟ES集群 自定義分詞庫 用 vim 在ik中的

    2023年04月10日
    瀏覽(19)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包