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

前提条件

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

下载

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

启动

1、进入目录C:\test\es\elasticsearch-5.6.3\bin

2、点击elasticsearch.bat即可启动

 

验证

 

中文分词安装

1、进入目录C:\test\es\elasticsearch-5.6.3\bin

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

 

中文分词验证

1、创建分词索引库

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

2、搜索切词验证

ik_max_word

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

3、添加索引数据

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":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"}
'

4、搜索

curl -XPOST http://localhost:9200/fenci_1/mynames/_search  -d'
{
    "query" : { "match" : { "content" : "中国" }}
}

  

posted on 2017-11-07 15:26  李雷  阅读(297)  评论(0)    收藏  举报

导航