zoukankan      html  css  js  c++  java
  • elasticsearch安装ik模块(中文分词器)

    下载和elasticsearch版本对应的软件包

    wget https://github.com/medcl/elasticsearch-analysis-ik/archive/v5.6.8.zip

    创建ik目录

    cd /data/tools/elasticsearch-5.6.8/plugins/
    mkdir ik

    将文件解压到ik目录下

    unzip elasticsearch-analysis-ik-5.6.8.zip
    cp elasticsearch-analysis-ik-5.6.8/* 、/data/tools/elasticsearch-5.6.8/plugins/ik/

    查看文件:

    [root@xxxx ik]# ll
    总用量 1428
    -rw-r--r-- 1 elasticsearch elasticsearch 263965 7月   2 2015 commons-codec-1.9.jar
    -rw-r--r-- 1 elasticsearch elasticsearch  61829 7月   2 2015 commons-logging-1.2.jar
    drwxr-xr-x 2 elasticsearch elasticsearch   4096 11月 15 2017 config
    -rw-r--r-- 1 elasticsearch elasticsearch  51384 3月   5 15:25 elasticsearch-analysis-ik-5.6.8.jar
    -rw-r--r-- 1 elasticsearch elasticsearch 736658 8月  14 2016 httpclient-4.5.2.jar
    -rw-r--r-- 1 elasticsearch elasticsearch 326724 8月  14 2016 httpcore-4.4.4.jar
    drwxrwxr-x 3 elasticsearch elasticsearch   4096 6月   5 14:35 pinyin
    -rw-r--r-- 1 elasticsearch elasticsearch   2666 3月   5 15:26 plugin-descriptor.propert

    由于IK插件直接是现场jar包,所以重启elasticsearch就可以加载了

    测试:

    curl -XGET 'http://127.0.0.1:9200/_analyze?pretty&analyzer=ik_max_word' -d '联想是全球最大的笔记本厂商'
    {
      "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" : 5,
          "type" : "CN_WORD",
          "position" : 2
        },
        {
          "token" : "最大",
          "start_offset" : 5,
          "end_offset" : 7,
          "type" : "CN_WORD",
          "position" : 3
        },
        {
          "token" : "",
          "start_offset" : 7,
          "end_offset" : 8,
          "type" : "CN_CHAR",
          "position" : 4
        },
        {
          "token" : "笔记本",
          "start_offset" : 8,
          "end_offset" : 11,
          "type" : "CN_WORD",
          "position" : 5
        },
        {
          "token" : "笔记",
          "start_offset" : 8,
          "end_offset" : 10,
          "type" : "CN_WORD",
          "position" : 6
        },
        {
          "token" : "本厂",
          "start_offset" : 10,
          "end_offset" : 12,
          "type" : "CN_WORD",
          "position" : 7
        },
        {
          "token" : "厂商",
          "start_offset" : 11,
          "end_offset" : 13,
          "type" : "CN_WORD",
          "position" : 8
        }
      ]
    }
  • 相关阅读:
    centos 安装netstat
    du 常见的命令
    CentOS7 安装Python3.6.8
    Alpine安装telnet
    TypeError: 'NoneType' object is not callable
    docker中删除dead状态的容器
    监控进程,线程shell脚本
    pyinstaller打包py成exe后音乐文件播放异常pygame.error failed to execute script
    lambda expressions
    Domain logic approaches
  • 原文地址:https://www.cnblogs.com/cangyuefeng/p/9140595.html
Copyright © 2011-2022 走看看