我有我得到的情况version_conflict_engine_exception。我有守护进程,它不断地将数据更新到elasticsearch。我正在使用_updat_by_query. 这是示例调用:
curl -XPOST 'localhost:9200/my_index/my_type/_update_by_query?pretty' -H 'Content-Type: application/json' -d '
{
"query":{
"term":{
"userid":1234
}
},
"script":{
"lang":"painless",
"inline":"if (ctx._source.containsKey(\"newfield\")) {ctx._source.newfiled.add(params.value)} else {ctx._source.newfield = [params.value]}",
"params":{
"value":{"new":"value"}
}
}
}'
Run Code Online (Sandbox Code Playgroud)
每当我有相同的用户 ID(在query.terms)时,就会有多个更新查询一个接一个地点击,它给我错误version_conflict_engine_exception。我知道这是因为版本冲突,但我们如何克服我经常更新查询的问题。我也没有找到任何bulk选项_update_by_query。我收到以下错误:
{
"took": 1,
"timed_out": false,
"total": 1,
"updated": 0,
"deleted": 0,
"batches": 1,
"version_conflicts": 1,
"noops": 0,
"retries": {
"bulk": 0,
"search": 0
},
"throttled_millis": 0,
"requests_per_second": -1.0,
"throttled_until_millis": 0,
"failures": [{
"index": "my_index",
"type": "my_type",
"id": "Gc-_SWIBUzg1_4kxJ5uD",
"cause": {
"type": "version_conflict_engine_exception",
"reason": "[logs][Gc-_SWIBUzg1_4kxJ5uD]: version conflict, current version [2] is different than the one provided [1]",
"index_uuid": "dbtt5uS9R3ClcPt6Oar1MQ",
"shard": "3",
"index": "my_index"
},
"status": 409
}]
}
Run Code Online (Sandbox Code Playgroud)
目前这是 Elasticsearch 中的预期行为。您可以尝试使用冲突和刷新参数来解决此问题。
您可以使用
curl -XPOST 'localhost:9200/my_index/my_type/_update_by_query?conflicts=proceed&refresh=wait_for
Run Code Online (Sandbox Code Playgroud)
正如这里提到的。希望有帮助!
| 归档时间: |
|
| 查看次数: |
14017 次 |
| 最近记录: |