安装es
1、检查java版本,安装java版本至少是1.8以上
java -version
2、新增用户组 用户
groupadd es useradd es -g es -p 123456
3、下载es,并解压,将文件权限赋予es
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.2.2.tar.gz tar -zxvf elasticsearch-5.2.2.tar.gz chown -R es:es elasticsearch-5.2.2
4、修改es配置文件,修改network.host参数为0.0.0.0
vim /config/elasticsearch.yml
5、启动es
./bin/elasticsearch -d
配置ik中文分词器
1、下载对应版本的插件源码,参考github ik。以5.2.2为例,下载 5.2.2 插件
2、解压移动到 es-root/plugins/
3、重启es
4、测试分词器
curl -XPUT http://localhost:9200/index curl -XPOST http://localhost:9200/index/fulltext/_mapping -H 'Content-Type:application/json' -d' { "properties": { "content": { "type": "text", "analyzer": "ik_max_word", "search_analyzer": "ik_max_word" } } }' curl -XPOST http://localhost:9200/index/fulltext/1 -H 'Content-Type:application/json' -d' {"content":"美国留给伊拉克的是个烂摊子吗"} ' curl -XPOST http://localhost:9200/index/fulltext/2 -H 'Content-Type:application/json' -d' {"content":"公安部:各地校车将享最高路权"} ' curl -XPOST http://localhost:9200/index/fulltext/3 -H 'Content-Type:application/json' -d' {"content":"中韩渔警冲突调查:韩警平均每天扣1艘中国渔船"} ' curl -XPOST http://localhost:9200/index/fulltext/4 -H 'Content-Type:application/json' -d' {"content":"中国驻洛杉矶领事馆遭亚裔男子枪击 嫌犯已自首"} '