采用ELK搭建日志平台,安装elasticsearch中文分词器

1、进入ES安装目录下

复制代码
cd /usr/local/elasticsearch7.17

2、安装

复制代码
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v7.17.7/elasticsearch-analysis-ik-7.17.7.zip

3、查看是否安装成功

复制代码
systemctl restart elasticsearch.service

4、测试

4.1、创建索引---yulongwang

复制代码
curl -XPUT http://localhost:9200/yulongwang?pretty=true

4.2、往索引里面添加数据

复制代码
curl -XPOST http://localhost:9200/yulongwang/_create/1?pretty=true -H 'Content-Type:application/json' -d '{"content":"汪玉龙出生在美丽的中国-安徽省-安庆市-太湖县-小池镇"}'
curl -XPOST http://localhost:9200/yulongwang/_create/2?pretty=true -H 'Content-Type:application/json' -d '{"content":"汪玉龙2012年大专毕业于安徽新华学院-计算机工程学院-计算机应用技术专业"}'
curl -XPOST http://localhost:9200/yulongwang/_create/3?pretty=true -H 'Content-Type:application/json' -d '{"content":"汪玉龙于2011年10月26号进入光宝集团IT咨询部实习,开始使用大学所学的计算机知识做SFL系统开发及SPA维护工作。SFL系统采用的是delphi语言开发,SPA采用的是Java语言开发。"}'
curl -XPOST http://localhost:9200/yulongwang/_create/4?pretty=true -H 'Content-Type:application/json' -d '{"content":"2012年8月18号,由台北科技总部宣布,汪玉龙正式升级成台北科技大陆部技术经理,主要工作是负责台机、富士康、光宝IT咨询部协调管理"}'

4.3、查看结果

复制代码
curl -XPOST http://localhost:9200/yulongwang/_search?pretty=true -H 'Content-Type:application/json' -d '{
"query" : { "match" : { "content" : "光宝" }},
"highlight" : {
"pre_tags" : ["<tag1>", "<tag2>"],
"post_tags" : ["</tag1>", "</tag2>"],
"fields" : {
"content" : {}
}
}
}'

4.4、采用中文分词器查看结果

复制代码
curl -XPUT http://localhost:9200/yulongwang -H 'Content-Type:application/json' -d '{
        "settings" : {
        "index" : {
            "analysis.analyzer.default.type": "ik_max_word"
        }
    }
}'
curl -XPOST http://localhost:9200/yulongwang/_mapping -H 'Content-Type:application/json' -d '{
        "properties": {
            "content": {
                "type": "text",
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_smart"
            }
        }
}'
相关推荐
Elasticsearch21 小时前
从 22.61GB 到 15.63GB:Elasticsearch 9.5 如何用「混合存储」重新定义日志数据库
elasticsearch
Elasticsearch21 小时前
用于自托管 LLM 调优的 vLLM Prometheus 指标:TTFT、KV Cache 和 GPU 利用率
elasticsearch
Sayai1 天前
Elasticsearch 快照备份到 NAS(NFS)实战:SLM 自动化 + 365 天保留策略
elasticsearch·自动化·jenkins
JavaPub-rodert2 天前
写软著 - Copyright Forge Skill 完整闭环改造方案
大数据·elasticsearch·搜索引擎
Elastic 中国社区官方博客2 天前
从建议到修复的 4 个阶段:使用 Elastic Workflows 实现人在回路中的自动化
运维·数据库·人工智能·后端·elasticsearch·ai·自动化
Elasticsearch2 天前
使用 OpenTelemetry 进行 Android 应用监控:从点击到后端的分布式追踪
elasticsearch
诗词在线2 天前
《江东文学发展史》,东吴文风,和中原文坛有什么不同
中文分词
Elasticsearch2 天前
安心睡过凌晨 3 点的告警:在 Red Hat OpenShift 上使用 Elastic 实现自动化故障事件响应
elasticsearch
Elasticsearch3 天前
将 1,100 个文件迁移到 Redux Toolkit v2,同时避免冻结 Kibana 单体仓库
elasticsearch
Elasticsearch3 天前
从 582 毫秒的延迟峰值追踪到负责该服务的团队:使用 Kibana Discover
elasticsearch