我在我的 Laravel 应用程序中使用 ElasticSearch,最近我实现了允许从 Elastic Search 索引中删除文档的选项。问题是我不断收到version_conflict_engine_exception
错误。
我的代码如下所示:
$params = [
'index' => 'invoices',
'body' => [
'query' => [
'bool' => [
'must' => [
['term' => ['user_id' => $userId]]
]
]
]
],
'refresh' => true,
];
Elasticsearch::deleteByQuery($params);
阅读官方文档后,我发现'conflicts' => 'proceed'
可以添加一个参数,这应该可以解决问题。但我觉得我只是在隐藏问题,而不是真正解决它。我确定没有同时对该文档执行其他操作,因此没有理由更改版本,但此错误不断弹出。
{
"took": 1189,
"timed_out": false,
"total": 47,
"deleted": 0,
"batches": 1,
"version_conflicts": 47,
"noops": 0,
"retries": {
"bulk": 0,
"search": 0
},
"throttled_millis": 0,
"requests_per_second": -1,
"throttled_until_millis": 0,
"failures": {
"index": "invoices",
"type": "_doc",
"id": "6e6bd47a-c225-4d7f-8798-cc1275b0363c",
"cause": {
"type": "version_conflict_engine_exception",
"reason": "[6e6bd47a-c225-4d7f-8798-cc1275b0363c]: version conflict, required seqNo [667648], primary term [7]. but no document was found",
"index_uuid": "7wBzPBXYT4Kfx8jP1SjSNA",
"shard": "0",
"index": "invoices"
},
"status": 409
}
}
我做错了什么吗?