Commit 0b05123b authored by 赵威's avatar 赵威

update types

parent f445a94a
...@@ -46,7 +46,7 @@ def es_insert_device_info(device_id, body, es=None, rw=None): ...@@ -46,7 +46,7 @@ def es_insert_device_info(device_id, body, es=None, rw=None):
if es is None: if es is None:
es = get_es() es = get_es()
index = es_index_adapt(index_prefix="gm-dbmw", doc_type="device", rw=None) index = es_index_adapt(index_prefix="gm-dbmw", doc_type="device", rw=None)
bulk_head = '{"index": {"_id":"%s"}}' % device_id bulk_head = '{"index": {"_id": "%s"}}' % device_id
data_str = json.dumps(body, ensure_ascii=False) data_str = json.dumps(body, ensure_ascii=False)
bulk_one_body = bulk_head + "\n" + data_str + "\n" bulk_one_body = bulk_head + "\n" + data_str + "\n"
return es.bulk(index=index, doc_type="device", body=bulk_one_body) return es.bulk(index=index, doc_type="device", body=bulk_one_body)
...@@ -43,7 +43,7 @@ def user_portrait_scan_info(): ...@@ -43,7 +43,7 @@ def user_portrait_scan_info():
def _dict_to_name_score(d): def _dict_to_name_score(d):
res = [] res = []
for (k, v) in d.items(): for (k, v) in d.items():
res.append({"name": k, "score": v}) res.append({"name": k, "score": double(v)})
return res return res
...@@ -71,8 +71,6 @@ def write_to_es(device_id): ...@@ -71,8 +71,6 @@ def write_to_es(device_id):
body["second_solutions"] = _dict_to_name_score(second_solutions_d) body["second_solutions"] = _dict_to_name_score(second_solutions_d)
body["projects"] = _dict_to_name_score(projects_d) body["projects"] = _dict_to_name_score(projects_d)
body["anecdote_tags"] = anecdote_tags body["anecdote_tags"] = anecdote_tags
print(body)
print(body.keys())
es_insert_device_info(device_id, body) es_insert_device_info(device_id, 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