ElasticSearch(四) ElasticSearch中文分词插件IK的简单测试
先来一个简单的测试
# curl -XPOST "http://192.168.9.155:9200/_analyze?analyzer=standard&pretty" -d 'PHP是世界上最好的语言' //_analyze表示分析分词;analyzer=standard,表示分词方式standard; -d表示测试的一段文字
测试结果
{
"tokens" : [
{
"token" : "php",
"start_offset" : ,
"end_offset" : ,
"type" : "<ALPHANUM>",
"position" :
},
{
"token" : "是",
"start_offset" : ,
"end_offset" : ,
"type" : "<IDEOGRAPHIC>",
"position" :
},
{
"token" : "世",
"start_offset" : ,
"end_offset" : ,
"type" : "<IDEOGRAPHIC>",
"position" :
},
{
"token" : "界",
"start_offset" : ,
"end_offset" : ,
"type" : "<IDEOGRAPHIC>",
"position" :
},
{
"token" : "上",
"start_offset" : ,
"end_offset" : ,
"type" : "<IDEOGRAPHIC>",
"position" :
},
{
"token" : "最",
"start_offset" : ,
"end_offset" : ,
"type" : "<IDEOGRAPHIC>",
"position" :
},
{
"token" : "好",
"start_offset" : ,
"end_offset" : ,
"type" : "<IDEOGRAPHIC>",
"position" :
},
{
"token" : "的",
"start_offset" : ,
"end_offset" : ,
"type" : "<IDEOGRAPHIC>",
"position" :
},
{
"token" : "语",
"start_offset" : ,
"end_offset" : ,
"type" : "<IDEOGRAPHIC>",
"position" :
},
{
"token" : "言",
"start_offset" : ,
"end_offset" : ,
"type" : "<IDEOGRAPHIC>",
"position" :
}
]
}
接下来使用我们的IK
ik 带有两个分词器
ik_max_word :会将文本做最细粒度的拆分;尽可能多的拆分出词语,拼接各种可能的组合 。
ik_smart:会做最粗粒度的拆分;已被分出的词语将不会再次被其它词语占有 。
curl -XPOST "http://192.168.9.155:9200/_analyze?analyzer=ik_smart&pretty" -d 'PHP是世界上最好的语言' //ik_smart方式
{
"tokens" : [
{
"token" : "php",
"start_offset" : ,
"end_offset" : ,
"type" : "ENGLISH",
"position" :
},
{
"token" : "世界上",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
},
{
"token" : "最好",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
},
{
"token" : "语言",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
}
]
}
curl -XPOST "http://192.168.9.155:9200/_analyze?analyzer=ik_max_word&pretty" -d 'PHP是世界上最好的语言' //ik_max_word方式
{
"tokens" : [
{
"token" : "php",
"start_offset" : ,
"end_offset" : ,
"type" : "ENGLISH",
"position" :
},
{
"token" : "世界上",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
},
{
"token" : "世界",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
},
{
"token" : "上",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_CHAR",
"position" :
},
{
"token" : "最好",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
},
{
"token" : "语言",
"start_offset" : ,
"end_offset" : ,
"type" : "CN_WORD",
"position" :
}
]
}
区别很明显~
ElasticSearch(四) ElasticSearch中文分词插件IK的简单测试的更多相关文章
- Elasticsearch如何安装中文分词插件ik
elasticsearch-analysis-ik 是一款中文的分词插件,支持自定义词库. 安装步骤: 1.到github网站下载源代码,网站地址为:https://github.com/medcl/ ...
- ElasticSearch(三) ElasticSearch中文分词插件IK的安装
正因为Elasticsearch 内置的分词器对中文不友好,会把中文分成单个字来进行全文检索,所以我们需要借助中文分词插件来解决这个问题. 一.安装maven管理工具 Elasticsearch 要使 ...
- Elasticsearch安装中文分词插件ik
Elasticsearch默认提供的分词器,会把每一个汉字分开,而不是我们想要的依据关键词来分词.比如: curl -XPOST "http://localhost:9200/userinf ...
- ElasticSearch 中文分词插件ik 的使用
下载 IK 的版本要与 Elasticsearch 的版本一致,因此下载 7.1.0 版本. 安装 1.中文分词插件下载地址:https://github.com/medcl/elasticsearc ...
- 如何在Elasticsearch中安装中文分词器(IK)和拼音分词器?
声明:我使用的Elasticsearch的版本是5.4.0,安装分词器前请先安装maven 一:安装maven https://github.com/apache/maven 说明: 安装maven需 ...
- ElasticSearch-5.0.0安装中文分词插件IK
Install IK 源码地址:https://github.com/medcl/elasticsearch-analysis-ik,git clone下来. 1.compile mvn packag ...
- 如何在Elasticsearch中安装中文分词器(IK+pinyin)
如果直接使用Elasticsearch的朋友在处理中文内容的搜索时,肯定会遇到很尴尬的问题--中文词语被分成了一个一个的汉字,当用Kibana作图的时候,按照term来分组,结果一个汉字被分成了一组. ...
- ElasticSearch搜索引擎安装配置中文分词器IK插件
近几篇ElasticSearch系列: 1.阿里云服务器Linux系统安装配置ElasticSearch搜索引擎 2.Linux系统中ElasticSearch搜索引擎安装配置Head插件 3.Ela ...
- 沉淀再出发:ElasticSearch的中文分词器ik
沉淀再出发:ElasticSearch的中文分词器ik 一.前言 为什么要在elasticsearch中要使用ik这样的中文分词呢,那是因为es提供的分词是英文分词,对于中文的分词就做的非常不好了 ...
随机推荐
- 81、去除标题栏 Activity 和 AppCompatActivity
[Activity ] requestWindowFeature(Window.FEATURE_NO_TITLE); [AppCompatActivity] getSupportActionBar() ...
- Mysql 知识点总结
1.创建数据库 mysqladmin 下面是一个简单的例子,创建名为 yiibai_tutorials1 的数据库. D:\software\mysql--winx64\bin> mysq ...
- WEB安全番外第四篇--关于SQL盲注
一.SQL盲注: 看不到回显的,无法从返回直接读取到数据库内容的对数据的猜解,属于盲注. 二.第一种--基于布尔类型的盲注: 这种很简单,最典型的例子,就是挖SQL注入的时候常用的: ''' http ...
- LeetCode 笔记系列十 Suduko
题目:Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by ...
- Angular2+学习第3篇 基本知识-组件
一.插值表达式 基本用法与ng1一样. 可以使用 Angular 内置的 json 管道,来显示对象信息,管道用来格式化数据 import { Component } from '@angular/c ...
- 第九课——MySQL优化之索引和执行计划
一.创建索引需要关注什么? 1.关注基数列唯一键的数量: 比如性别,该列只有男女之分,所以性别列基数是2: 2.关注选择性列唯一键与行数的比值,这个比值范围在0~1之前,值越小越好: 其实,选择性列唯 ...
- 通过/dev/mem只能访问高端内存以下的内核线性地址空间
http://blog.chinaunix.net/uid-20564848-id-74706.html </proc/iomem和/proc /ioports对应的fops> < ...
- jquery.dragsort.js 实现拖拽过程遇到的问题
.在IE下第一次拖动的时候,被拖动的li元素会不显示,查了很多资料发现是因为在IE中定位出了问题,li标签还在,只是位置计算出错.解决的办法是在li的css样式中position设置为relative ...
- 安装串口设备驱动时遇到 Windows 无法验证此设备所需的驱动程序的数字签名。最近的硬件或软件更改安装的文件可能未正确签名或已损坏,或者可能是来自未知来源的恶意软件. 问题该如何处理?
win7 系统直接在 cmd 命令行中输入以下语句,重启电脑后重新安装驱动即可. BCDEDIT -SET LOADOPTIONS DISABLE_INTEGRITY_CHECKS BCDEDIT - ...
- Hdu 2457 DNA repair (ac自己主动机+dp)
题目大意: 改动文本串的上的字符,使之不出现上面出现的串.问最少改动多少个. 思路分析: dp[i][j]表示如今 i 个字符改变成了字典树上的 j 节点. 然后顺着自己主动机一直转移方程. 注意合法 ...