mirror of
https://github.com/simon987/od-database.git
synced 2025-04-20 02:46:45 +00:00
retry if deleting docs fail
This commit is contained in:
parent
f452d0f8b2
commit
2f1b0c96f1
@ -95,22 +95,25 @@ class ElasticSearchEngine(SearchEngine):
|
|||||||
|
|
||||||
def delete_docs(self, website_id):
|
def delete_docs(self, website_id):
|
||||||
|
|
||||||
try:
|
while True:
|
||||||
print("Deleting docs of " + str(website_id))
|
try:
|
||||||
self.es.delete_by_query(body={
|
print("Deleting docs of " + str(website_id))
|
||||||
"query": {
|
self.es.delete_by_query(body={
|
||||||
"constant_score": {
|
"query": {
|
||||||
"filter": {
|
"constant_score": {
|
||||||
"term": {"website_id": website_id}
|
"filter": {
|
||||||
|
"term": {"website_id": website_id}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}, index=self.index_name, request_timeout=200)
|
||||||
}, index=self.index_name, request_timeout=200)
|
break
|
||||||
except elasticsearch.exceptions.ConflictError:
|
except elasticsearch.exceptions.ConflictError:
|
||||||
print("Error: multiple delete tasks at the same time")
|
print("Error: multiple delete tasks at the same time, retrying")
|
||||||
except Exception:
|
time.sleep(10)
|
||||||
print("Timeout during delete!")
|
except Exception:
|
||||||
time.sleep(30)
|
print("Timeout during delete! Retrying")
|
||||||
|
time.sleep(10)
|
||||||
|
|
||||||
def import_json(self, in_lines, website_id: int):
|
def import_json(self, in_lines, website_id: int):
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user