es基础命令(版本6.3.2)(持续更新中)
添加索引
①PUT /people?pretty
-> 入参:添加主分片和副本分片(不设置会有默认值)
{ "settings": { "number_of_shards": 5, "number_of_replicas": 4 } }
-> 成功返回
{ "acknowledged" : true, "shards_acknowledged" : true, "index" : "commodity" }
②PUT /people?pretty
-> 入参:创建索引的时候将映射一并创建好
{ "settings": { "number_of_shards": 3, "number_of_replicas": 2 }, "mapping": { "_doc": { "properties": { "commodity_id": { "type": "long" }, "commodity_name": { "type": "text" }, "picture_url": { "type": "keyword" }, "price": { "type": "double" } } } } }
③PUT /people/_settings
-> 入参:修改副本操作
{ "number_of_replicas": 3 }
④查看已添加的索引:
GET /_cat/indices?v
⑤查看某个索引下的type
GET /people/_mappings
⑥创建一个文档:
//手动创建id
POST /people/man/1?pretty
{
"name": "luoqiang"
}
//自动生产id
POST /people/man/?pretty
{
"name": "luoqiang"
}
⑦删除一个索引
DELETE /people?pretty
⑧删除文档数据
DELETE /people/man/1?pretty
⑨查看文档数据
GET /people/man/_search
10、批处理
POST /people/man/_bulk?pretty
{"index": {"_id": "1"}}
{"name": "luoqiang"}
{"index":{"_id": "2"}}
{"name": "wenying"}