问题描述:

ES在多次更细同一条数据时会产生冲突

elasticsearch.exceptions.ConflictError: ConflictError(409, '{"took":4,"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":"xxxx","type":"xxxx","id":"901d7ee97489c9ebb5a0498ce9fe8a3a","cause":{"type":"version_conflict_engine_exception","reason":"[xxxx][901d7ee97489c9ebb5a0498ce9fe8a3a]: version conflict, current version [31] is different than the one provided [30]","index_uuid":"FAR-xl5RS3ywZTw3kazGZA","shard":"0","index":"source_code_leak"},"status":409}]}')

解决方法:

增加{"refresh": "true"}
es.update_by_query(index="xxx", body=query, doc_type="",
                            params={"refresh": "true"})
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐