elasticsearch 学习笔记

  • 集群健康
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
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值