linux安装elasticsearch

上传安装包到linux,并解压

 进入config目录,有个elasticsearch.yml

 还有些端口什么的,在之前的一篇博客中有关于elasticsearch.yml的详细解释

进入bin目录。

./elasticsearch -d 启动

如果是root启动会报错,前面的博客中有说到

切换到elasearch 用户启动

执行命令:curl 'http://localhost:9200/?pretty'    或者  curl localhost:9200   ,如果出现以下结果,则ok

启动成功后,  curl -XGET -H "Content-Type: application/json"  "http://localhost:9200/_analyze?pretty=true" -d'{"text":"公安部各地校车将享最高路权"}';

 以上结果是没用有分词(默认分词器)的,所以需要安装ik分词器

下载与你的es版本相对应的版本 :https://github.com/medcl/elasticsearch-analysis-ik
 wget https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.4.1/elasticsearch-analysis-ik-6.4.1.zip


#解压
unzip elasticsearch-analysis-ik-6.4.1.zip    解压后的文件放到es的plugins下的ik目录下

完成后重启es

ik_max_word 和 ik_smart 什么区别?

ik_max_word: 会将文本做最细粒度的拆分,比如会将“中华人民共和国国歌”拆分为“中华人民共和国,中华人民,中华,华人,人民共和国,人民,人,民,共和国,共和,和,国国,国歌”,会穷尽各种可能的组合;

ik_smart: 会做最粗粒度的拆分,比如会将“中华人民共和国国歌”拆分为“中华人民共和国,国歌”。

curl -XGET -H "Content-Type: application/json"  "http://localhost:9200/_analyze?pretty=true" -d'{"text":"公安部:各地校车将享最高路权","analyzer": "ik_max_word"}';

原文地址:https://www.cnblogs.com/longyao/p/11775927.html