语法
批量操作对json有严格的要求,每个json串不能换行,只能放在同一行,相邻的json串之间必须要有换行。每个操作必须是一对json串(delete语法除外)
{ action: { metadata }}
{ request body }
{ action: { metadata }}
{ request body }
操作类型 | 介绍 |
---|---|
create | 文档id不存在则创建,不存在则报错 |
index | 文档id不存在则创建,存在则更新文档 |
update | 根据文档id更新文档,不存在则返回错误 |
delete | 根据文档id删除文档,不存在则返回错误 |
批量新增
{"index": {"_id": 1}}
{"name": "张三", "age": 10, "email": "1.qq.com", "address": "北京朝阳"}
{"index": {"_id": 2}}
{"name": "李四", "age": 20, "email": "2.qq.com", "address": "北京西城"}
{"index": {"_id": 3}}
{"name": "王五", "age": 30, "email": "3.qq.com", "address": "北京东城"}
{"index": {"_id": 4}}
{"name": "赵六", "age": 40, "email": "4.qq.com", "address": "北京海淀"}
[1]https://blog.csdn.net/weixin_39723544/article/details/109237175
[2]https://cloud.tencent.com/developer/article/2133017