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提供的分词是英文分词,对于中文的分词就做的非常不好了 ...
 
随机推荐
- oracle数据库查询时间sql
			
select * from cc_picture_info where PICTURE_SOURCE = 3 AND UPLOAD_TIME > to_date('2017-03-29 16:5 ...
 - 安装顺序----------SQL server 2008 r2;VS2008;VS2010;
			
[1]一般先安装了VS2008 再安装SQL server 2008 r2会报错:安装sql server 2008 报错“检查 Microsoft Visual Studio 2008 的早期版本” ...
 - 程序记录2(设置MapID)
			
try{ INIT_PLUG I_MongoDB* i = NEW(MongoDB); /*[注] 若自定义错误消息的数组长度必需指定为MAX_ERROR_SIZE*/ //char errmsg[M ...
 - HDU1536 S-Nim
			
S-Nim Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submi ...
 - android EditText自动弹出和自动关闭软键盘
			
程序进入某个activity直接弹出软键盘,不能直接在OnCreate中设置,必须等View绘制事件完毕才可以弹出,需要用到Timer辅助实现,如果要实现输入的功能,必须让EditText获得焦点. ...
 - APACHE优化参数
			
1.CentOS5.8 x86_64位 采用最小化安装,系统经过了基本优化篇2.apache版本:httpd-2.2.293.源码包存放位置:/home/oldboy/tools4.源码包编译安装位置 ...
 - [iOS微博项目 - 4.6] - 微博配图
			
github: https://github.com/hellovoidworld/HVWWeibo A.微博配图 1.需求 显示原创微博.转发微博的缩略图 4张图使用2x2布局,其他使用3x3布局, ...
 - JUnit4 测试示例
			
1. JUnit4 测试示例 // Calculator.java public class Calculator{ public int add(int a, int b){ return a + ...
 - Linux 2.6 内核阅读笔记 中断和异常
			
2014年7月24日 中断门.陷阱门及中断门 中断是能够禁止的,能够通过告诉PIC停止对某个中断的公布.被禁止的中断是不会丢失的,在解除禁止后又会发送到CPU上. 禁止中断和屏蔽(mask)中断的不同 ...
 - MyEclipse 10的使用技巧
			
默认快捷键 :Shift+Alt+s 然后选择generater getter and setter,这是快捷键.或者右键source里边有 generater getter and setter. ...