针对词条查询(TermQuery),查看默认中文分词器的效果:
[itstar@bigdata111 elasticsearch]$ curl -XGET 'http://bigdata111:9200/_analyze?pretty&analyzer=standard' -d '中华人民共和国'
{
"tokens" : [
{
"token" : "中",
"start_offset" : 0,
"end_offset" : 1,
"type" : "<IDEOGRAPHIC>",
"position" : 0
},
{
"token" : "华",
"start_offset" : 1,
"end_offset" : 2,
"type" : "<IDEOGRAPHIC>",
"position" : 1
},
{
"token" : "人",
"start_offset" : 2,
"end_offset" : 3,
"type" : "<IDEOGRAPHIC>",
"position" : 2
},
{
"token" : "民",
"start_offset" : 3,
"end_offset" : 4,
"type" : "<IDEOGRAPHIC>",
"position" : 3
},
{
"token" : "共",
"start_offset" : 4,
"end_offset" : 5,
"type" : "<IDEOGRAPHIC>",
"position" : 4
},
{
"token" : "和",
"start_offset" : 5,
"end_offset" : 6,
"type" : "<IDEOGRAPHIC>",
"position" : 5
},
{
"token" : "国",
"start_offset" : 6,
"end_offset" : 7,
"type" : "<IDEOGRAPHIC>",
"position" : 6
}
]
}
一、IK分词器的安装
1.1 前期准备工作
(1)CentOS联网
配置CentOS能连接外网。Linux虚拟机ping www.baidu.com 是畅通的
(2)jar包准备
1)elasticsearch-analysis-ik-master.zip
(下载地址:https://github.com/medcl/elasticsearch-analysis-ik)
2)apache-maven-3.0.5-bin.tar.gz
1.2 jar包安装
(1)Maven解压、配置 MAVEN_HOME和PATH。
[itstar@bigdata111 software]# tar -zxvf apache-maven-3.0.5-bin.tar.gz -C /opt/module/
[itstar@bigdata111 apache-maven-3.0.5]# sudo vi /etc/profile
<