Commit 1c03f85a authored by lixiaofang's avatar lixiaofang

Merge branch 'test' of git.wanmeizhensuo.com:alpha/physical into test

parents b14bafa0 06905909
...@@ -445,7 +445,7 @@ class TopicUtils(object): ...@@ -445,7 +445,7 @@ class TopicUtils(object):
q = dict() q = dict()
q["query"] = dict() q["query"] = dict()
logging.warning("topic_tag_list:%s"%str(topic_tag_list)) # logging.warning("topic_tag_list:%s"%str(topic_tag_list))
functions_list = [ functions_list = [
{ {
"linear": { "linear": {
...@@ -456,23 +456,23 @@ class TopicUtils(object): ...@@ -456,23 +456,23 @@ class TopicUtils(object):
} }
} }
] ]
if len(topic_tag_list) > 0: # if len(topic_tag_list) > 0:
functions_list.append( # functions_list.append(
{ # {
"filter": {"bool": { # "filter": {"bool": {
"should": {"terms": {"tag_list": topic_tag_list}}}}, # "should": {"terms": {"tag_list": topic_tag_list}}}},
"weight": 5000 # "weight": 5000
} # }
) # )
if topic_user_id != -1: # if topic_user_id != -1:
functions_list.append( # functions_list.append(
{ # {
"filter": {"bool": { # "filter": {"bool": {
"should": {"term": {"user_id": topic_user_id}}}}, # "should": {"term": {"user_id": topic_user_id}}}},
"weight": 5000 # "weight": 5000
} # }
) # )
if len(topic_tag_list) != 0 or user_id!= -1: if len(topic_tag_list) != 0 or topic_user_id!= -1:
query_function_score = { query_function_score = {
"query": { "query": {
"bool": { "bool": {
...@@ -520,7 +520,7 @@ class TopicUtils(object): ...@@ -520,7 +520,7 @@ class TopicUtils(object):
} }
} }
if topic_user_id != -1: if topic_user_id != -1:
query_function_score["query"]["bool"]["should"] = { query_function_score["query"]["bool"]["must"] += {
"term": { "term": {
"user_id": topic_user_id "user_id": topic_user_id
} }
......
...@@ -300,8 +300,8 @@ def topic_detail_page_recommend(device_id="", user_id=-1, topic_id=-1, topic_pic ...@@ -300,8 +300,8 @@ def topic_detail_page_recommend(device_id="", user_id=-1, topic_id=-1, topic_pic
if topic_user_id != -1: if topic_user_id != -1:
topic_user_result = TopicUtils.top_get_topic_detail_recommend_list(user_id, topic_id, have_read_topic_list, topic_user_result = TopicUtils.top_get_topic_detail_recommend_list(user_id, topic_id, have_read_topic_list,
size, es_cli_obj, size, es_cli_obj,
index_type="topic", routing="4,5,6", index_type="topic", routing="4,5,6",topic_user_id = topic_user_id
topic_tag_list=topic_tag_list) )
topic_user_size = len(topic_user_result) topic_user_size = len(topic_user_result)
have_read_topic_list.extend(topic_user_result) have_read_topic_list.extend(topic_user_result)
if topic_user_size < size: if topic_user_size < size:
...@@ -342,6 +342,9 @@ def topic_detail_page_recommend(device_id="", user_id=-1, topic_id=-1, topic_pic ...@@ -342,6 +342,9 @@ def topic_detail_page_recommend(device_id="", user_id=-1, topic_id=-1, topic_pic
redis_client.expire(redis_key, 60 * 60 * 24) redis_client.expire(redis_key, 60 * 60 * 24)
result_list = [] result_list = []
logging.warning("topic_tag_result:%s" % str(topic_tag_result))
logging.warning("topic_user_result:%s" % str(topic_user_result))
logging.warning("result:%s" % str(result))
recommend_topic_ids_list = list() recommend_topic_ids_list = list()
recommend_topic_ids_list.extend(topic_tag_result) recommend_topic_ids_list.extend(topic_tag_result)
recommend_topic_ids_list.extend(topic_user_result) recommend_topic_ids_list.extend(topic_user_result)
......
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