run_codes_extract_directory
This commit is contained in:
@@ -580,7 +580,7 @@ class ElasticHelper:
|
||||
# - دادهها را به صورت bulk آپدیت میکند
|
||||
# - از helpers.bulk Elasticsearch استفاده میکند
|
||||
# -----------------------------end----------------------------
|
||||
def updateBulkList(self, listData, index_name):
|
||||
def updateBulkList(self, listData, index_name, streem_state=False):
|
||||
chunk_size = 100000
|
||||
raise_on_error = False
|
||||
raise_on_exception = False
|
||||
@@ -597,15 +597,28 @@ class ElasticHelper:
|
||||
"doc": item["_source"],
|
||||
}
|
||||
)
|
||||
helpers.bulk(
|
||||
self.es,
|
||||
actions,
|
||||
chunk_size,
|
||||
raise_on_error,
|
||||
raise_on_exception,
|
||||
stats_only,
|
||||
yield_ok,
|
||||
)
|
||||
|
||||
if streem_state :
|
||||
### /// برای مواردی که نیاز هست خطا فهمیده شود
|
||||
for ok, result in helpers.streaming_bulk(
|
||||
self.es,
|
||||
actions,
|
||||
raise_on_error=False,
|
||||
raise_on_exception=False,
|
||||
):
|
||||
if not ok:
|
||||
print("Error:", result)
|
||||
|
||||
else :
|
||||
helpers.bulk(
|
||||
self.es,
|
||||
actions,
|
||||
chunk_size,
|
||||
raise_on_error,
|
||||
raise_on_exception,
|
||||
stats_only,
|
||||
yield_ok,
|
||||
)
|
||||
|
||||
# ----------------------------start---------------------------
|
||||
# متد importBulkList:
|
||||
@@ -617,22 +630,36 @@ class ElasticHelper:
|
||||
# - دادهها را به صورت bulk وارد میکند
|
||||
# - از helpers.bulk Elasticsearch استفاده میکند
|
||||
# -----------------------------end----------------------------
|
||||
def importBulkList(self, listData, index_name):
|
||||
def importBulkList(self, listData, index_name, streem_state=False):
|
||||
chunk_size = 100000
|
||||
raise_on_error = False
|
||||
raise_on_exception = False
|
||||
stats_only = True
|
||||
yield_ok = False
|
||||
|
||||
actions=[]
|
||||
for item in listData:
|
||||
actions = [
|
||||
actions.append(
|
||||
{
|
||||
"_op_type": "index",
|
||||
"_index": index_name,
|
||||
"_id": item["_id"],
|
||||
"_source": item["_source"],
|
||||
}
|
||||
]
|
||||
)
|
||||
|
||||
if streem_state :
|
||||
### /// برای مواردی که نیاز هست خطا فهمیده شود
|
||||
for ok, result in helpers.streaming_bulk(
|
||||
self.es,
|
||||
actions,
|
||||
raise_on_error=False,
|
||||
raise_on_exception=False,
|
||||
):
|
||||
if not ok:
|
||||
print("Error:", result)
|
||||
|
||||
else :
|
||||
helpers.bulk(
|
||||
self.es,
|
||||
actions,
|
||||
|
||||
Reference in New Issue
Block a user