地址:https://github.com/medcl/elasticsearch-analysis-ik
#elasticsearch-analysis-ik-1.8.0.zip
1\复制elasticsearch-analysis-ik-1.8.0.zip到hh15的/home/elasticsearch-2.2.0/plugins/ik目录下
#其中ik目录需要手动创建:mkdir ik
修改ik目录的权限
# chown -R username:groupname /home/elasticsearch-2.2.0/plugins/ik
2\群发ik文件夹到hh6和hh17上,同时修改ik目录的权限
#scp -r /home/elasticsearch-2.2.0/plugins/ik/ root@hh16:/home/elasticsearch-2.2.0/plugins/
#scp -r /home/elasticsearch-2.2.0/plugins/ik/ root@hh17:/home/elasticsearch-2.2.0/plugins/
权限修改:
# chown -R username:groupname /home/elasticsearch-2.2.0/plugins/ik
3\在hh15上创建索引和mapping(最好是在刚才创建的username用户上执行以下命令)
#curl -XPUT http://hh15:9200/mytest
curl -XPOST http://hh15:9200/mytest/fulltext/_mapping -d'
{
"fulltext": {
"_all": {
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word",
"term_vector": "no",
"store": "false"
},
"properties": {
"content": {
"type": "string",
"store": "no",
"term_vector": "with_positions_offsets",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word",
"include_in_all": "true",
"boost": 8
}
}
}
}'
4\在hh15上举例
curl -XPOST http://hh15:9200/mytest/fulltext/1 -d'{"content":"美国留给伊拉克的是个烂摊子吗"}'
curl -XPOST http://hh15:9200/mytest/fulltext/2 -d'{"content":"公安部:各地校车将享最高路权"}'
curl -XPOST http://hh15:9200/mytest/fulltext/3 -d'{"content":"中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"}'
curl -XPOST http://hh15:9200/mytest/fulltext/4 -d'{"content":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}'
高亮查询
curl -XPOST http://hh15:9200/mytest/fulltext/_search -d'
{
"query" : { "term" : { "content" : "中国" }},
"highlight" : {
"pre_tags" : ["
"post_tags" : [""],
"fields" : {
"content" : {}
}
}
}
'