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

    1. 分词器的安装

    ./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.2.3/elasticsearch-analysis-ik-6.2.3.zip
    

    NOTE: replace 6.2.3 to your own elasticsearch version

    github上面的地址

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

    需要注意安装的版本和对应的elasticsearch相匹配

    使用方法:

    1> 在ElasticSearch的配置文件config/elasticsearch.yml中的最后一行添加参数 index.analysis.analyzer.default.type: ik,则设置所有索引的默认分词器为ik分词。

    2> 也可以通过设置mapping来使用ik分词

    2. IK分词器的两种分词模式。

    1> ik_max_word: 会将文本做最细粒度的拆分,比如会将"北京邮电大学"拆分,会穷尽各种可能的组合;

    {
        "tokens":[
            {
                "token":"北京邮电",
                "start_offset":0,
                "end_offset":4,
                "type":"CN_WORD",
                "position":0
            },
            {
                "token":"北京",
                "start_offset":0,
                "end_offset":2,
                "type":"CN_WORD",
                "position":1
            },
            {
                "token":"邮电大学",
                "start_offset":2,
                "end_offset":6,
                "type":"CN_WORD",
                "position":2
            },
            {
                "token":"邮电",
                "start_offset":2,
                "end_offset":4,
                "type":"CN_WORD",
                "position":3
            },
            {
                "token":"电大",
                "start_offset":3,
                "end_offset":5,
                "type":"CN_WORD",
                "position":4
            },
            {
                "token":"大学",
                "start_offset":4,
                "end_offset":6,
                "type":"CN_WORD",
                "position":5
            }
        ]
    }
    

    2> ik_smart: 会做最粗粒度的拆分

    {
        "tokens":[
            {
                "token":"北京",
                "start_offset":0,
                "end_offset":2,
                "type":"CN_WORD",
                "position":0
            },
            {
                "token":"邮电大学",
                "start_offset":2,
                "end_offset":6,
                "type":"CN_WORD",
                "position":1
            }
        ]
    }
    
  • 相关阅读:
    监听器模式
    接口幂等性实现
    如何设计一个良好的API接口
    接口重试实现
    Spring不常用但有用的注解
    angular项目语言切换功能
    解决IOS上传竖向照片会旋转90度的问题
    微信点击链接:debugx5.qq.com提示您使用的不是x5内核
    swagger注释@API详细说明
    创建swap虚拟内存分区
  • 原文地址:https://www.cnblogs.com/redirect/p/10066786.html
Copyright © 2011-2022 走看看