zoukankan      html  css  js  c++  java
  • es(elasticsearch)安装IK中文分词器

    IK压缩包下载地址:https://github.com/medcl/elasticsearch-analysis-ik/releases?after=v6.7.0,需要下载对应的版本

    2、下载完成之后,上传到服务器,然后解压到elasticsearch的plugins文件夹下,然后重命名为analysis-ik

    也可以先在别处解压之后,然后重命名,以下代码,每个人可能不一样,根据自己实际的来

    mv elasticsearch-analysis-ik-6.6.2 elasticsearch-6.6.0/plugins/analysis-ik
    

      在这里要注意层级,以下这个IKAnalyzer.cfg.xml文件和plugins文件夹的层级是这样的

    /plugins/analysis-ik/config/IKAnalyzer.cfg.xml
    

      

    然后关闭elasticsearch

    [root@localhost config]# ps -ef|grep elast
    elas+  49202      1  1 18:10 pts/1    00:00:23 /usr/web/java/jdk1.8/bin/java -Xms256m -Xmx256m -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.io.tmpdir=/tmp/elasticsearch-628240789535257481 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=data -XX:ErrorFile=logs/hs_err_pid%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:logs/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=32 -XX:GCLogFileSize=64m -Des.path.home=/usr/web/elasticsearch/elasticsearch-6.6.0 -Des.path.conf=/usr/web/elasticsearch/elasticsearch-6.6.0/config -Des.distribution.flavor=default -Des.distribution.type=tar -cp /usr/web/elasticsearch/elasticsearch-6.6.0/lib/* org.elasticsearch.bootstrap.Elasticsearch -d
    hongzhi+  49216  49202  0 18:10 pts/1    00:00:00 /usr/web/elasticsearch/elasticsearch-6.6.0/modules/x-pack-ml/platform/linux-x86_64/bin/controller
    root      49738   3679  0 18:37 pts/0    00:00:00 grep --color=auto elast
    

      然后杀掉进程

    kill 49202
    

      

    然后切换到普通账号(使用root账号启动会失败)重新启动,进入elasticsearch文件目录的bin文件夹下

    ./elasticsearch
    

      或者后台启动

    nohup ./elasticsearch &
    

      

    如果出现以下报错

    org.elasticsearch.bootstrap.StartupException: java.lang.IllegalArgumentException: Plugin [analysis-ik] was built for Elasticsearch version 6.5.0 but version 6.6.0 is running
    

      

    问题原因

    elasticsearch版本和 ik分词器版本不一致。
    由于我用的elasticsearch时最新版本 6.6.0,而ik分词器master编译出来的是6.5.0

    解决办法

    进入插件目录的分词文件夹下,修改 plugin-descriptor.properties 文件中的

       改为你的elasticsearch版本号,我的是6.6.0

    然后保存退出  使用非root用户重启

    IK提供了两个分词算法ik_smart和ik_max_word,其中ik_smart为最少切分,ik_max_word为最细粒度划分

  • 相关阅读:
    SQLAlchemy Table(表)类方式
    MySQL简单入门
    第四次作业
    第三次随笔
    第二次随笔
    第一次随笔
    第四次随笔
    第三次作业
    第二次随笔
    第一次随笔
  • 原文地址:https://www.cnblogs.com/pxblog/p/12633189.html
Copyright © 2011-2022 走看看