首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用python更新文档时,Elasticsearch抛出异常`index_failed_engine_exception`

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

Stack Overflow用户
提问于 2018-07-14 20:55:20
回答 1查看 265关注 0票数 0

我试图在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)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-07-14 21:19:20

更改elasticsearch.yml中的10s设置。如果10不起作用,增加更多并尝试。

有关更多信息,请参阅Translog settings

您可以通过以下提到的步骤为索引动态更新此设置:

1)关闭你的索引:

POST my_index/_close

2)更新设置:

PUT my_index/_settings
{
  "index.translog.sync_interval" : "10s"
}

3)重新打开索引:

POST my_index/_open
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/51338710

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档