Commit a7cee0ca authored by 段英荣's avatar 段英荣

batch_user增加query为空的兼容

parent 356f005d
......@@ -275,21 +275,21 @@ class UserUtils(object):
for query_item in batch_query_list:
query_body += "{}\n{}\n".format(json.dumps(search_header_dict),json.dumps(query_item))
result_dict = ESPerform.get_search_results(es_cli_obj, sub_index_name="user", query_body=query_body,
batch_search=True)
ret_dict = dict()
user_index = 0
for res_item in result_dict["responses"]:
recommend_user_list = list()
for item in res_item["hits"]["hits"]:
recommend_user_list.append(item["_source"]["user_id"])
if len(query_body)>0:
result_dict = ESPerform.get_search_results(es_cli_obj, sub_index_name="user", query_body=query_body,
batch_search=True)
user_index = 0
for res_item in result_dict["responses"]:
recommend_user_list = list()
for item in res_item["hits"]["hits"]:
recommend_user_list.append(item["_source"]["user_id"])
logging.info("duan add,attention_user_id_list:%s,user_index:%d" % (str(attention_user_id_list), user_index))
ret_dict[str(attention_user_id_list[user_index])] = recommend_user_list
user_index += 1
logging.info("duan add,attention_user_id_list:%s,user_index:%d" % (str(attention_user_id_list), user_index))
ret_dict[str(attention_user_id_list[user_index])] = recommend_user_list
user_index += 1
logging.info("duan add,ret_dict:%s" % str(ret_dict))
return ret_dict
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......
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