【发布时间】:2016-12-30 13:37:35
【问题描述】:
我正在尝试在弹性搜索中执行 批量操作。然而,JSON 中给出的 last operation 永远不会被弹性搜索执行。
这是我的请求:
curl -XPOST 'localhost:9200/customer/external/_bulk?pretty&pretty' -d'
{"update":{"_id":"1"}}
{"doc": { "name": "Update - John Doe becomes Jane Doe" } }
{"delete":{"_id":"4"}}
{"index":{"_id":"3"}}
{"name": "Create or Update - New Jane Doe" }
{"create":{"_id":"4"}}
{"name": "Only Create - New Jane Doe" }
{"create":{"_id":"5"}}
{"name": "Only Create - New Jane Doe 1" }'
响应只包含 4 个输出而不是 5 个:
{
"took": 100,
"errors": false,
"items": [
{
"update": {
"_index": "customer",
"_type": "external",
"_id": "1",
"_version": 9,
"result": "noop",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"status": 200
}
},
{
"delete": {
"found": true,
"_index": "customer",
"_type": "external",
"_id": "4",
"_version": 4,
"result": "deleted",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"status": 200
}
},
{
"index": {
"_index": "customer",
"_type": "external",
"_id": "3",
"_version": 7,
"result": "updated",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"created": false,
"status": 200
}
},
{
"create": {
"_index": "customer",
"_type": "external",
"_id": "4",
"_version": 5,
"result": "created",
"_shards": {
"total": 2,
"successful": 1,
"failed": 0
},
"created": true,
"status": 201
}
}
]
}
在我的场景中,ID 为“5”的客户(名称:“Only Create - New Jane Doe 1”)从未创建。如果我删除最后一个请求 (id:5),那么即使 id:4 也不会被创建。
我进行了搜索以获取客户索引的所有文档,但 id:5 不存在。
好像弹性搜索忽略了 JSON 的最后一部分。我什至尝试通过 PostmanClient 发布请求,但它仍然是一样的。
弹性搜索版本:5.1.1
【问题讨论】:
-
我不确定,试试 curl -XPOST 'localhost:9200/customer/external/_bulk?pretty=true' -d
标签: elasticsearch