I'm using ElasticSearch in my Laravel app and recently I've implemented the option to allow for deletion of documents from the Elastic Search index. The problem is that I keep getting the version_conflict_engine_exception
error.
My code looks like this:
$params = [
'index' => 'invoices',
'body' => [
'query' => [
'bool' => [
'must' => [
['term' => ['user_id' => $userId]]
]
]
]
],
'refresh' => true,
];
Elasticsearch::deleteByQuery($params);
After reading the official docs I get that a 'conflicts' => 'proceed'
parameter can be added and this should solve the problem. But I feel like I'm only hiding the issue, not actually solving it. I know for sure that no other operation is performed on that document in the same time, so no reason for the version to change, but this error keeps popping up.
{
"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
}
}
Could there be something else to this that I'm doing wrong?