查看集群状态
命令行:curl -XGET "http://localhost:9200/_cat/health?v"
kibana控制台:GET /_cat/health?v
列出集群中的节点
命令行:curl -XGET "http://localhost:9200/_cat/nodes?v"
kibana控制台:GET /_cat/nodes?v
列出集群所有的索引
命令行:curl -XGET "http://localhost:9200/_cat/indices?v"
kibana控制台:GET /_cat/indices?v
创建索引:
创建名为customer的索引:
命令行:curl -XPUT "http://localhost:9200/customer?pretty"
kibana控制台:PUT /customer?pretty
索引并且查询一个文档
PUT /customer/external/1?pretty
{
"name": "John Doe"
}
GET /customer/external/1?pretty
删除一个索引
DELETE /customer?pretty
DELETE /customer/external/1?pretty
更新数据
PUT /customer/external/1?pretty
{
"name": "John Doe"
}
如果对相同的文档多次执行以上的命令,elastic将重新索引,ID为1,Version号码递增
更新记录
POST /customer/external/1/_update?pretty
{
"doc": { "name": "Jane Doe" }
}
POST /customer/external/1/_update?pretty
{
"doc": { "name": "Jane Doe", "age": 20 }
}
POST /customer/external/1/_update?pretty
{
"script" : "ctx._source.age += 5"
}
删除记录
DELETE /cutomer/external/1?pretty
批处理
POST /customer/external/_bulk?pretty
{"index":{"_id":"1"}}
{"name": "John Doe" }
{"index":{"_id":"2"}}
{"name": "Jane Doe" }
POST /customer/external/_bulk?pretty
{"update":{"_id":"1"}}
{"doc": { "name": "John Doe becomes Jane Doe" } }
{"delete":{"_id":"2"}}