- 集群健康
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%
- 获取节点列表
GET /_cat/nodes?v
返回
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role主名称
127.0.0.1 10 5 5 4.46 mdi * PB2SGZY
- 列出所有指标
GET /_cat/indices?v
返回
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
- 创建索引
PUT /customer?pretty
创建名为customer 的索引
GET /_cat/indices?v - 索引和查询文档
插入数据
PUT /customer/_doc/1?pretty
{
"name":"John Doe"
}`
获取数据
GET /customer/_doc/1?pretty
- 删除索引
DELETE /customer?pretty
GET /_cat/indices?v
- 修改数据
POST /customer/_doc?pretty
{
"name":"Jane Doe"
}
POST /customer/_doc/1/_update?pretty
{
"doc":{"name":"Jane Doe"}
}
POST /customer/_doc/1/_update?pretty
{
"doc":{"name":"Jane Doe","age":20}
}
POST /customer/_doc/1/_update?pretty
{
"script":"ctx._source.age += 5"
}
- 删除文档
删除id为2的文档
DELETE /customer/_doc/2?pretty
- 批量处理
POST /customer/_doc/_bulk?pretty
{"index":{"_id":1}}
{"name":"John Doe"}
{"index":{"_id":"2"}}
{"name":""Jane Doe}
更新文档1,删除文档2
POST /customer/_doc/_bulk?pretty
{“update”:{"_id":1}}
{“doc”:{“name”:“John Doe becomes Jane Doe”}}
{“delete”:{"_id":2}}
- 查询
GET /.monitoring-es-6-2019.07.14/_search
- took -Elasticsearch 执行搜索时间(以毫秒为单位)
- time_out 告诉我们搜索是否超时
- _shards 告诉我们搜索了多少个分片,以及搜索成功/失败分片的数量
- hits 搜索结果
- hits.total 包含与我们的搜索条件匹配的文档总数的信息对象
- hits.total.value 总命中数的值
GET /bank/_search
{
"query":{"match_all":{}},
"sort":[
{"account_number":"asc"}
]
}
GET /.monitoring-es-6-2019.07.14/_search
{
"query":{"match_all": {}},
"size":1
}