Elasticsearch IK分词插件安装
Elasticsearch IK分词插件安装
Alex插件安装
1 | ### 当前版本elasticsearch-5.5.1 |
创建索引测试分词
- 创建elasticsearch索引
1
curl -XPUT http://localhost:9200/my_index
- 设置索引映射关系制定分词组件
1
2
3
4
5
6
7
8
9
10
11curl -XPOST http://localhost:9200/my_index/fulltext/_mapping -d'
{
"properties": {
"content": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
}
}
}' - 添加测试数据
1
2
3curl -XPOST http://localhost:9200/index/fulltext/1 -d'
{"content":"美国留给伊拉克的是个烂摊子吗"}
'1
2
3curl -XPOST http://localhost:9200/index/fulltext/3 -d'
{"content":"中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"}
'1
2
3curl -XPOST http://localhost:9200/index/fulltext/4 -d'
{"content":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}
' - 查询测试
1
2
3
4
5
6
7
8
9
10
11
12curl -XPOST http://localhost:9200/index/fulltext/_search -d'
{
"query" : { "match" : { "content" : "中国" }},
"highlight" : {
"pre_tags" : ["<tag1>", "<tag2>"],
"post_tags" : ["</tag1>", "</tag2>"],
"fields" : {
"content" : {}
}
}
}
'