0

I'm trying to updating my elasticsearch documents with help of python script but after some doc update I got the exception follow:

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'}})

Please help me to understand why it happens?

Here is my python code:

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

7
  • Is your index open? Commented Jul 14, 2018 at 13:07
  • yes it is open because 10 out of 100 does not update 90 docs were successfully update Commented Jul 14, 2018 at 13:14
  • Using bulk request to insert? Commented Jul 14, 2018 at 13:17
  • no, as you can see in my code I'm updating single record at a time Commented Jul 14, 2018 at 13:18
  • let me know if that worked? Commented Jul 14, 2018 at 13:44

1 Answer 1

2

Change the setting index.translog.sync_interval: 10s in your elasticsearch.yml. If 10s won't work increase more and try.

Please refer Translog settings for more information.

You can update this setting dynamically for your index by following mentioned steps:

1) Close your index:

POST my_index/_close

2) Update the settings:

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

3) Open the index again:

POST my_index/_open
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.