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
2dd629c9
Commit
2dd629c9
authored
May 05, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify pictorial sort
parent
cae0f3ad
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
12 deletions
+71
-12
group.py
search/utils/group.py
+63
-10
group.py
search/views/group.py
+8
-2
No files found.
search/utils/group.py
View file @
2dd629c9
...
...
@@ -47,23 +47,76 @@ class GroupUtils(object):
return
{
"total_count"
:
0
,
"hits"
:
[]}
@classmethod
def
get_hot_pictorial_recommend_result_list
(
cls
,
offset
,
size
,
es_cli_obj
=
None
):
def
get_hot_pictorial_recommend_result_list
(
cls
,
offset
,
size
,
es_cli_obj
=
None
,
attention_tag_list
=
[]
):
try
:
if
not
es_cli_obj
:
es_cli_obj
=
ESPerform
.
get_cli
()
q
=
dict
()
q
[
"query"
]
=
{
"bool"
:{
"must"
:[
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:{
"is_deleted"
:
False
}},
{
"term"
:
{
"effective"
:
True
}}
]
functions_list
=
list
()
for
tag_id
in
attention_tag_list
:
functions_list
.
append
({
"filter"
:{
"constant_score"
:{
"filter"
:{
"term"
:{
"tag_id"
:
tag_id
}
}
},
"weight"
:
20
}
})
if
len
(
functions_list
)
>=
20
:
break
functions_list
.
append
(
{
"gauss"
:
{
"create_time"
:
{
"scale"
:
"1d"
,
"decay"
:
0.99
}
},
"weight"
:
60
}
)
q
=
{
"query"
:{
"function_score"
:{
"query"
:{
"bool"
:{
"filter"
:[
{
"term"
:
{
"is_online"
:
True
}},
{
"term"
:
{
"is_deleted"
:
False
}},
{
"term"
:
{
"effective"
:
True
}}
]
}
},
"score_mode"
:
"sum"
,
"boost_mode"
:
"sum"
,
"functions"
:
functions_list
}
}
}
q
[
"sort"
]
=
[
{
"high_quality_topic_num"
:{
"order"
:
"desc"
}}
{
"_script"
:
{
"type"
:
"number"
,
"script"
:
{
"lang"
:
"expression"
,
"source"
:
"_score+doc['offline_score']"
# "lang":"painless",
# "source":"_score+params._source.offline_score"
},
"order"
:
"desc"
}
},
{
"_score"
:{
"order"
:
"desc"
}
}
]
q
[
"_source"
]
=
{
"includes"
:[
"id"
]
...
...
search/views/group.py
View file @
2dd629c9
...
...
@@ -52,9 +52,15 @@ def pictorial_sort(user_id=-1, sort_type=GroupSortTypes.HOT_RECOMMEND, offset=0,
es_cli_obj
=
ESPerform
.
get_cli
()
if
sort_type
==
GroupSortTypes
.
HOT_RECOMMEND
:
pictorial_ids_list
=
GroupUtils
.
get_hot_pictorial_recommend_result_list
(
offset
,
size
,
es_cli_obj
)
return
{
"pictorial_recommend_ids"
:
pictorial_ids_list
}
# 用户关注标签
attention_tag_list
=
list
()
if
user_id
>
0
:
redis_tag_data
=
redis_client
.
hget
(
"physical:linucb:register_user_tag_info"
,
user_id
)
attention_tag_list
=
json
.
loads
(
redis_tag_data
)
if
redis_tag_data
else
[]
pictorial_ids_list
=
GroupUtils
.
get_hot_pictorial_recommend_result_list
(
offset
,
size
,
es_cli_obj
,
attention_tag_list
)
return
{
"pictorial_recommend_ids"
:
pictorial_ids_list
}
elif
sort_type
==
GroupSortTypes
.
ATTENTION_RECOMMEND
:
attention_pictorial_list
=
GroupUtils
.
get_user_attention_pictorial_list
(
user_id
,
offset
=
0
,
size
=
1
,
es_cli_obj
=
es_cli_obj
)
...
...
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