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
45d32a16
Commit
45d32a16
authored
May 05, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify home_query
parent
eadbbcd8
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
7 deletions
+13
-7
topic.py
search/utils/topic.py
+6
-5
topic.py
search/views/topic.py
+7
-2
No files found.
search/utils/topic.py
View file @
45d32a16
...
...
@@ -122,7 +122,7 @@ class TopicUtils(object):
@classmethod
def
get_recommend_topic_ids
(
cls
,
user_id
,
tag_id
,
offset
,
size
,
single_size
,
query
=
None
,
query_type
=
TopicPageType
.
FIND_PAGE
,
filter_topic_id_list
=
[],
test_score
=
False
,
must_topic_id_list
=
[],
recommend_tag_list
=
[],
user_similar_score_list
=
[],
index_type
=
"topic"
,
routing
=
None
,
attention_tag_list
=
[],
current_topic_id
=-
1
,
topic_tag_list
=
[],
topic_user_id
=-
1
):
user_similar_score_list
=
[],
index_type
=
"topic"
,
routing
=
None
,
attention_tag_list
=
[],
current_topic_id
=-
1
,
topic_tag_list
=
[],
topic_user_id
=-
1
,
disable_collpase
=
False
):
"""
:remark:获取首页推荐帖子列表
:param user_id:
...
...
@@ -304,7 +304,7 @@ class TopicUtils(object):
query_function_score
[
"query"
][
"bool"
][
"should"
]
=
[
{
'multi_match'
:
multi_match
},
{
"term"
:
{
"tag_list"
:
tag_id
}},
{
"term"
:
{
"user_nick_name"
:
query
}}
{
"term"
:
{
"user_nick_name
_pre
"
:
query
}}
]
query_function_score
[
"query"
][
"bool"
][
"minimum_should_match"
]
=
1
else
:
...
...
@@ -317,9 +317,10 @@ class TopicUtils(object):
{
"term"
:
{
"is_operation_home_recommend"
:
True
}}
]
q
[
"query"
][
"function_score"
]
=
query_function_score
q
[
"collapse"
]
=
{
"field"
:
"user_id"
}
if
not
disable_collpase
:
q
[
"collapse"
]
=
{
"field"
:
"user_id"
}
# "includes": ["id", "pictorial_id", "offline_score", "user_id", "edit_tag_list"]
q
[
"_source"
]
=
{
"includes"
:
[
"id"
]
...
...
search/views/topic.py
View file @
45d32a16
...
...
@@ -46,7 +46,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
):
query_type
=
TopicPageType
.
HOME_RECOMMEND
,
disable_collpase
=
False
):
try
:
if
query
is
None
:
if
user_id
>
0
:
...
...
@@ -113,7 +113,7 @@ def get_home_recommend_topic_ids(user_id, device_id, tag_id, offset, size, query
topic_id_list
=
list
()
rank_topic_id_list
=
TopicUtils
.
get_recommend_topic_ids
(
user_id
=
user_id
,
tag_id
=
tag_id
,
offset
=
0
,
size
=
size
,
single_size
=
size
,
query
=
query
,
query_type
=
query_type
,
filter_topic_id_list
=
have_read_topic_id_list
,
index_type
=
"topic-high-star"
,
routing
=
"4,5,6"
,
attention_tag_list
=
attention_tag_list
)
filter_topic_id_list
=
have_read_topic_id_list
,
index_type
=
"topic-high-star"
,
routing
=
"4,5,6"
,
attention_tag_list
=
attention_tag_list
,
disable_collpase
=
disable_collpase
)
if
len
(
recommend_topic_list
)
==
6
and
query
is
None
:
if
(
size
<
11
):
...
...
@@ -244,6 +244,11 @@ def home_query(device_id="", tag_id=-1, user_id=-1, query="", offset=0, size=10)
device_id
=
""
recommend_topic_ids
=
get_home_recommend_topic_ids
(
user_id
,
device_id
,
tag_id
,
offset
=
offset
,
size
=
size
,
query
=
query
)
#todo 因为按用户打散,会出现召回数量少于请求数的情况,再次去掉打散请求
if
len
(
recommend_topic_ids
)
>
0
and
len
(
recommend_topic_ids
)
<
size
:
recommend_topic_ids
=
get_home_recommend_topic_ids
(
user_id
,
device_id
,
tag_id
,
offset
=
offset
,
size
=
size
,
query
=
query
,
disable_collpase
=
True
)
return
{
"recommend_topic_ids"
:
recommend_topic_ids
}
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
...
...
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