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
d0bcfa5e
Commit
d0bcfa5e
authored
Nov 30, 2018
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
ec2cb251
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
11 deletions
+38
-11
topic.py
search/utils/topic.py
+38
-11
No files found.
search/utils/topic.py
View file @
d0bcfa5e
...
...
@@ -69,6 +69,22 @@ class TopicUtils(object):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
False
@classmethod
def
___get_should_term_list
(
cls
,
ori_list
):
try
:
should_term_list
=
list
()
for
term_id
in
ori_list
:
term_dict
=
{
"term"
:{
"tag_list"
:{
"value"
:
term_id
}
}
}
should_term_list
.
append
(
term_dict
)
return
should_term_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
@classmethod
def
get_recommend_topic_ids
(
cls
,
user_id
,
offset
,
size
,
is_first_time
,
group_topic_ids_index
,
not_group_topic_ids_index
,
query
=
None
):
"""
...
...
@@ -115,9 +131,16 @@ class TopicUtils(object):
user_tag_list
=
result_dict
[
"hits"
][
0
][
"_source"
][
"tag_list"
]
q
=
dict
()
q
[
"query"
]
=
dict
()
q
[
"query"
][
"bool"
]
=
{
"must"
:{
"range"
:
{
"content_level"
:
{
"gte"
:
3
,
"lte"
:
5
}}
}
}
"""
q["filter"] = {
"range": {"content_level": {"gte": 3, "lte": 5}}
}
}
if not is_first_time:
if group_topic_ids_index:
q["filter"]["range"]["group_id"] = {
...
...
@@ -126,29 +149,35 @@ class TopicUtils(object):
else:
q["filter"]["range"]["group_id"] = {
"lt": 0
}
}
"""
attention_user_id_term_list
=
cls
.
___get_should_term_list
(
attention_chinese_user_id_list
+
attention_japan_user_id_list
+
attention_korea_user_id_list
)
pick_user_id_term_list
=
cls
.
___get_should_term_list
(
pick_chinese_user_id_list
+
pick_japan_user_id_list
+
pick_korea_user_id_list
)
same_group_user_id_term_list
=
cls
.
___get_should_term_list
(
same_group_chinese_user_id_list
+
same_group_japan_user_id_list
+
same_group_korea_user_id_list
)
functions_list
=
[
{
"filter"
:
{
"
match
"
:
{
"
user_id"
:
attention_chinese_user_id_list
+
attention_japan_user_id_list
+
attention_korea_user_id
_list
}},
"filter"
:
{
"
bool
"
:
{
"
should"
:
attention_user_id_term
_list
}},
"weight"
:
5
,
},
{
"filter"
:
{
"match"
:
{
"user_id"
:
pick_
chinese_user_id_list
+
pick_japan_user_id_list
+
pick_korea_user_id
_list
}},
"user_id"
:
pick_
user_id_term
_list
}},
"weight"
:
3
},
{
"filter"
:
{
"match"
:
{
"user_id"
:
same_group_
chinese_user_id_list
+
same_group_japan_user_id_list
+
same_group_korea_user_id
_list
}},
"user_id"
:
same_group_
user_id_term
_list
}},
"weight"
:
2
}
]
query_tag_term_list
=
cls
.
___get_should_term_list
(
user_tag_list
)
query_function_score
=
{
"query"
:
{
"
match
"
:
{
"
tag_list"
:
user_tag
_list
"
bool
"
:
{
"
should"
:
query_tag_term
_list
}
},
"score_mode"
:
"sum"
,
...
...
@@ -156,9 +185,7 @@ class TopicUtils(object):
"functions"
:
functions_list
}
q
[
"query"
]
=
{
"function_score"
:
query_function_score
}
q
[
"query"
][
"function_score"
]
=
query_function_score
if
query
is
not
None
:
#搜索帖子
multi_fields
=
{
...
...
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