是否可以
答案 0 :(得分:1)
是的,请使用批量create
:
POST /my_index/my_type/_bulk
{"create":{"_id":1}}
{"foo":1,"bar":"y"}
{"create":{"_id":6}}
{"foo":1,"bar":"y"}
上述请求适用于已存在的doc 1和不存在的doc 6。该请求的输出是:
"items": [
{
"create": {
"_index": "my_index",
"_type": "my_type",
"_id": "1",
"status": 409,
"error": "DocumentAlreadyExistsException[[my_index][2] [my_type][1]: document already exists]"
}
},
{
"create": {
"_index": "my_index",
"_type": "my_type",
"_id": "6",
"_version": 1,
"status": 201
}
}
]