IK官网:https://github.com/medcl/elasticsearch-analysis-ik/releases如下图:下载对应版本即可
1、进入elasticsearch安装目录,执行以下命令(elasticsearch-analysis-ik可以下载对应版本):
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.3.1/elasticsearch-analysis-ik-6.3.1.zip
3、使用:查询是要带: -H 'Content-Type: application/json'
curl -X GET 'http://192.168.1.107:9200/_cat/indices?v'
curl -X GET 'http://192.168.1.107:9200/_cat/nodes?v'
curl -X GET 'http://192.168.1.107:9200/_cat/health?v'
curl -XPUT http://localhost:9200/index
curl -XPOST http://localhost:9200/index/fulltext/_mapping -H 'Content-Type:application/json' -d'{ "properties": { "content": { "type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_max_word" } }}'
curl -XPOST http://localhost:9200/index/fulltext/1 -H 'Content-Type:application/json' -d'{"content":"美国留给伊拉克的是个烂摊子吗"}'
curl -XPOST http://localhost:9200/index/fulltext/2 -H 'Content-Type:application/json' -d'{"content":"公安部:各地校车将享最高路权"}'
curl -XPOST http://localhost:9200/index/fulltext/3 -H 'Content-Type:application/json' -d'{"content":"中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"}'
curl -XPOST http://localhost:9200/index/fulltext/4 -H 'Content-Type:application/json' -d'{"content":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}'
curl -XPOST http://localhost:9200/index/fulltext/_search -H 'Content-Type:application/json' -d'{ "query" : { "match" : { "content" : "中国" }}, "highlight" : { "pre_tags" : ["<tag1>", "<tag2>"], "post_tags" : ["</tag1>", "</tag2>"], "fields" : { "content" : {} } }}'
-- Elastic 默认一次返回10条结果,可以通过size字段改变这个设置
curl 'localhost:9200/index/fulltext/_search' -H 'Content-Type: application/json' -d '
"query" : { "match" : { "content" : "中国" }},
curl 'localhost:9200/index/fulltext/_search' -H 'content-Type: application/json' -d '
"query" : { "match" : { "content" : "中国" }},
curl 'localhost:9200/index/fulltext/_search' -H 'content-Type: application/json' -d '
"query" : { "match" : { "content" : "中国 公安" }}
curl 'localhost:9200/index/fulltext/_search' -H 'content-Type: application/json' -d '
{ "match": { "content": "渔船" } },
{ "match": { "content": "中国" } }
向/Index/Type/Id发出 GET 请求,就可以查看这条记录,URL 的参数pretty=true表示以易读的格式返回,found字段表示查询成功,_source字段返回原始记录,如果 Id 不正确,就查不到数据,found字段就是false
curl -XGET localhost:9200/index/fulltext/2?pretty=true
查询所有记录:curl -XGET localhost:9200/index/fulltext/_search?pretty=true
来源:CSDN
作者:Black10086
链接:https://blog.csdn.net/ls_call520/article/details/103898196