elastic 6.x 利用restApi 与集群进行交互 .3

操作功能:

检查群集、节点和索引的健康、状态和统计信息
管理群集、节点和索引数据和元数据
执行CRUD(创建、读取、更新和删除)并对索引进行搜索操作

执行高级搜索操作,如分页、排序、过滤、脚本编写、聚合以及其他许多操作。

1.查看集群状态

GET /_cat/health?v

epoch      timestamp cluster       status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1475247709 17:01:49  elasticsearch green           1         1      0   0    0    0        0             0                  -                100.0%

绿色-一切都好(集群功能齐全)
黄色-所有数据可用,但一些副本尚未分配(集群是完全功能的)

红色-由于某些原因,有些数据是不可用的(集群是部分功能的)

2.查看节点

GET /_cat/nodes?v

ip        heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
127.0.0.1           10           5   5    4.46                        mdi      *      PB2SGZY

3.列出所有索引数据

GET /_cat/indices?v

health status index uuid pri rep docs.count docs.deleted store.size pri.store.size

默认为无.

4.创建索引,

PUT /customer?pretty

5.创建文档

PUT /customer/_doc/1?pretty
{
  "name": "John Doe"

}

GET /customer/_doc/1?pretty

返回结果

{
  "_index" : "customer",
  "_type" : "_doc",
  "_id" : "1",
  "_version" : 1,
  "found" : true,
  "_source" : { "name": "John Doe" }
}

6.删除索引

DELETE /customer?pretty
GET /_cat/indices?v

PUT /customer
PUT /customer/_doc/1
{
  "name": "John Doe"
}
GET /customer/_doc/1

DELETE /customer

猜你喜欢

转载自blog.csdn.net/weixin_38098312/article/details/80075552