• 1.8 Elasticsearch建立IK中文分词器


    IK中文分词器

    Github:https://github.com/medcl/elasticsearch-analysis-ik/releases/tag/v8.2.3

    • zip解压:unzip  elasticsearch-analysis-ik-8.2.3.zip

     unzip elasticsearch-analysis-ik-8.2.3.zip -d /usr/local/elasticsearch-8.2.3/plugins/ik 

     重启ES

     如果启动报错:

     解决办法

    cd /usr/local/elasticsearch-8.4.0/plugins/ik

    vim plugin-descriptor.properties

    修改 plugin-descriptor.properties 文件中 elasticsearch.version=你的ES版本号

    我之前安装的是ES8.4.0但是用上面的方法虽然会解决报错,但是会出现其他的报错。

    所以我将ES降到了ES8.2.3版本。和analysis-ik的分词器版本一致。

    测试中文分词效果

    POST /_analyze
    {
        "analyzer": "ik_max_word",
        "text": "上下班车流量很大"
    }

    演示:

    结果:

     {
        "tokens": [{
                "token": "上下班",
                "start_offset": 0,
                "end_offset": 3,
                "type": "CN_WORD",
                "position": 0
            },
            {
                "token": "上下",
                "start_offset": 0,
                "end_offset": 2,
                "type": "CN_WORD",
                "position": 1
            },
            {
                "token": "下班",
                "start_offset": 1,
                "end_offset": 3,
                "type": "CN_WORD",
                "position": 2
            },
            {
                "token": "班车",
                "start_offset": 2,
                "end_offset": 4,
                "type": "CN_WORD",
                "position": 3
            },
            {
                "token": "车流量",
                "start_offset": 3,
                "end_offset": 6,
                "type": "CN_WORD",
                "position": 4
            },
            {
                "token": "车流",
                "start_offset": 3,
                "end_offset": 5,
                "type": "CN_WORD",
                "position": 5
            },
            {
                "token": "流量",
                "start_offset": 4,
                "end_offset": 6,
                "type": "CN_WORD",
                "position": 6
            },
            {
                "token": "很大",
                "start_offset": 6,
                "end_offset": 8,
                "type": "CN_WORD",
                "position": 7
            }
        ]
    }

  • 相关阅读:
    axios入门
    Persistent data structure 不可变数据结构
    TYFLOW学习23
    【Android】WMS(四)WMS职责
    开发工程师必备————【Day05】UDP协议;进程的并发与并行
    力扣232 - 用栈实现队列【C语言实现】
    【云原生之Docker实战】使用Docker部署Pichome个人相册系统
    Jenkins
    头歌实践平台-数据结构-二叉树及其应用
    文旅元宇宙解决方案|人工智能、虚拟数字人、导览系统深度应用
  • 原文地址:https://blog.csdn.net/Xx13624558575/article/details/126640210