Elasticsearch学习笔记——分词
1.测试Elasticsearch的分词
Elasticsearch有多种分词器(参考:https://www.jianshu.com/p/d57935ba514b)
Set the shape to semi-transparent by calling set_trans(5)
(1)standard analyzer:标准分词器(默认是这种)
set,the,shape,to,semi,transparent by,calling,set_trans,5
(2)simple analyzer:简单分词器
set, the, shape, to, semi, transparent, by, calling, set, trans
(3)whitespace analyzer:空白分词器。大小写,下划线等都不会转换
Set, the, shape, to, semi-transparent, by, calling, set_trans(5)
(4)language analyzer:(特定语言分词器,比如说English英语分瓷器)
set, shape, semi, transpar, call, set_tran, 5
2.为Elasticsearch的index设置分词
这样就将这个index里面的所有type的分词设置成了simple
PUT my_index
{
"settings": {
"analysis": {
"analyzer": {"default":{"type":"simple"}}
}
}
}
http://localhost:9200/_analyze?analyzer=standard&pretty=true&text=test测试
分词结果
{
"tokens" : [
{
"token" : "test",
"start_offset" : 0,
"end_offset" : 4,
"type" : "<ALPHANUM>",
"position" : 0
},
{
"token" : "测",
"start_offset" : 4,
"end_offset" : 5,
"type" : "<IDEOGRAPHIC>",
"position" : 1
},
{
"token" : "试",
"start_offset" : 5,
"end_offset" : 6,
"type" : "<IDEOGRAPHIC>",
"position" : 2
}
]
}
简单分词器 : simple analyzer
http://localhost:9200/_analyze?analyzer=simple&pretty=true&text=test_测试
结果
{
"tokens" : [
{
"token" : "test",
"start_offset" : 0,
"end_offset" : 4,
"type" : "word",
"position" : 0
},
{
"token" : "测试",
"start_offset" : 5,
"end_offset" : 7,
"type" : "word",
"position" : 1
}
]
}
IK分词器 : ik_max_word analyzer 和 ik_smart analyzer
首先需要安装
https://github.com/medcl/elasticsearch-analysis-ik
下zip包,然后使用install plugin进行安装,我机器上的es版本是5.6.10,所以安装的就是5.6.10
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.6.10/elasticsearch-analysis-ik-5.6.10.zip
然后重新启动Elasticsearch就可以了
进行测试
http://localhost:9200/_analyze?analyzer=ik_max_word&pretty=true&text=test_tes_te测试
结果
{
"tokens" : [
{
"token" : "test_tes_te",
"start_offset" : 0,
"end_offset" : 11,
"type" : "LETTER",
"position" : 0
},
{
"token" : "test",
"start_offset" : 0,
"end_offset" : 4,
"type" : "ENGLISH",
"position" : 1
},
{
"token" : "tes",
"start_offset" : 5,
"end_offset" : 8,
"type" : "ENGLISH",
"position" : 2
},
{
"token" : "te",
"start_offset" : 9,
"end_offset" : 11,
"type" : "ENGLISH",
"position" : 3
},
{
"token" : "测试",
"start_offset" : 11,
"end_offset" : 13,
"type" : "CN_WORD",
"position" : 4
}
]
}
Elasticsearch学习笔记——分词的更多相关文章
- elasticsearch学习笔记——相关插件和使用场景
logstash-input-jdbc学习 ES(elasticsearch缩写)的一大优点就是开源,插件众多.所以扩展起来非常的方便,这也造成了它的生态系统越来越强大.这种开源分享的思想真是与天朝格 ...
- ElasticSearch学习笔记(超详细)
文章目录 初识ElasticSearch 什么是ElasticSearch ElasticSearch特点 ElasticSearch用途 ElasticSearch底层实现 ElasticSearc ...
- Elasticsearch学习笔记一
Elasticsearch Elasticsearch(以下简称ES)是一款Java语言开发的基于Lucene的高效全文搜索引擎.它提供了一个分布式多用户能力的基于RESTful web接口的全文搜索 ...
- ElasticSearch学习笔记(一)-- 查询索引分词
# 查看所有索引 GET _cat/indices # 创建一个索引 PUT /test_index # 插入一条数据(指定id)PUT /test_index/doc/ { "userna ...
- elasticsearch学习笔记-倒排索引以及中文分词
我们使用数据库的时候,如果查询条件太复杂,则会涉及到很多问题 1.无法维护,各种嵌套查询,各种复杂的查询,想要优化都无从下手 2.效率低下,一般语句复杂了之后,比如使用or,like %,,%查询之后 ...
- Elasticsearch学习笔记
Why Elasticsearch? 由于需要提升项目的搜索质量,最近研究了一下Elasticsearch,一款非常优秀的分布式搜索程序.最开始的一些笔记放到github,这里只是归纳总结一下. 首先 ...
- 2018/2/13 ElasticSearch学习笔记三 自动映射以及创建自动映射模版,ElasticSearch聚合查询
终于把这些命令全敲了一遍,话说ELK技术栈L和K我今天花了一下午全部搞定,学完后还都是花式玩那种...E却学了四天(当然主要是因为之前上班一直没时间学,还有安装服务时出现的各种error真是让我扎心了 ...
- 2018/2/11 ELK技术栈之ElasticSearch学习笔记二
终于有时间记录一下最近学习的知识了,其实除了写下的这些还有很多很多,但懒得一一写下了: ElasticSearch添加修改删除原理:ElasticSearch的倒排索引和文档一旦生成就不允许修改(其实 ...
- 【原】无脑操作:ElasticSearch学习笔记(01)
开篇来自于经典的“保安的哲学三问”(你是谁,在哪儿,要干嘛) 问题一.ElasticSearch是什么?有什么用处? 答:截至2018年12月28日,从ElasticSearch官网(https:// ...
随机推荐
- [leetcode] 329. Longest Increasing Path in a Matrix My Submissions Question
在递归调用的函数中使用了max = INT_MIN,结果报超时错误,改为max=0就对了,虽然在这题中最小就为0, 看来在之后最小为0的时候,就不要使用INT_MIN了.
- innerHTML innerText与outerHTML间的区别
innerHTML与innerText及outerHTML间的区别最容易使初学者搞混淆,为了更好的使读者区分开.下面我就通过一个demo来解释: 代码: <!DOCTYPE html>&l ...
- 将Django部署到Linux
https://cloud.tencent.com/developer/labs/lab/10372
- 【最短路】道路重建 @upcexam5797
时间限制: 1 Sec 内存限制: 128 MB 题目描述 小L的家乡最近遭遇了一场洪水,城市变得面目全非,道路也都被冲毁了.生活还要继续,于是市政府决定重建城市中的道路. 在洪水到来前,城市中共有n ...
- Linux Performance Profiling & Visualization
https://github.com/figozhang/CLK/tree/master/CLK2016 http://www.linuxep.com/
- java 规则引擎资料汇集
1. ibm的developworks中较早的一篇关于规则引擎的文章 https://www.ibm.com/developerworks/cn/java/j-java-rules/ 2. 一篇硕士论 ...
- MAC终端密钥登录自动输入密码
升级MAC系统后,发现用于MAC终端ssh服务器的登录脚本无法正常执行了,表现为:需要手动输入密钥密码,于是重新整理一下,恢复正常,在此记录一下: #!/usr/bin/expect -fspawn ...
- IE中的console.log
部分情况下,IE中如果控制台没有开启,打印console.log可能会报错,一下为兼容方案: if(window.console && console.log) { console.l ...
- Asp.Net Core获取请求上下文HttpContext
注:特别说明当前版本对应.Net Core2.1意义上框架 一.注入HttpContextAccessor ASP.NET Core中提供了一个IHttpContextAccessor接口,HttpC ...
- Centos7 设置、查看、添加、删除服务的开机启动项
查看开机启动项 systemctl list-unit-files | grep enable 为服务添加开机启动项 systemctl enable zabbix-server.service ...