elastic-search单机部署以及中文分词IKAnalyzer安装

前提条件

elasticsearch使用版本5.6.3,须要jdk版本1.8,低于该版本不能使用java

下载

https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.6.3.zipgit

启动

一、进入目录C:\test\es\elasticsearch-5.6.3\bingithub

二、点击elasticsearch.bat便可启动app

 

验证

 

中文分词安装

一、进入目录C:\test\es\elasticsearch-5.6.3\bincurl

二、执行命令elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v5.6.3/elasticsearch-analysis-ik-5.6.3.zipelasticsearch

 

中文分词验证

一、建立分词索引库url

curl -PUT http://localhost:9200/fenci_1/
{
  "mappings": {
    "mynames": {
       "properties": {
            "content": {
                "type": "text",
                "analyzer": "ik_max_word",
                "search_analyzer": "ik_max_word"
            }
        }
    }
  }
} 

二、搜索切词验证spa

ik_max_wordblog

http://192.168.4.131:9201/fenci_1/_analyze?text=中华人民共和国MN&tokenizer=ik_max_word索引

ik_smart

http://localhost:9200/fenci_1/_analyze?text=中华人民共和国MN&tokenizer=ik_smart

三、添加索引数据

curl -XPOST http://localhost:9200/fenci_1/mynames/1 -d'
{"content":"美国留给伊拉克的是个烂摊子吗"}
'
curl -XPOST http://localhost:9200/fenci_1/mynames/2 -d'
{"content":"公安部:各地校车将享最高路权"}
'
curl -XPOST http://localhost:9200/fenci_1/mynames/3 -d'
{"content":"中韩渔警冲突调查:韩警平均天天扣1艘中国渔船"}
'
curl -XPOST http://localhost:9200/fenci_1/mynames/4 -d'
{"content":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}
'

四、搜索

curl -XPOST http://localhost:9200/fenci_1/mynames/_search  -d'
{
    "query" : { "match" : { "content" : "中国" }}
}
相关文章
相关标签/搜索