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

alpha1.2

parent da1d0d49
...@@ -28,10 +28,10 @@ class TopicDocumentField(object): ...@@ -28,10 +28,10 @@ class TopicDocumentField(object):
class TopicPageType(object): class TopicPageType(object):
# 首页推荐 # 首页推荐
HOME_RECOMMEND=0 HOME_RECOMMEND=1
# 发现页面 # 发现页面
FIND_PAGE=1 FIND_PAGE=2
def time_consuming_decorator(func): def time_consuming_decorator(func):
def time_consuming(*args, **kwargs): def time_consuming(*args, **kwargs):
......
...@@ -238,7 +238,7 @@ class TopicUtils(object): ...@@ -238,7 +238,7 @@ class TopicUtils(object):
return [] return []
@classmethod @classmethod
def get_topic_detail_recommend_list(cls,user_id,topic_id,topic_tag_list,topic_group_id,topic_user_id,offset,size): def get_topic_detail_recommend_list(cls,user_id,topic_id,topic_tag_list,topic_group_id,topic_user_id,filter_topic_user_id,offset,size):
""" """
:remark 帖子详情页推荐列表,缺少按时间衰减 :remark 帖子详情页推荐列表,缺少按时间衰减
:param user_id: :param user_id:
...@@ -281,9 +281,9 @@ class TopicUtils(object): ...@@ -281,9 +281,9 @@ class TopicUtils(object):
query_function_score = { query_function_score = {
"query":{ "query":{
"bool":{ "bool":{
"must": { "must": [
"range": {"content_level": {"gte": 3, "lte": 5}} {"range": {"content_level": {"gte": 3, "lte": 5}}}
}, ],
"must_not":{ "must_not":{
"term":{ "term":{
"id":topic_id "id":topic_id
...@@ -296,6 +296,8 @@ class TopicUtils(object): ...@@ -296,6 +296,8 @@ class TopicUtils(object):
"functions": functions_list "functions": functions_list
} }
if filter_topic_user_id:
query_function_score["query"]["bool"]["must"].append({"term": {"user_id": topic_user_id}})
if len(topic_tag_list)>0: if len(topic_tag_list)>0:
query_function_score["query"]["bool"]["should"]={ query_function_score["query"]["bool"]["should"]={
"terms":{ "terms":{
......
...@@ -140,7 +140,7 @@ def home_query(session_id="",user_id=-1,query="",offset=0,size=10): ...@@ -140,7 +140,7 @@ def home_query(session_id="",user_id=-1,query="",offset=0,size=10):
@bind("physical/search/topic_detail_page_recommend") @bind("physical/search/topic_detail_page_recommend")
def topic_detail_page_recommend(user_id=-1,topic_id=-1,topic_group_id=-1,topic_user_id=-1,offset=0,size=10): def topic_detail_page_recommend(user_id=-1,topic_id=-1,topic_group_id=-1,topic_user_id=-1,filter_topic_user_id=False,offset=0,size=10):
""" """
:remark:帖子详情页推荐策略,缺少第一个卡片策略 :remark:帖子详情页推荐策略,缺少第一个卡片策略
:param user_id: :param user_id:
...@@ -156,7 +156,7 @@ def topic_detail_page_recommend(user_id=-1,topic_id=-1,topic_group_id=-1,topic_u ...@@ -156,7 +156,7 @@ def topic_detail_page_recommend(user_id=-1,topic_id=-1,topic_group_id=-1,topic_u
# 获取帖子标签列表 # 获取帖子标签列表
topic_tag_list = TopicUtils.get_topic_tag_id_list(topic_id) topic_tag_list = TopicUtils.get_topic_tag_id_list(topic_id)
result_list = TopicUtils.get_topic_detail_recommend_list(user_id,topic_id,topic_tag_list,topic_group_id,topic_user_id,offset,size) result_list = TopicUtils.get_topic_detail_recommend_list(user_id,topic_id,topic_tag_list,topic_group_id,topic_user_id,filter_topic_user_id,offset,size)
recommend_topic_ids_list = list() recommend_topic_ids_list = list()
if len(result_list)>0: if len(result_list)>0:
recommend_topic_ids_list = [item["_source"]["id"] for item in result_list] recommend_topic_ids_list = [item["_source"]["id"] for item in result_list]
......
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