查看集群狀態(tài)
命令行:curl -XGET "http://localhost:9200/_cat/health?v"
kibana控制臺(tái):GET /_cat/health?v
列出集群中的節(jié)點(diǎn)
命令行:curl -XGET "http://localhost:9200/_cat/nodes?v"
kibana控制臺(tái):GET /_cat/nodes?v
列出集群所有的索引
命令行:curl -XGET "http://localhost:9200/_cat/indices?v"
kibana控制臺(tái):GET /_cat/indices?v
創(chuàng)建索引:
創(chuàng)建名為customer的索引:
命令行:curl -XPUT "http://localhost:9200/customer?pretty"
kibana控制臺(tái):PUT /customer?pretty
索引并且查詢一個(gè)文檔
PUT /customer/external/1?pretty
{
"name": "John Doe"
}
GET /customer/external/1?pretty
刪除一個(gè)索引
DELETE /customer?pretty
DELETE /customer/external/1?pretty
更新數(shù)據(jù)
PUT /customer/external/1?pretty
{
"name": "John Doe"
}
如果對(duì)相同的文檔多次執(zhí)行以上的命令,elastic將重新索引,ID為1,Version號(hào)碼遞增
更新記錄
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"}}