Esearch

Esearch安装文档

1:安装步骤

 

 

一:安装RPM软件包

rpm --install elasticsearch-6.5.1.rpm

 

二:修改配置文件

vim /etc/sysconfig/elasticsearch

JAVA_HOME=/home/java/jdk1.8.0_181

 

三:启动Esearch

service elasticsearch start

 

四:测试Esearch

curl localhost:9200

 

{

  "name" : "mZJN_QU",

  "cluster_name" : "elasticsearch",

  "cluster_uuid" : "Vl0l04LqRdmutjp3AQBx3Q",

  "version" : {

    "number" : "6.5.1",

    "build_flavor" : "default",

    "build_type" : "rpm",

    "build_hash" : "8c58350",

    "build_date" : "2018-11-16T02:22:42.182257Z",

    "build_snapshot" : false,

    "lucene_version" : "7.5.0",

    "minimum_wire_compatibility_version" : "5.6.0",

    "minimum_index_compatibility_version" : "5.0.0"

  },

  "tagline" : "You Know, for Search"

}

2:启动排错

错误:

system call filters failed to install; check the logs and fix your configuration or disable system call filters at your own risk

修改:vim /etc/elasticsearch/elasticsearch.yml

bootstrap.memory_lock: true

bootstrap.system_call_filter: false

 

错误:

max number of threads [1024] for user [elasticsearch] is too low, increase to at least [4096]

修改:/etc/security/limits.conf

elasticsearch soft nproc unlimited

elasticsearch hard nproc unlimited

 

错误:

memory locking requested for elasticsearch process but memory is not locked

修改:/etc/security/limits.conf

elasticsearch soft memlock unlimited

elasticsearch hard memlock unlimited

 

 

3:RPM工作目录

 

 

4:安装中文分词器

https://github.com/medcl/elasticsearch-analysis-ik

下载对应版本elasticsearch-analysis-ik-6.5.1.zip

 

在/usr/share/elasticsearch/plugin下创建目录ik,把zip放入ik解压重启服务完成安装

 

 

5:安装kibana

1:安装RPM软件包

yum localinstall kibana-6.5.1-x86_64.rpm

 

 

2:安装目录

 

3:配置kibana

修改 vim /etc/kibana/kibana.yml

server.host: "0.0.0.0"

elasticsearch.url: http://localhost:9200

 

启动kibana

service kibana start

访问地址 http://192.168.80.114:5601/

 

 

 

6:Java客户端

https://www.elastic.co/guide/en/elasticsearch/client/java-api/current/index.html

 

<dependency>
    <groupId>org.elasticsearch.client</groupId>
   <artifactId>elasticsearch-rest-high-level-client</artifactId>
    <version>6.5.1</version>
</dependency>

 

 

Esearch学习文档

0:学习文档

https://www.elastic.co/guide/cn/elasticsearch/guide/cn/_indexing_employee_documents.html

1:计算集群中文档的数量

GET _count?pretty=true

{

  "query": {"match_all": {}}

}

 

{

  "count" : 14022,

  "_shards" : {

    "total" : 2,

    "successful" : 2,

    "skipped" : 0,

    "failed" : 0

  }

}

2:查询所有的索引

GET _cat/indices?v

 

3:索引一个JSON数据

PUT /megacorp/employee/3

{

    "first_name" :  "Douglas",

    "last_name" :   "Fir",

    "age" :         35,

    "about":        "I like to build cabinets",

    "interests":  [ "forestry" ]

}

 

{

  "_index" : "megacorp",

  "_type" : "employee",

  "_id" : "3",

  "_version" : 1,

  "result" : "created",

  "_shards" : {

    "total" : 2,

    "successful" : 1,

    "failed" : 0

  },

  "_seq_no" : 0,

  "_primary_term" : 1

}

 

 

4:获取一个JSON数据

GET /megacorp/employee/1

 

{

  "_index" : "megacorp",

  "_type" : "employee",

  "_id" : "1",

  "_version" : 1,

  "found" : true,

  "_source" : {

    "first_name" : "John",

    "last_name" : "Smith",

    "age" : 25,

    "about" : "I love to go rock climbing",

    "interests" : [

      "sports",

      "music"

    ]

  }

}

 

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值