Commit 69628563 authored by litaolemo's avatar litaolemo

update

parent c1b02661
......@@ -41,50 +41,54 @@ search_body = {
}
es2_re = es2.search(index=target_index, doc_type=target_type,
body=search_body)
q3_total = es2_re['hits']['total']
write_into_scan = scan(client=es2,
query=search_body,
index=target_index,
doc_type=target_type,
scroll='5m',
request_timeout=100
)
count = 0
for one_scan in write_into_scan:
count = count + 1
line = one_scan['_source']
doc_id = one_scan['_id']
try:
if line['facevideo_is_assistant'] == 1:
line['facevideo_is_assistant'] = True
else:
line['facevideo_is_assistant'] = False
except:
pass
bulk_head = '{"index": {"_id":"%s"}}' % doc_id
data_str = json.dumps(line, ensure_ascii=False)
bulk_one_body = bulk_head + '\n' + data_str + '\n'
# print(bulk_one_body)
bulk_all_body += bulk_one_body
# break
if count%500 == 0:
eror_dic=es7.bulk(index=target_index,
body=bulk_all_body, request_timeout=200)
bulk_all_body=''
if eror_dic['errors'] is True:
print(eror_dic['items'])
print(bulk_all_body)
print(count)
if bulk_all_body != '':
eror_dic = es7.bulk(body=bulk_all_body,
index=target_index,
request_timeout=200)
if eror_dic['errors'] is True:
print(eror_dic)
es7_re = es7.search(index=target_index, doc_type=target_type,
body=search_body)
bulk_all_body = ''
#
# q3_total = es2_re['hits']['total']
# write_into_scan = scan(client=es2,
# query=search_body,
# index=target_index,
# doc_type=target_type,
# scroll='5m',
# request_timeout=100
# )
#
# count = 0
# for one_scan in write_into_scan:
# count = count + 1
# line = one_scan['_source']
# doc_id = one_scan['_id']
# try:
# if line['facevideo_is_assistant'] == 1:
# line['facevideo_is_assistant'] = True
# else:
# line['facevideo_is_assistant'] = False
# except:
# pass
#
# bulk_head = '{"index": {"_id":"%s"}}' % doc_id
# data_str = json.dumps(line, ensure_ascii=False)
#
# bulk_one_body = bulk_head + '\n' + data_str + '\n'
# # print(bulk_one_body)
# bulk_all_body += bulk_one_body
# # break
# if count%500 == 0:
#
# eror_dic=es7.bulk(index=target_index,
# body=bulk_all_body, request_timeout=200)
# bulk_all_body=''
# if eror_dic['errors'] is True:
# print(eror_dic['items'])
# print(bulk_all_body)
# print(count)
#
# if bulk_all_body != '':
# eror_dic = es7.bulk(body=bulk_all_body,
# index=target_index,
# request_timeout=200)
# if eror_dic['errors'] is True:
# print(eror_dic)
#
# bulk_all_body = ''
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment