我正在尝试借助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)
答案 0 :(得分:1)
在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