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
alpha
physical
Commits
24a32996
Commit
24a32996
authored
Feb 20, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add query_topic_by_user_similarity
parent
59e9675f
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
1 deletion
+28
-1
topic.py
search/utils/topic.py
+7
-1
topic.py
search/views/topic.py
+21
-0
No files found.
search/utils/topic.py
View file @
24a32996
...
...
@@ -93,7 +93,7 @@ class TopicUtils(object):
return
[]
@classmethod
def
get_recommend_topic_ids
(
cls
,
user_id
,
offset
,
size
,
query
=
None
,
query_type
=
TopicPageType
.
FIND_PAGE
,
filter_topic_id_list
=
[],
test_score
=
False
):
def
get_recommend_topic_ids
(
cls
,
user_id
,
offset
,
size
,
query
=
None
,
query_type
=
TopicPageType
.
FIND_PAGE
,
filter_topic_id_list
=
[],
test_score
=
False
,
must_topic_id_list
=
[]
):
"""
:需增加打散逻辑
:remark:获取首页推荐帖子列表
...
...
@@ -212,6 +212,12 @@ class TopicUtils(object):
"boost_mode"
:
"sum"
,
"functions"
:
functions_list
}
if
len
(
must_topic_id_list
)
>
0
:
query_function_score
[
"query"
][
"bool"
][
"must"
]
=
{
"terms"
:{
"id"
:
must_topic_id_list
}
}
if
len
(
filter_topic_id_list
)
>
0
:
query_function_score
[
"query"
][
"bool"
][
"must_not"
]
=
{
"terms"
:{
...
...
search/views/topic.py
View file @
24a32996
...
...
@@ -346,3 +346,24 @@ def topic_search(filters, nfilters=None, sorts_by=None, offset=0, size=10):
except
:
logging
.
error
(
"catch exception, err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"topic_ids"
:
[]}
@bind
(
"physical/search/query_topic_by_user_similarity"
)
def
query_topic_by_user_similarity
(
topic_similarity_score_dict
,
offset
=
0
,
size
=
10
):
"""
:remark 按帖子所属用户相似度召回帖子
:param tag_id:
:param offset:
:param size:
:return:
"""
try
:
must_topic_id_list
=
list
(
topic_similarity_score_dict
.
keys
())
topic_id_dict
=
TopicUtils
.
get_recommend_topic_ids
(
user_id
=-
1
,
offset
=
offset
,
size
=
size
,
must_topic_id_list
=
must_topic_id_list
)
recommend_topic_ids
=
list
(
topic_id_dict
.
keys
())
return
{
"recommend_topic_ids"
:
recommend_topic_ids
}
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"recommend_topic_id"
:
[]}
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