ES中怎么添加 IK 分词器
发表于:2024-10-02 作者:千家信息网编辑
千家信息网最后更新 2024年10月02日,ES中怎么添加 IK 分词器,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。1.下载IK分词器,一定要注意和ES的版本一致
千家信息网最后更新 2024年10月02日ES中怎么添加 IK 分词器
ES中怎么添加 IK 分词器,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
1.下载IK分词器,一定要注意和ES的版本一致
2 .下载之后放到 ES 的 \plugins 目录下面去 重启 ES 服务
测试:http://localhost:9200/blog1/_analyze
{ "text":"中华人民共和国MN","tokenizer": "ik_max_word"}
结果:
{ "tokens": [ { "token": "中华人民共和国", "start_offset": 0, "end_offset": 7, "type": "CN_WORD", "position": 0 }, { "token": "中华人民", "start_offset": 0, "end_offset": 4, "type": "CN_WORD", "position": 1 }, { "token": "中华", "start_offset": 0, "end_offset": 2, "type": "CN_WORD", "position": 2 }, { "token": "华人", "start_offset": 1, "end_offset": 3, "type": "CN_WORD", "position": 3 }, { "token": "人民共和国", "start_offset": 2, "end_offset": 7, "type": "CN_WORD", "position": 4 }, { "token": "人民", "start_offset": 2, "end_offset": 4, "type": "CN_WORD", "position": 5 }, { "token": "共和国", "start_offset": 4, "end_offset": 7, "type": "CN_WORD", "position": 6 }, { "token": "共和", "start_offset": 4, "end_offset": 6, "type": "CN_WORD", "position": 7 }, { "token": "国", "start_offset": 6, "end_offset": 7, "type": "CN_CHAR", "position": 8 }, { "token": "mn", "start_offset": 7, "end_offset": 9, "type": "ENGLISH", "position": 9 } ]}
ik_max_word 和 ik_smart 什么区别?
ik_max_word: 会将文本做最细粒度的拆分,比如会将"中华人民共和国国歌"拆分为"中华人民共和国,中华人民,中华,华人,人民共和国,人民,人,民,共和国,共和,和,国国,国歌",会穷尽各种可能的组合,适合 Term Query;
ik_smart: 会做最粗粒度的拆分,比如会将"中华人民共和国国歌"拆分为"中华人民共和国,国歌",适合 Phrase 查询。
# 测试分词器GET _analyze{ "analyzer": "ik_smart", "text": "我爱你中国"}GET _analyze{ "analyzer": "ik_max_word", "text": "我爱你中国"}# 存储数据PUT /test3/_doc/1{ "name":"施爷", "age":13, "birth":"2020-07-05"}# 修改数据 (全部修改,birth没有会被删除)PUT /test3/_doc/1{ "name":"施爷222", "age":13}# 修改数据,只会修改name这个属性,别的不会变POST /test3/_doc/1/_update{ "doc":{ "name":"我是用post方式进行了修改" }}# 获取对象结构GET /test3# 通过id来获取文档GET /test3/_doc/1# 查看数据库中全部存储的统计信息GET _cat/indices?v# 删除数据DELETE /test3/_doc/1# 存储,跟新数据PUT /shiye/user/6{ "name":"shiye施爷成绩好", "age":30, "desc":"一看操作猛如虎,一战战绩0-5", "tags":["靓仔","旅游","爬山"]}# 通过id来查询数据GET /shiye/user/A001 # 通过名称搜索 GET /shiye/user/_search?q=name:shiye # 通过构建复杂查询,查询指定属性_source GET /shiye/user/_search { "query": { "match": { "name": "shiye" } }, "_source":["name","desc","age"] }# must查询 相当于 andGET /shiye/user/_search{ "query": { "bool": { "must": [ { "match": { "name": "shiye" } },{ "match": { "name": "施爷" } } ] } }}# should 查询,相当于orGET /shiye/user/_search{ "query": { "bool": { "should": [ { "match": { "name": "shiye" } },{ "match": { "name": "施爷" } } ] } }}# 加上 must+filter GET /shiye/user/_search{ "query": { "bool": { "must": [ { "match": { "name": "shiye" } } ], "filter": { "range": { "age": { "gte": 20, "lte": 40 } } } } }}# 查询 tags 中匹配到山的GET /shiye/user/_search{ "query": { "match": { "tags": "山" } }}#############测试 text,keyword ################ text 可以分词# keyword 不分词# 指定索引各个字段的创建规则PUT testdb{ "mappings": { "properties":{ "name":{ "type":"text" }, "desc":{ "type": "keyword" } } }}# 添加数据PUT testdb/_doc/2{ "name":"武松", "desc":"打老虎"}# 查询GET testdb/_search{ "query": { "match": { "desc": "军事" } }}#查询+高亮GET testdb/_search{ "query": { "match": { "name": "施" } }, "highlight": { "pre_tags": "", "post_tags": "
", "fields": {"name":{}} }}
看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注行业资讯频道,感谢您对的支持。
人民
共和国
中华
查询
数据
中华人民共和国
国歌
共和
存储
测试
人民共和国
华人
属性
我爱
我爱你
粒度
中华人民
中国
帮助
复杂
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
佳木斯向阳区网络安全
鸠鸠互联网科技 海口
包商银行数据库
个人软件开发创新服务
w7服务器管理器系统下载
多个redis数据库库
亚洲电视app无法连接服务器
北京网络技术开发市场报价
后端软件开发英文
扬州营销软件开发培训
c excel插入数据库
网络安全是怎样实现的
sql数据库dfq格式
房子设计图软件开发
连接steam服务器发生问题
服务器中间件应用场景
达芬奇数据库可以建吗
网络安全法规定国家需要
jsp接收数据库数据
帮芒拼服务器
在个人计算机上使用的数据库是
嘉定区常用网络技术服务
数据库保存文本空格
天下数据香港服务器
上海群海网络技术有限公司
win7 更新服务器
数据库创建修改删除表
管理控制台服务器限制与设置
网络技术是哪一类职业
美国网络安全战略典型案例