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
8a9e2f5c
Commit
8a9e2f5c
authored
Jan 29, 2019
by
zhanglu
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' into 'feature/searth_topic'
# Conflicts: # search/views/topic.py
parents
3d8b104e
e07e2a14
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
topic.py
search/utils/topic.py
+7
-1
topic.py
search/views/topic.py
+20
-0
No files found.
search/utils/topic.py
View file @
8a9e2f5c
...
@@ -93,7 +93,7 @@ class TopicUtils(object):
...
@@ -93,7 +93,7 @@ class TopicUtils(object):
return
[]
return
[]
@classmethod
@classmethod
def
get_recommend_topic_ids
(
cls
,
user_id
,
offset
,
size
,
query
=
None
,
query_type
=
TopicPageType
.
FIND_PAGE
,
filter_topic_id_list
=
[]):
def
get_recommend_topic_ids
(
cls
,
user_id
,
offset
,
size
,
query
=
None
,
query_type
=
TopicPageType
.
FIND_PAGE
,
filter_topic_id_list
=
[]
,
must_topic_id_list
=
[]
):
"""
"""
:需增加打散逻辑
:需增加打散逻辑
:remark:获取首页推荐帖子列表
:remark:获取首页推荐帖子列表
...
@@ -203,6 +203,12 @@ class TopicUtils(object):
...
@@ -203,6 +203,12 @@ class TopicUtils(object):
"boost_mode"
:
"sum"
,
"boost_mode"
:
"sum"
,
"functions"
:
functions_list
"functions"
:
functions_list
}
}
if
len
(
must_topic_id_list
)
>
0
:
query_function_score
[
"query"
][
"bool"
][
"must"
]
=
{
"terms"
:{
"id"
:
must_topic_id_list
}
}
if
query_type
==
TopicPageType
.
FIND_PAGE
and
len
(
filter_topic_id_list
)
>
0
:
if
query_type
==
TopicPageType
.
FIND_PAGE
and
len
(
filter_topic_id_list
)
>
0
:
query_function_score
[
"query"
][
"bool"
][
"must_not"
]
=
{
query_function_score
[
"query"
][
"bool"
][
"must_not"
]
=
{
"terms"
:{
"terms"
:{
...
...
search/views/topic.py
View file @
8a9e2f5c
...
@@ -266,3 +266,23 @@ def topic_search(filters, nfilters=None, sorts_by=None, offset=0, size=10):
...
@@ -266,3 +266,23 @@ def topic_search(filters, nfilters=None, sorts_by=None, offset=0, size=10):
except
:
except
:
logging
.
error
(
"catch exception, err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception, err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"topic_ids"
:
[]}
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
=
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
=
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