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
ac4b0fee
Commit
ac4b0fee
authored
Mar 20, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
887acd9d
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
27 deletions
+28
-27
workspace.xml
.idea/workspace.xml
+0
-0
group.py
search/utils/group.py
+7
-6
topic.py
search/utils/topic.py
+14
-14
group.py
search/views/group.py
+5
-5
topic.py
search/views/topic.py
+2
-2
No files found.
.idea/workspace.xml
View file @
ac4b0fee
This diff is collapsed.
Click to expand it.
search/utils/group.py
View file @
ac4b0fee
...
...
@@ -113,7 +113,7 @@ class GroupUtils(object):
return
[]
@classmethod
def
get_
group
_ids_by_aggs
(
cls
,
pictorial_ids_list
,
es_cli_obj
=
None
):
def
get_
pictorial
_ids_by_aggs
(
cls
,
pictorial_ids_list
,
es_cli_obj
=
None
):
"""
:remark:聚合查询获取小组列表
:param group_id_list:
...
...
@@ -131,9 +131,9 @@ class GroupUtils(object):
}
}
q
[
"aggs"
]
=
{
"
group
_ids"
:{
"
pictorial
_ids"
:{
"terms"
:{
"field"
:
"
group
_id"
"field"
:
"
pictorial
_id"
},
"aggs"
:{
"max_date"
:{
...
...
@@ -146,12 +146,12 @@ class GroupUtils(object):
}
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
"topic"
,
q
,
aggregations_query
=
True
)
buckets_list
=
result_dict
[
"aggregations"
][
"
group
_ids"
][
"buckets"
]
buckets_list
=
result_dict
[
"aggregations"
][
"
pictorial
_ids"
][
"buckets"
]
sorted_buckets_list
=
sorted
(
buckets_list
,
key
=
lambda
item
:
item
[
"max_date"
][
"value"
],
reverse
=
True
)
sorted_
group
_id_list
=
[
item
[
"key"
]
for
item
in
sorted_buckets_list
]
sorted_
pictorial
_id_list
=
[
item
[
"key"
]
for
item
in
sorted_buckets_list
]
return
sorted_
group
_id_list
return
sorted_
pictorial
_id_list
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
\ No newline at end of file
search/utils/topic.py
View file @
ac4b0fee
...
...
@@ -32,7 +32,7 @@ class TopicUtils(object):
}
}
q
[
"_source"
]
=
[
"tag_list"
,
"attention_user_id_list"
,
"pick_user_id_list"
,
"same_
group
_user_id_list"
]
q
[
"_source"
]
=
[
"tag_list"
,
"attention_user_id_list"
,
"pick_user_id_list"
,
"same_
pictorial
_user_id_list"
]
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
"user"
,
q
,
offset
,
size
)
...
...
@@ -101,7 +101,7 @@ class TopicUtils(object):
}
},
"_source"
:{
"includes"
:
[
"id"
,
"
group
_id"
,
"offline_score"
,
"user_id"
,
"edit_tag_list"
]
"includes"
:
[
"id"
,
"
pictorial
_id"
,
"offline_score"
,
"user_id"
,
"edit_tag_list"
]
}
}
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
sub_index_name
=
"topic"
,
query_body
=
q
,
...
...
@@ -148,9 +148,9 @@ class TopicUtils(object):
pick_user_info_list
=
result_dict
[
"hits"
][
0
][
"_source"
][
"pick_user_id_list"
]
pick_user_id_list
=
[
item
[
"user_id"
]
for
item
in
pick_user_info_list
]
same_
group_user_info_list
=
result_dict
[
"hits"
][
0
][
"_source"
][
"same_group
_user_id_list"
]
same_
group_id_list
=
[
item
[
"user_id"
]
for
item
in
same_group
_user_info_list
]
same_
group_id_list
=
same_group
_id_list
[:
100
]
same_
pictorial_user_info_list
=
result_dict
[
"hits"
][
0
][
"_source"
][
"same_pictorial
_user_id_list"
]
same_
pictorial_id_list
=
[
item
[
"user_id"
]
for
item
in
same_pictorial
_user_info_list
]
same_
pictorial_id_list
=
same_pictorial
_id_list
[:
100
]
user_tag_list
=
result_dict
[
"hits"
][
0
][
"_source"
][
"tag_list"
]
...
...
@@ -204,11 +204,11 @@ class TopicUtils(object):
"weight"
:
2
}
)
if
len
(
same_
group
_id_list
)
>
0
:
if
len
(
same_
pictorial
_id_list
)
>
0
:
functions_list
.
append
(
{
"filter"
:
{
"bool"
:
{
"should"
:
{
"terms"
:{
"user_id"
:
same_
group
_id_list
}}}},
"should"
:
{
"terms"
:{
"user_id"
:
same_
pictorial
_id_list
}}}},
"weight"
:
1
}
)
...
...
@@ -304,7 +304,7 @@ class TopicUtils(object):
"field"
:
"user_id"
}
q
[
"_source"
]
=
{
"includes"
:[
"id"
,
"
group
_id"
,
"offline_score"
,
"user_id"
,
"edit_tag_list"
]
"includes"
:[
"id"
,
"
pictorial
_id"
,
"offline_score"
,
"user_id"
,
"edit_tag_list"
]
}
q
[
"sort"
]
=
[
{
...
...
@@ -325,7 +325,7 @@ class TopicUtils(object):
offset
=
offset
,
size
=
size
)
topic_id_list
=
list
()
same_
group
_id_set
=
set
()
same_
pictorial
_id_set
=
set
()
same_user_id_set
=
set
()
for
item
in
result_dict
[
"hits"
]:
...
...
@@ -362,7 +362,7 @@ class TopicUtils(object):
return
list
()
@classmethod
def
get_topic_detail_recommend_list
(
cls
,
user_id
,
topic_id
,
topic_tag_list
,
topic_
group
_id
,
topic_user_id
,
filter_topic_user_id
,
have_read_topic_list
,
offset
,
size
,
es_cli_obj
=
None
):
def
get_topic_detail_recommend_list
(
cls
,
user_id
,
topic_id
,
topic_tag_list
,
topic_
pictorial
_id
,
topic_user_id
,
filter_topic_user_id
,
have_read_topic_list
,
offset
,
size
,
es_cli_obj
=
None
):
"""
:remark 帖子详情页推荐列表,缺少按时间衰减
:param user_id:
...
...
@@ -395,11 +395,11 @@ class TopicUtils(object):
}
}
]
if
isinstance
(
topic_
group_id
,
int
)
and
topic_group
_id
>
0
:
if
isinstance
(
topic_
pictorial_id
,
int
)
and
topic_pictorial
_id
>
0
:
functions_list
.
append
(
{
"filter"
:
{
"term"
:
{
"
group_id"
:
topic_group
_id
}},
"
pictorial_id"
:
topic_pictorial
_id
}},
"weight"
:
1
,
}
)
...
...
@@ -435,7 +435,7 @@ class TopicUtils(object):
}
q
[
"query"
][
"function_score"
]
=
query_function_score
q
[
"_source"
]
=
{
"includes"
:[
"id"
,
"
group
_id"
,
"user_id"
,
"_score"
]
"includes"
:[
"id"
,
"
pictorial
_id"
,
"user_id"
,
"_score"
]
}
result_dict
=
ESPerform
.
get_search_results
(
es_cli_obj
,
sub_index_name
=
"topic"
,
query_body
=
q
,
...
...
@@ -547,7 +547,7 @@ class TopicUtils(object):
"function_score"
:
query_function_score
}
q
[
"_source"
]
=
{
"includes"
:[
"id"
,
"
group
_id"
,
"user_id"
,
"_score"
,
"offline_score"
,
"manual_score"
]
"includes"
:[
"id"
,
"
pictorial
_id"
,
"user_id"
,
"_score"
,
"offline_score"
,
"manual_score"
]
}
q
[
"sort"
]
=
[
{
...
...
search/views/group.py
View file @
ac4b0fee
...
...
@@ -12,7 +12,7 @@ from search.utils.common import GroupSortTypes
from
libs.es
import
ESPerform
@bind
(
"physical/search/query_
group
"
)
@bind
(
"physical/search/query_
pictorial
"
)
def
query_group
(
query
=
""
,
offset
=
0
,
size
=
10
):
"""
:remark:小组搜索排序策略,缺少排序策略
...
...
@@ -33,7 +33,7 @@ def query_group(query="",offset=0,size=10):
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
{
"group_ids"
:[]}
@bind
(
"physical/search/
group
_sort"
)
@bind
(
"physical/search/
pictorial
_sort"
)
def
group_sort
(
user_id
=-
1
,
sort_type
=
GroupSortTypes
.
HOT_RECOMMEND
,
offset
=
0
,
size
=
10
):
"""
:remark 小组排序,缺少:前1天发评论人数*x
...
...
@@ -61,14 +61,14 @@ def group_sort(user_id=-1,sort_type=GroupSortTypes.HOT_RECOMMEND,offset=0,size=1
return
{
"pictorial_recommend_ids"
:
[]}
else
:
attention_pictorial_id_list
=
[
item
[
"pictorial_id"
]
for
item
in
attention_pictorial_list
]
sorted_pictorial_ids_list
=
GroupUtils
.
get_
group
_ids_by_aggs
(
attention_pictorial_id_list
,
es_cli_obj
)
sorted_pictorial_ids_list
=
GroupUtils
.
get_
pictorial
_ids_by_aggs
(
attention_pictorial_id_list
,
es_cli_obj
)
pictorial_recommend_ids_list
=
sorted_pictorial_ids_list
#if len(group_recommend_ids_list) < size and len(group_recommend_ids_list)<len(attention_group_list):
sorted_attention_pictorial_list
=
sorted
(
attention_pictorial_list
,
key
=
lambda
item
:
item
[
"update_time_val"
],
reverse
=
True
)
for
item
in
sorted_attention_pictorial_list
:
if
item
[
"
group
_id"
]
not
in
pictorial_recommend_ids_list
:
pictorial_recommend_ids_list
.
append
(
item
[
"
group
_id"
])
if
item
[
"
pictorial
_id"
]
not
in
pictorial_recommend_ids_list
:
pictorial_recommend_ids_list
.
append
(
item
[
"
pictorial
_id"
])
return
{
"pictorial_recommend_ids"
:
pictorial_recommend_ids_list
[
offset
:(
offset
+
size
)]}
...
...
search/views/topic.py
View file @
ac4b0fee
...
...
@@ -225,7 +225,7 @@ def home_query(device_id="", tag_id=-1, user_id=-1, query="", offset=0, size=10)
@bind
(
"physical/search/topic_detail_page_recommend"
)
def
topic_detail_page_recommend
(
device_id
=
""
,
user_id
=-
1
,
topic_id
=-
1
,
topic_
group
_id
=-
1
,
topic_user_id
=-
1
,
def
topic_detail_page_recommend
(
device_id
=
""
,
user_id
=-
1
,
topic_id
=-
1
,
topic_
pictorial
_id
=-
1
,
topic_user_id
=-
1
,
filter_topic_user_id
=
False
,
offset
=
0
,
size
=
10
):
"""
:remark:帖子详情页推荐策略,缺少第一个卡片策略
...
...
@@ -249,7 +249,7 @@ def topic_detail_page_recommend(device_id="", user_id=-1, topic_id=-1, topic_gro
# 获取帖子标签列表
topic_tag_list
=
TopicUtils
.
get_topic_tag_id_list
(
topic_id
,
es_cli_obj
)
result_list
=
TopicUtils
.
get_topic_detail_recommend_list
(
user_id
,
topic_id
,
topic_tag_list
,
topic_
group
_id
,
result_list
=
TopicUtils
.
get_topic_detail_recommend_list
(
user_id
,
topic_id
,
topic_tag_list
,
topic_
pictorial
_id
,
topic_user_id
,
filter_topic_user_id
,
have_read_topic_list
,
offset
,
size
,
es_cli_obj
)
recommend_topic_ids_list
=
list
()
...
...
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