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

modify

parent fb058dde
......@@ -10,5 +10,6 @@
<element value="physical.django_init"/>
<element value="search.views.topic"/>
<element value="search.views.pick"/>
<element value="search.views.group"/>
</config>
</gm_rpcd_config>
......@@ -32,7 +32,7 @@ class TopicUtils(object):
return result_dict
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return None
return []
@classmethod
......@@ -228,4 +228,59 @@ class TopicUtils(object):
return (group_topic_ids,not_group_topic_ids)
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return ([],[])
\ No newline at end of file
return ([],[])
@classmethod
def get_topic_detail_recommend(cls,user_id,user_tag_list,topic_group_id,topic_user_id,offset,size):
"""
:remark 帖子详情页推荐策略,缺少按时间衰减
:param user_id:
:param user_tag_list:
:param topic_group_id:
:param topic_user_id:
:param offset:
:param size:
:return:
"""
try:
q = dict()
q["query"] = dict()
functions_list = [
{
"filter": {"term": {
"group_id": topic_group_id}},
"weight": 1,
},
{
"filter": {"term": {
"user_id": topic_user_id}},
"weight": 1000
}
]
query_tag_term_list = cls.___get_should_term_list(user_tag_list)
query_function_score = {
"query":{
"bool":{
"should": query_tag_term_list,
"must": {
"range": {"content_level": {"gte": 3, "lte": 5}}
}
}
},
"score_mode": "sum",
"boost_mode": "sum",
"functions": functions_list
}
q["query"]["function_score"] = query_function_score
q["_source"] = {
"include":["id","group_id","user_id","_score"]
}
result_dict = ESPerform.get_search_results(ESPerform.get_cli(), sub_index_name="topic", query_body=q,
offset=offset, size=size)
return result_dict
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return []
\ No newline at end of file
......@@ -83,8 +83,8 @@ def home_query(user_id=-1,query="",offset=0,size=10):
if len(redis_val_dict) > 0:
group_topic_ids = json.loads(redis_val_dict[b"group_topic_ids"])
not_group_topic_ids = json.loads(redis_val_dict[b"not_group_topic_ids"])
group_topic_ids_index = redis_val_dict[b"group_topic_ids_index"]
not_group_topic_ids_index = redis_val_dict[b"not_group_topic_ids_index"]
group_topic_ids_index = int(redis_val_dict[b"group_topic_ids_index"])
not_group_topic_ids_index = int(redis_val_dict[b"not_group_topic_ids_index"])
if len(group_topic_ids) < (size-1) or len(not_group_topic_ids) < 1:
if len(group_topic_ids) < (size-1):
......@@ -136,6 +136,8 @@ def topic_detail_page_recommend(user_id=-1,topic_id=-1,topic_group_id=-1,topic_u
:return:
"""
try:
user_tag_list = list()
result_dict = TopicUtils.get_topic_detail_recommend(user_id,user_tag_list,topic_group_id,topic_user_id,offset,size)
return {"recommend_topic_ids": []}
except:
......
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