1、安装java环境

先查看环境是否安装

yum list installed |grep java

如果存在自带的环境则卸载

yum -y remove java-1.7.-openjdk*

查看安装包

yum -y list java*

安装java1.8

yum -y install java-1.8.-openjdk*

2、安装ES

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.4.2.tar.gz
tar -xvf elasticsearch-6.4..tar.gz
cd elasticsearch-6.4.
如果需要则设置内存

vim  config/jvm.options
默认为:    -Xms1g
默认为: -Xmx1g

添加用户

//添加用户组 elsearch
groupadd elsearch
//添加用户 elsearch 密码为 elasticsearch 到用户组 elsearch
useradd elsearch -g elsearch -p elasticsearch
//将elsearch安装目录授权给 用户组:用户
chown -R elsearch:elsearch ../elasticsearch-6.4.

切换用户并启动ES

su elsearch
cd /usr/local/elasticsearch-6.4.
bin/elasticsearch
如果第一次启动没问题,可以bin/elasticsearch -d 后台启动

3、运行测试

curl -X GET localhost:

出现

{
"name" : "qBx0xRG",
"cluster_name" : "elasticsearch",
"cluster_uuid" : "o-GjxaRZT_qHVj-V3DRxWw",
"version" : {
"number" : "6.4.2",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "04711c2",
"build_date" : "2018-09-26T13:34:09.098244Z",
"build_snapshot" : false,
"lucene_version" : "7.4.0",
"minimum_wire_compatibility_version" : "5.6.0",
"minimum_index_compatibility_version" : "5.0.0"
},
"tagline" : "You Know, for Search"
}

表示成功

4、安装Ik中文分词插件

cd elasticsearch-6.4.2
在线安装:
./bin/elasticsearch-plugin install https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.4.2/elasticsearch-analysis-ik-6.4.2.zip
离线安装:
1、下载https://github.com/medcl/elasticsearch-analysis-ik/releases/download/v6.4.2/elasticsearch-analysis-ik-6.4.2.zip
2、在elasticsearch-6.4.2/plugin目录创建ik目录,将zip文件传进去
3、解压zip文件
4、重启elasticsearch
bin/elasticsearch-plugin list //查看ik插件是否安装成功 看到analysis-ik 则为成功


5、常用方法
创建索引
curl -XPUT http://localhost:9200/test_index  
查看索引
curl http://localhost:9200/test_index?pretty
添加表头
curl -H'Content-Type: application/json' -XPUT http://localhost:9200/test_index/_mapping/_doc?pretty -d'{
"properties": {
"title": { "type": "text", "analyzer": "ik_smart" },
"description": { "type": "text", "analyzer": "ik_smart" },
"price": { "type": "scaled_float", "scaling_factor": }
}
}'
创建索引时需制定analyzer与search_analyzer为ik_max_word,中文分词
这里需要注意的是 analyzer, IK插件目前只支持两种: ik_max_word 和ik_smart,
ik_max_word: 会将文本做最细粒度的拆分,比如会将“中华人民共和国国歌”拆分为“中华人民共和国,中华人民,中华,华人,人民共和国,人民,人,民,共和国,共和,和,国国,国歌”,会穷尽各种可能的组合;
ik_smart : 会做最粗粒度的拆分,比如会将“中华人民共和国国歌”拆分为“中华人民共和国,国歌”。
添加数据
curl -H'Content-Type: application/json' -XPUT http://localhost:9200/test_index/_doc/1?pretty -d'{
"title": "iPhone X",
"description": "新品到货",
"price":
}'
 
 

最新文章

  1. linux NFS 配置步骤
  2. jpa和hibernate注解
  3. uC/OS-II内核的服务文件
  4. JavaScript 回调函数中的 return false 问题
  5. Android Studio集成SVN报错:can't use subversion command line client : svn
  6. 敏捷BI——岂止于快
  7. JavaScript == VS ===
  8. Jquery+Jquery-easyui的倒计时
  9. freemarker list (长度,遍历,下标,嵌套,排序)
  10. JavaScript 获取 Div 的坐标
  11. struts2第一个程序的详解(配图)
  12. 【转贴】 Flex 预编译处理 与 手机项目、Web项目、Air项目自由转换
  13. php mysql语句预编译(preparestatement)
  14. 七、Servlet概述
  15. jQuery筛选器常用总结
  16. jenkins 结合 jmeter 的报告篇
  17. 第16月第6天 vs2005 lseek directdraw
  18. 51Nod 1001 数组中和等于K的数对
  19. oracle11g的安装
  20. 关于centos7中使用rpm方式安装mysql5.7版本后无法使用root登录的问题

热门文章

  1. BZOJ4570 SCOI2016妖怪(三分)
  2. P3375【模板】KMP字符串匹配
  3. [洛谷P1131][ZJOI2007]时态同步
  4. idea 的http client的使用
  5. 怎么让Intellj Idea 把数据库的表映射成hibernate的domain对象
  6. Javascript 的addEventListener()及attachEvent()区别分析
  7. eclipse console输出有长度限制
  8. SQL 学习小笔记
  9. c++ fstream用法
  10. JAVASCRIPT和JSP计算闰年