1. 批量操作(bulk)

官方文档

用法

  1. POST _bulk
  2. { "index" : { "_index" : "test", "_id" : "1" } }
  3. { "field1" : "value1" }
  4. { "delete" : { "_index" : "test", "_id" : "2" } }
  5. { "create" : { "_index" : "test", "_id" : "3" } }
  6. { "field1" : "value3" }
  7. { "update" : {"_id" : "1", "_index" : "test"} }
  8. { "doc" : {"field2" : "value2"} }

accounts.json

字段说明:

  1. {
  2. "account_number" : 6, //银行账户
  3. "balance" : 5686, // 余额
  4. "firstname" : "Hattie",
  5. "lastname" : "Bond",
  6. "age" : 36,
  7. "gender" : "M",
  8. "address" : "671 Bristol Street",
  9. "employer" : "Netagy", //所在公司
  10. "email" : "hattiebond@netagy.com",
  11. "city" : "Dante", //城市
  12. "state" : "TN" //国家
  13. }

2. 批量获取(mget)

官方文档

  1. GET /_mget
  2. {
  3. "docs": [
  4. {
  5. "_index": "my-index-000001",
  6. "_id": "1"
  7. },
  8. {
  9. "_index": "my-index-000001",
  10. "_id": "2"
  11. }
  12. ]
  13. }