Commit 7543e7ec authored by 段英荣's avatar 段英荣

modify

parent 5d71c369
......@@ -158,6 +158,12 @@ class TopicUtils(object):
}
}
},
"gauss": {
"update_time": {
"scale": "1d",
"decay": 0.5
}
},
"score_mode": "sum",
"boost_mode": "sum",
"functions": functions_list
......@@ -274,6 +280,12 @@ class TopicUtils(object):
}
}
},
"gauss":{
"update_time":{
"scale":"1d",
"decay":0.5
}
},
"score_mode": "sum",
"boost_mode": "sum",
"functions": functions_list
......
......@@ -13,10 +13,11 @@ from search.utils.common import PickType
@bind("physical/search/pick_celebrity")
def pick_celebrity(user_id,pick_id,offset=0,size=10):
try:
redis_key = "physical:pick_celebrity:" + "user_id:" + str(user_id) + ":pick_id:" + str(pick_id)
have_read_pick_celebrity_ids = list()
redis_key = "physical:pick_celebrity:" + "user_id:" + str(user_id) + ":pick_id:" + str(pick_id)
if user_id != -1:
try:
redis_celebrity_info = redis_client.get(redis_key)
if redis_celebrity_info:
......@@ -27,7 +28,7 @@ def pick_celebrity(user_id,pick_id,offset=0,size=10):
recommend_pick_celebrity_list = PickUtils.get_recommend_celebrity_id_list(pick_id,have_read_pick_celebrity_ids,offset,size)
if len(recommend_pick_celebrity_list) > 0:
if len(recommend_pick_celebrity_list)>0 and user_id!=-1:
total_read_celebrity_ids = have_read_pick_celebrity_ids + recommend_pick_celebrity_list
PickUtils.refresh_redis_data(have_read_celebrity_list=total_read_celebrity_ids,
redis_cli=redis_client,redis_key=redis_key)
......@@ -41,16 +42,18 @@ def pick_celebrity(user_id,pick_id,offset=0,size=10):
@bind("physical/search/pick_topic")
def pick_topic(user_id,pick_id,offset=0,size=10):
try:
redis_key = "physical:pick_topic:" + "user_id:" + str(user_id) + ":pick_id:" + str(pick_id)
have_read_pick_topic_ids = list()
redis_key = "physical:pick_topic:" + "user_id:" + str(user_id) + ":pick_id:" + str(pick_id)
if user_id != -1:
try:
redis_celebrity_info = redis_client.get(redis_key)
if redis_celebrity_info:
have_read_pick_topic_ids = json.loads(redis_celebrity_info)
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
pass
q = dict()
functions_list = [
......@@ -102,7 +105,7 @@ def pick_topic(user_id,pick_id,offset=0,size=10):
if len(result_dict["hits"]) > 0:
recommend_pick_topic_list = [item["_source"]["id"] for item in result_dict["hits"]]
if len(recommend_pick_topic_list) > 0:
if len(recommend_pick_topic_list)>0 and user_id!=-1:
total_read_topic_ids = have_read_pick_topic_ids + recommend_pick_topic_list
PickUtils.refresh_redis_data(have_read_celebrity_list=total_read_topic_ids,
redis_cli=redis_client,redis_key=redis_key)
......
......@@ -13,7 +13,11 @@ from libs.cache import redis_client
@bind("physical/search/home_recommend")
def home_recommend(session_id="",user_id=-1,offset=0,size=10):
"""
:remark:首页推荐,目前只推荐日记,缺少小组打散策略
:remark:首页推荐,目前只推荐日记
:param session_id:
:param user_id:
:param offset:
:param size:
:return:
"""
try:
......@@ -57,6 +61,8 @@ def home_recommend(session_id="",user_id=-1,offset=0,size=10):
"have_read_topic_id":json.dumps(list(have_read_topic_id_tuple))
}
redis_client.hmset(redis_key,redis_dict)
# 每个session key保存15分钟
redis_client.expire(redis_key,15*60*60)
return {"recommend_topic_ids":recommend_topic_ids}
except:
......@@ -67,7 +73,9 @@ def home_recommend(session_id="",user_id=-1,offset=0,size=10):
@bind("physical/search/home_query")
def home_query(session_id="",user_id=-1,query="",offset=0,size=10):
"""
:remark 首页搜索排序,没有做打散,搜索逻辑优化
:remark:首页搜索,目前只推荐日记
:param session_id:
:param user_id:
:param query:
:param offset:
:param size:
......@@ -114,6 +122,8 @@ def home_query(session_id="",user_id=-1,query="",offset=0,size=10):
"have_read_topic_id":json.dumps(list(have_read_topic_id_tuple))
}
redis_client.hmset(redis_key,redis_dict)
# 每个session key保存15分钟
redis_client.expire(redis_key,15*60*60)
return {"recommend_topic_ids":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