ElasticSearch6.x插件之IK分词器

IK分词器插件下载地址:git地址

1.下载并安装IK插件

首先下载es对应版本的ik分词器的zip包,上传到es服务器上,在es的安装目录下有一个plugins的目录,在这个目录下创建一个叫ik的目录
然后将解压好的内容,拷贝到ik目录
将ik目录拷贝到其他的es节点
重新启动所有的es

2.使用

#创建索引名字叫news
curl -H "Content-Type: application/json" -XPUT http://192.168.177.11:9200/news

#创建mapping(相当于数据中的schema信息,表名和字段名以及字段的类型)
curl -H "Content-Type: application/json" -XPOST http://192.168.177.11:9200/news/fulltext/_mapping -d'
{
        "properties": {
            "content": {
                "type": "text",
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_max_word"
            }
        }
    
}'


curl -H "Content-Type: application/json" -XPOST http://192.168.177.11:9200/news/fulltext/1 -d'
{"content":"美国留给伊拉克的是个烂摊子吗"}'

curl -H "Content-Type: application/json" -XPOST http://192.168.177.11:9200/news/fulltext/2 -d'
{"content":"公安部:各地校车将享最高路权"}'

curl -H "Content-Type: application/json" -XPOST http://192.168.177.11:9200/news/fulltext/3 -d'
{"content":"中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"}'

curl -H "Content-Type: application/json" -XPOST http://192.168.177.11:9200/news/fulltext/4 -d'
{"content":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}'

curl -H "Content-Type: application/json" -XPOST http://192.168.177.11:9200/news/fulltext/_search  -d'
{
    "query" : { "match" : { "content" : "中国" }},
    "highlight" : {
        "pre_tags" : ["", ""],
        "post_tags" : ["", ""],
        "fields" : {
            "content" : {}
        }
    }
}'

curl -H "Content-Type: application/json" -XGET 'http://192.168.177.11:9200/_analyze' -d'
{
    "analyzer" : "ik_max_word"
    "text":"联想是全球最大的笔记本厂商"
}'

 

你可能感兴趣的:(ElasticSearch)