新增冲突重试

This commit is contained in:
shenjian@fangjia.com
2022-11-23 11:40:01 +08:00
parent 9acba02dec
commit 8681268f15
@@ -41,23 +41,18 @@ def sync():
"_op_type": "update",
"_index": index_name,
"_id": item['_id'],
"doc": doc_info
"doc": doc_info,
"_retry_on_conflict": 5
}
actions.append(action)
if len(actions) == 5000:
try:
helpers.bulk(es206_client.elastic_client, actions)
count += len(actions)
logging.info("已补全:" + str(count))
except Exception as e:
log.error(e)
helpers.bulk(es206_client.elastic_client, actions)
count += len(actions)
logging.info("已补全:" + str(count))
actions.clear()
if len(actions) > 0:
try:
helpers.bulk(es206_client.elastic_client, actions)
except Exception as e:
log.error(e)
helpers.bulk(es206_client.elastic_client, actions)
actions.clear()
log.info(f"完成补全户均总价信息至206 {index_name}")