Commit 821090cd authored by 段英荣's avatar 段英荣

modify

parent c8615822
...@@ -344,9 +344,6 @@ class TopicUtils(object): ...@@ -344,9 +344,6 @@ class TopicUtils(object):
pick_user_info_list = result_dict["hits"][0]["_source"]["pick_user_id_list"] pick_user_info_list = result_dict["hits"][0]["_source"]["pick_user_id_list"]
pick_user_id_list = [item["user_id"] for item in pick_user_info_list] pick_user_id_list = [item["user_id"] for item in pick_user_info_list]
q = dict()
q["query"] = dict()
functions_list = [ functions_list = [
{ {
"gauss": { "gauss": {
...@@ -391,9 +388,12 @@ class TopicUtils(object): ...@@ -391,9 +388,12 @@ class TopicUtils(object):
"functions": functions_list "functions": functions_list
} }
q["query"]["function_score"] = query_function_score q = dict()
q["query"] = {
"function_score":query_function_score
}
q["_source"] = { q["_source"] = {
"include":["id","group_id","user_id","_score"] "include":["id","group_id","user_id","_score","offline_score","manual_score"]
} }
q["sort"] = [ q["sort"] = [
{ {
...@@ -401,8 +401,9 @@ class TopicUtils(object): ...@@ -401,8 +401,9 @@ class TopicUtils(object):
"type":"number", "type":"number",
"script":{ "script":{
"lang":"painless", "lang":"painless",
"source":"_score" "source":"_score+params._source.offline_score+params._source.manual_score"
} },
"order":"desc"
} }
} }
] ]
...@@ -410,8 +411,7 @@ class TopicUtils(object): ...@@ -410,8 +411,7 @@ class TopicUtils(object):
result_dict = ESPerform.get_search_results(ESPerform.get_cli(), sub_index_name="topic", query_body=q, result_dict = ESPerform.get_search_results(ESPerform.get_cli(), sub_index_name="topic", query_body=q,
offset=offset, size=size) offset=offset, size=size)
return result_dict["hits"]
return list()
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return list() return list()
\ No newline at end of file
...@@ -168,7 +168,7 @@ def topic_detail_page_recommend(user_id=-1,topic_id=-1,topic_group_id=-1,topic_u ...@@ -168,7 +168,7 @@ def topic_detail_page_recommend(user_id=-1,topic_id=-1,topic_group_id=-1,topic_u
@bind("physical/search/tag_aggregation") @bind("physical/search/tag_aggregation")
def tag_aggregation(tag_id, offset, size): def tag_aggregation(user_id,tag_id, offset, size):
""" """
:remark 按标签聚合召回帖子 :remark 按标签聚合召回帖子
:param tag_id: :param tag_id:
...@@ -177,7 +177,12 @@ def tag_aggregation(tag_id, offset, size): ...@@ -177,7 +177,12 @@ def tag_aggregation(tag_id, offset, size):
:return: :return:
""" """
try: try:
return {"recommend_topic_id": []} result_list = TopicUtils.get_tag_aggregation_topic_id_list(user_id,tag_id,offset,size)
recommend_topic_ids_list = list()
if len(result_list)>0:
recommend_topic_ids_list = [item["_source"]["id"] for item in result_list]
return {"recommend_topic_id": recommend_topic_ids_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_id": []} return {"recommend_topic_id": []}
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
"share_num":{"type":"long"}, "share_num":{"type":"long"},
"pick_id_list":{"type":"long"}, "pick_id_list":{"type":"long"},
"offline_score":{"type":"double"},//离线算分 "offline_score":{"type":"double"},//离线算分
"manual_score":{"type":"double"},//人工赋分
"create_time":{"type":"date", "format":"date_time_no_millis"}, "create_time":{"type":"date", "format":"date_time_no_millis"},
"update_time":{"type":"date", "format":"date_time_no_millis"}, "update_time":{"type":"date", "format":"date_time_no_millis"},
"create_time_val":{"type":"long"}, "create_time_val":{"type":"long"},
......
...@@ -39,6 +39,7 @@ class Topic(models.Model): ...@@ -39,6 +39,7 @@ class Topic(models.Model):
group = models.ForeignKey( group = models.ForeignKey(
Group, verbose_name=u"关联的小组", related_name=u"group_topics",null=True, blank=True, default=None, on_delete=models.CASCADE) Group, verbose_name=u"关联的小组", related_name=u"group_topics",null=True, blank=True, default=None, on_delete=models.CASCADE)
user_id = models.IntegerField(verbose_name='用户ID') user_id = models.IntegerField(verbose_name='用户ID')
drop_score = models.IntegerField(verbose_name=u'人工赋分')
description = models.CharField(verbose_name='日记本描述',max_length=200) description = models.CharField(verbose_name='日记本描述',max_length=200)
content = models.CharField(verbose_name='日记本内容',max_length=1000) content = models.CharField(verbose_name='日记本内容',max_length=1000)
share_num = models.IntegerField(verbose_name='') share_num = models.IntegerField(verbose_name='')
......
...@@ -36,6 +36,7 @@ class TopicTransfer(object): ...@@ -36,6 +36,7 @@ class TopicTransfer(object):
res["tag_name_list"] = instance.get_tag_name_list(res["tag_list"]) res["tag_name_list"] = instance.get_tag_name_list(res["tag_list"])
res["offline_score"] = instance.get_topic_offline_score() res["offline_score"] = instance.get_topic_offline_score()
res["manual_score"] = instance.drop_score
create_time = instance.create_time create_time = instance.create_time
tzlc_create_time = tzlc(create_time) tzlc_create_time = tzlc(create_time)
......
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