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

modify home_recommend return

parent 086b6ef5
...@@ -259,6 +259,8 @@ class TopicUtils(object): ...@@ -259,6 +259,8 @@ class TopicUtils(object):
query_function_score["query"]["bool"]["must_not"] = [ query_function_score["query"]["bool"]["must_not"] = [
{"terms":{"id":filter_topic_id_list}} {"terms":{"id":filter_topic_id_list}}
] ]
if len(linucb_user_id_list)>0:
if "must_not" in query_function_score["query"]["bool"]: if "must_not" in query_function_score["query"]["bool"]:
query_function_score["query"]["bool"]["must_not"] += [ query_function_score["query"]["bool"]["must_not"] += [
{"terms": {"user_id": linucb_user_id_list}} {"terms": {"user_id": linucb_user_id_list}}
......
...@@ -152,7 +152,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query ...@@ -152,7 +152,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
return recommend_topic_list,rank_topic_id_list return recommend_topic_list,rank_topic_id_list
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return [] return [],[]
@bind("physical/search/query_tag_id_by_topic") @bind("physical/search/query_tag_id_by_topic")
...@@ -252,8 +252,8 @@ def home_query(device_id="", tag_id=-1, user_id=-1, query="", offset=0, size=10) ...@@ -252,8 +252,8 @@ def home_query(device_id="", tag_id=-1, user_id=-1, query="", offset=0, size=10)
if not isinstance(device_id, str): if not isinstance(device_id, str):
device_id = "" device_id = ""
recommend_topic_ids = get_home_recommend_topic_ids(user_id, device_id, tag_id, offset=offset, size=size, query=query) recommend_topic_list, rank_topic_id_list = get_home_recommend_topic_ids(user_id, device_id, tag_id, offset=offset, size=size, query=query)
return {"recommend_topic_ids": recommend_topic_ids} return {"recommend_topic_ids": rank_topic_id_list}
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {"recommend_topic_ids": []} return {"recommend_topic_ids": []}
......
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