es基本操作
- 打开kibana,然后浏览器访问5601端口
- 点击上图红箭头位置,右侧就可以编辑最基本的CURD命令,都是rest风格,下边提供代码可直接复制
3.打开cerebro可查看集群信息
#create document 自动生成 _id
POST users/_doc
{
"user":"Mike",
"post_date":"2019-04-15T14:12:12",
"message":"trying out Kibana"
}
#create document 指定id 如果id已存在,报错
PUT users/_doc/1?op_type=create
{
"user":"Jake",
"post_date":"2019-04-15T14:12:12",
"message":"trying out Elasticsearch"
}
#Get Document by ID
GET users/_doc/1
#index 旧的删了,版本号加1
PUT users/_doc/1
{
"user":"Mike"
}
#update 在原文档上加字段
POST users/_update/1/
{
"doc":{
"post_date":"2019-04-15T14:12:12",
"message":"trying out Elasticsearch"
}
}
#Bulk Api 多索引多次操作
#Index Create Update Delete
#执行第1次
POST _bulk
{"index":{"_index":"test","_id":"1"}}
{"field1":"value1"}
{"delete":{"_index":"test","_id":"2"}}
{"create":{"_index":"test2","_id":"3"}}
{"field1":"value3"}
{"update":{"_id":"1","_index":"test"}}
{"doc":{"field2":"value2"}}
#查询
GET test2/_doc/3
#批量查询 msearch 操作
POST test/_msearch
{}
{"query":{"match_all":{}},"size":1}
{"index":"test2"}
{"query":{"match_all":{}},"size":2}
网友评论