gpt4 book ai didi

python - 当使用python更新文档时,Elasticsearch抛出异常 `index_failed_engine_exception`

转载 作者:行者123 更新时间:2023-12-03 01:37:20 25 4
gpt4 key购买 nike

我正在尝试借助python脚本更新我的elasticsearch文档,但是在进行了一些文档更新后,出现了以下异常:

TransportError(500, u'index_failed_engine_exception', {u'status': 500, 
u'error': {u'index': u'catalog', u'root_cause': [{u'index': u'catalog',
u'reason': u'Index failed for [variant#5a61e925ae8bdc45df6939fa]',
u'type': u'index_failed_engine_exception', u'shard': u'3'}],
u'caused_by': {u'reason': u'translog is already closed', u'type':
u'already_closed_exception'}, u'shard': u'3', u'reason': u'Index failed
for [variant#5a61e925ae8bdc45df6939fa]', u'type':
u'index_failed_engine_exception'}})

请帮助我了解为什么会发生?

这是我的python代码:
def updateElasticDoc(sku, facilityId, reason, comment, replaceVariant):
if sku and replaceVariant:
docs = getElasticSearchDoc1(sku, facilityId)
for doc in docs:
docC = doc['_source']
flag = es.update(doc_type='variant', index='catalog',id=docC['facility_variant_id'],
body={"doc": {"replaced_variant": {"pack_type" : replaceVariant['pack_type'],
"pack_size" : replaceVariant['pack_size'],
"drug_strength" : replaceVariant['drug_strength'],
"variant_id" : str(replaceVariant['_id']),
"name" : replaceVariant['name'],
"sku" : replaceVariant['sku']
},
"status": "Retired", "variant_status" : "Retired", "reason" : reason, "variant_reason" : reason, "comment" : comment,
"is_retired" : True, "retired": True}})
if flag:
print (flag)

enter image description here

最佳答案

在elasticsearch.yml中更改设置 index.translog.sync_interval : 10s 。如果10秒不起作用,请增加尝试。

有关更多信息,请引用Translog settings

您可以按照以下步骤为索引动态更新此设置:

1)关闭索引:

POST my_index/_close

2)更新设置:
PUT my_index/_settings
{
"index.translog.sync_interval" : "10s"
}

3)再次打开索引:
POST my_index/_open

关于python - 当使用python更新文档时,Elasticsearch抛出异常 `index_failed_engine_exception`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51338710/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com