Elasticsearch入门级别API

API并非DSL语句
1、健康检查命令

curl -X GET "localhost:9200/_cat/health?v&pretty"

执行以上命令或者直接在浏览器输入以上链接,将会得到如下返回包含集群名称,健康状态分片信息等状态。

epoch      timestamp cluster        status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1590149221 12:07:01  log-collection yellow          1         1    169 169    0    0      166             0                  -                 50.4%

我们可以看到status状态为yellow黄色,即可用状态,
集群健康状态可以分为以下三种

  • green(绿色):完全健康
  • yellow(黄色):所有数据节点可用,但是某些副本不可用,或者没有配置副本
  • red(红色):某些数据节点不可用。
    当集群状态为红色的时候仍然部分可用,但是需要尽快进行修复
    2、我们可以通过以下命令查看节点信息
curl -X GET "localhost:9200/_cat/nodes?v&pretty"

得到如下返回,记录了节点名称是否主节点,性能情况的星系

ip          heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
192.168.0.20           83          94   5    1.07    0.60     0.42 dilm      *      node-1

3、列出所有索引命令

curl -X GET "localhost:9200/_cat/indices?v&pretty"

将得到如下返回

health status index                                         uuid                   pri rep docs.count docs.deleted store.size pri.store.size
yellow open  log-nginx-2-access-2020-05-12                  A1FXDbIwSjeDzvbfXZgUFA   1   1      16230            0      2.7mb          2.7mb

4、创建索引

curl -X PUT "localhost:9200/customer?pretty"

返回执行成功

{
  "acknowledged" : true,
  "shards_acknowledged" : true,
  "index" : "customer"
}

然后可以通过上一个命令查看索引。
5、删除索引

curl -X DELETE "localhost:9200/customer?pretty"

返回

health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值