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提供的分词是英文分词,对于中文的分词就做的非常不好了 ...
随机推荐
- 盘点:七大.NET著名开源项目
尽管过了相当长的时间,花费了不少资源,微软和.NET社区还是在最近几年加入到了开源运动的阵营中来了,这令人相当惊讶,因为两大阵营一直都是经常对立的.然而,事实是依靠开源,微软社区中的开源开发工具日益发 ...
- 1855: [Scoi2010]股票交易[单调队列优化DP]
1855: [Scoi2010]股票交易 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 1083 Solved: 519[Submit][Status] ...
- 【BZOJ2525】[Poi2011]Dynamite 二分+树形DP
[BZOJ2525][Poi2011]Dynamite Description Byteotian Cave的结构是一棵N个节点的树,其中某些点上面已经安置了炸.药,现在需要点燃M个点上的引线引爆所有 ...
- cocos2dx-draw绘制
[一]:函数 //1.设置绘制颜色 1.ccDrawColor4B("红","绿","蓝","透明"); //2.设 ...
- Spoken English Practice (yesterday) (Look, I just wanted to apologize again for yesterday? It's fine, I know you didn't mean it. / when I say it, I mean it.)
绿色:连读: 红色:略读: 蓝色:浊化: 橙色:弱读 下划线_为浊化 口语蜕变(2017/7/12) ...
- linux 将同后缀名的文件统一移至另一个文件夹
w
- Flask使用日志记录到文件示例
https://www.polarxiong.com/archives/Flask%E4%BD%BF%E7%94%A8%E6%97%A5%E5%BF%97%E8%AE%B0%E5%BD%95%E5%8 ...
- https://zh.cppreference.com 和 https://en.cppreference.com 和 https://cppcon.org/
https://zh.cppreference.comhttps://en.cppreference.com/w/ https://cppcon.org/
- CSS冲突1 要关掉的css在项目内:【material-table】 中 checkbox 点击checkbox无法选中or取消,点击旁边才能选中or取消
CSS优先级: !important > 行内样式 > 内嵌样式|链接外部样式(哪个在后面哪个优先级大) id选择器 > class选择器 > 元素选择器 react中好像还不 ...
- openresty环境搭建问题记录
第一次在mac安装遇到如下问题: 截图: 具体code如下: Sonofelice:bch-flowrouter baidu$ brew install openresty/brew/openrest ...