zoukankan      html  css  js  c++  java
  • 为Elasticsearch添加中文分词

    Elasticsearch的中文分词很烂,所以我们需要安装ik。首先从github上下载项目,解压:

    1. cd /tmp
    2. wget https://github.com/medcl/elasticsearch-analysis-ik/archive/master.zip
    3. unzip master.zip
    4. cd elasticsearch-analysis-ik/

    然后使用mvn package 命令,编译出jar包 elasticsearch-analysis-ik-1.4.0.jar。

    1. mvn package

    将jar包复制到Elasticsearch的plugins/analysis-ik 目录下,再把解压出的ik目录(配置和词典等),复制到Elasticsearch的config 目录下。然后编辑配置文件elasticsearch.yml ,在后面加一行:

      index.analysis.analyzer.ik.type : "ik"

    重启service elasticsearch restart 。搞定

    准备工作:创建索引,录入测试数据

    先为后面的分词器效果对比做好准备,我的Elasticsearch部署在虚拟机 192.168.159.159:9200 上的,使用chrome的postman插件直接发http请求。第一步,创建index1 索引:

  • 相关阅读:
    cf C. Vasya and Robot
    zoj 3805 Machine
    cf B. Vasya and Public Transport
    cf D. Queue
    cf C. Find Maximum
    cf B. Two Heaps
    cf C. Jeff and Rounding
    cf B. Jeff and Periods
    cf A. Jeff and Digits
    I Think I Need a Houseboat
  • 原文地址:https://www.cnblogs.com/ytfcz/p/4275639.html
Copyright © 2011-2022 走看看