安装elasticsearch-analysis-ik

ik的github地址:https://github.com/medcl/elasticsearch-analysis-ik

查看elasticsearch版本: http://vm188:9200/

这里写图片描述

在ES_HOME下
命令安装

./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.5.1/elasticsearch-analysis-ik-5.5.1.zip

打开VM188:5601的kibana

#新建index
PUT /china
POST /china/fulltext/_mapping 
{
        "properties": {
            "content": {
                "type": "text",
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_max_word"
            }
        }

}


POST /china/fulltext/1
{

  "content":"美国留给伊拉克的是个烂摊子吗"
}

POST /china/fulltext/2
{

  "content":"公安部:各地校车将享最高路权"
}


POST /china/fulltext/3
{

"content":"中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"
}

POST /china/fulltext/4
{
  "content":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"

}


##调用search
GET /china/fulltext/_search

这里写图片描述

尝试搜索调用

POST /china/fulltext/_search
{
  "query" : {
    "match" : { "content" : "中国伊拉克"     }
  }
}

可以看到es搜索评分结果
这里写图片描述

猜你喜欢

转载自blog.csdn.net/baifanwudi/article/details/79514760
今日推荐