Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
P
physical
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
physical
Commits
30fa81b9
Commit
30fa81b9
authored
May 27, 2019
by
黄凯
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'hk' into 'master'
revise usefultag See merge request alpha/physical!362
parents
55a14f0d
5329f831
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
22 deletions
+22
-22
topic.py
search/utils/topic.py
+17
-17
topic.py
search/views/topic.py
+5
-5
No files found.
search/utils/topic.py
View file @
30fa81b9
...
...
@@ -337,7 +337,7 @@ class TopicUtils(object):
@classmethod
def
userful_tag_topic_list
(
cls
,
user_id
,
have_read_topic_list
,
size
,
index_type
=
"topic-high-star"
,
routing
=
None
):
index_type
=
"topic-high-star"
,
routing
=
None
,
useful_tag_list
=
[]
):
"""
:remark 帖子详情页推荐列表,缺少按时间衰减
:param user_id:
...
...
@@ -350,22 +350,22 @@ class TopicUtils(object):
"""
try
:
es_cli_obj
=
ESPerform
.
get_cli
()
useful_tag_list
=
list
()
q
=
dict
()
q
[
"query"
]
=
{
"term"
:
{
"user_id"
:
user_id
}
}
q
[
"_source"
]
=
{
"include"
:
[
"useful_tag_list"
]
}
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"user"
,
q
,
0
,
1
)
if
len
(
result_dict
[
"hits"
])
==
0
:
logging
.
warning
(
"not find user_id:
%
d in es!"
%
int
(
user_id
))
else
:
useful_tag_list
=
result_dict
[
"hits"
][
0
][
"_source"
][
"useful_tag_list"
]
#
useful_tag_list = list()
#
q = dict()
#
q["query"] = {
#
"term": {
#
"user_id": user_id
#
}
#
}
#
#
q["_source"] = {
#
"include": ["useful_tag_list"]
#
}
#
result_dict = ESPerform.get_search_results(es_cli_obj, "user", q, 0, 1)
#
if len(result_dict["hits"]) == 0:
#
logging.warning("not find user_id:%d in es!" % int(user_id))
#
else:
#
useful_tag_list = result_dict["hits"][0]["_source"]["useful_tag_list"]
if
len
(
useful_tag_list
)
==
0
:
return
[]
else
:
...
...
search/views/topic.py
View file @
30fa81b9
...
...
@@ -48,7 +48,7 @@ def get_discover_page_topic_ids(user_id, device_id, size, query_type=TopicPageTy
def
get_home_recommend_topic_ids
(
user_id
,
device_id
,
tag_id
,
offset
,
size
,
query
=
None
,
query_type
=
TopicPageType
.
HOME_RECOMMEND
,
promote_topic_list
=
[],
disable_collpase
=
False
,
usefulrecall
=
-
1
):
query_type
=
TopicPageType
.
HOME_RECOMMEND
,
promote_topic_list
=
[],
disable_collpase
=
False
,
usefulrecall
=
-
1
,
useful_tag_list
=
[]
):
try
:
topic_star_routing
=
"6"
index_type
=
"topic-high-star"
...
...
@@ -104,7 +104,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
# 有用标签召回
if
usefulrecall
!=
-
1
:
useful_topic_id_list
=
TopicUtils
.
userful_tag_topic_list
(
user_id
,
have_read_topic_id_list
,
4
,
"topic-high-star"
,
"6"
)
"topic-high-star"
,
"6"
,
useful_tag_list
=
useful_tag_list
)
# user_similar_score_redis_key = "physical:user_similar_score:user_id:" + str(user_id)
# redis_user_similar_score_redis_val = redis_client.get(user_similar_score_redis_key)
# user_similar_score_redis_list = json.loads(
...
...
@@ -206,7 +206,7 @@ def query_tag_id_by_topic(offset=0, size=10, topic_id_list=[], user_id=-1):
@bind
(
"physical/search/home_recommend"
)
def
home_recommend
(
device_id
=
""
,
user_id
=-
1
,
offset
=
0
,
size
=
10
,
query_type
=
TopicPageType
.
HOME_RECOMMEND
,
promote_topic_list
=
[],
usefulrecall
=
-
1
):
def
home_recommend
(
device_id
=
""
,
user_id
=-
1
,
offset
=
0
,
size
=
10
,
query_type
=
TopicPageType
.
HOME_RECOMMEND
,
promote_topic_list
=
[],
usefulrecall
=
-
1
,
useful_tag_list
=
[]
):
"""
:remark:首页推荐,目前只推荐日记
:param session_id:
...
...
@@ -244,9 +244,9 @@ def home_recommend(device_id="", user_id=-1, offset=0, size=10, query_type=Topic
recommend_topic_ids
=
have_read_topic_id_list
[
0
:
size
]
else
:
if
usefulrecall
!=
-
1
:
if
usefulrecall
!=
-
1
and
len
(
useful_tag_list
)
>
0
:
recommend_topic_ids
,
rank_topic_ids
,
useful_topic_ids
=
get_home_recommend_topic_ids
(
user_id
,
device_id
,
tag_id
=
0
,
offset
=
0
,
size
=
size
,
query_type
=
query_type
,
promote_topic_list
=
promote_topic_list
,
usefulrecall
=
usefulrecall
)
query_type
=
query_type
,
promote_topic_list
=
promote_topic_list
,
usefulrecall
=
usefulrecall
,
useful_tag_list
=
useful_tag_list
)
return
{
"linucb_topic_ids"
:
recommend_topic_ids
,
"rank_topic_ids"
:
rank_topic_ids
,
"useful_topic_ids"
:
useful_topic_ids
}
else
:
recommend_topic_ids
,
rank_topic_ids
=
get_home_recommend_topic_ids
(
user_id
,
device_id
,
tag_id
=
0
,
offset
=
0
,
size
=
size
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment