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
560d3c2f
Commit
560d3c2f
authored
6 years ago
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
e51ef4f3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
16 deletions
+17
-16
table_scan.py
libs/table_scan.py
+0
-8
topic.py
search/utils/topic.py
+4
-4
topic.py
search/views/topic.py
+13
-2
trans2es_data2es_parallel.py
trans2es/management/commands/trans2es_data2es_parallel.py
+0
-2
No files found.
libs/table_scan.py
View file @
560d3c2f
...
@@ -150,24 +150,17 @@ class TableSlicer(object):
...
@@ -150,24 +150,17 @@ class TableSlicer(object):
def
__init__
(
self
,
queryset
,
chunk_size
=
None
,
chunk_count
=
None
,
sep_list
=
None
):
def
__init__
(
self
,
queryset
,
chunk_size
=
None
,
chunk_count
=
None
,
sep_list
=
None
):
try
:
try
:
logging
.
info
(
"duan add,before assert queryset"
)
assert
isinstance
(
queryset
,
models
.
QuerySet
)
assert
isinstance
(
queryset
,
models
.
QuerySet
)
logging
.
info
(
"duan add,before assert chunk_size"
)
assert
chunk_size
is
None
or
isinstance
(
chunk_size
,
six
.
integer_types
)
assert
chunk_size
is
None
or
isinstance
(
chunk_size
,
six
.
integer_types
)
logging
.
info
(
"duan add,before assert chunk_count"
)
assert
chunk_count
is
None
or
isinstance
(
chunk_count
,
six
.
integer_types
)
assert
chunk_count
is
None
or
isinstance
(
chunk_count
,
six
.
integer_types
)
logging
.
info
(
"duan add,before assert sep_list"
)
assert
sep_list
is
None
or
isinstance
(
sep_list
,
list
)
assert
sep_list
is
None
or
isinstance
(
sep_list
,
list
)
logging
.
info
(
"duan add,before assert chunk_size"
)
assert
(
chunk_size
is
not
None
)
+
(
chunk_count
is
not
None
)
+
(
sep_list
is
not
None
)
==
1
assert
(
chunk_size
is
not
None
)
+
(
chunk_count
is
not
None
)
+
(
sep_list
is
not
None
)
==
1
logging
.
info
(
"duan add,after assert chunk_size"
)
logging
.
info
(
"duan add,sep_list:
%
s"
%
str
(
sep_list
))
if
sep_list
is
not
None
:
if
sep_list
is
not
None
:
sep_list
=
list
(
sep_list
)
sep_list
=
list
(
sep_list
)
else
:
else
:
...
@@ -180,7 +173,6 @@ class TableSlicer(object):
...
@@ -180,7 +173,6 @@ class TableSlicer(object):
for
index
in
index_list
for
index
in
index_list
]
]
logging
.
info
(
"duan add,queryset count:
%
d"
%
count
)
self
.
_model
=
queryset
.
model
self
.
_model
=
queryset
.
model
self
.
_query
=
queryset
.
query
self
.
_query
=
queryset
.
query
self
.
_sep_list
=
[
None
]
+
sep_list
+
[
None
]
self
.
_sep_list
=
[
None
]
+
sep_list
+
[
None
]
...
...
This diff is collapsed.
Click to expand it.
search/utils/topic.py
View file @
560d3c2f
...
@@ -339,7 +339,7 @@ class TopicUtils(object):
...
@@ -339,7 +339,7 @@ class TopicUtils(object):
return
dict
()
return
dict
()
@classmethod
@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
,
offset
,
size
,
es_cli_obj
=
None
):
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
):
"""
"""
:remark 帖子详情页推荐列表,缺少按时间衰减
:remark 帖子详情页推荐列表,缺少按时间衰减
:param user_id:
:param user_id:
...
@@ -381,7 +381,7 @@ class TopicUtils(object):
...
@@ -381,7 +381,7 @@ class TopicUtils(object):
}
}
)
)
# query_tag_term_list = cls.___get_should_term_list(topic_tag_list
)
have_read_topic_list
.
append
(
topic_id
)
query_function_score
=
{
query_function_score
=
{
"query"
:{
"query"
:{
"bool"
:{
"bool"
:{
...
@@ -391,8 +391,8 @@ class TopicUtils(object):
...
@@ -391,8 +391,8 @@ class TopicUtils(object):
{
"term"
:
{
"is_deleted"
:
False
}}
{
"term"
:
{
"is_deleted"
:
False
}}
],
],
"must_not"
:{
"must_not"
:{
"term"
:{
"term
s
"
:{
"id"
:
topic_id
"id"
:
have_read_topic_list
}
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
search/views/topic.py
View file @
560d3c2f
...
@@ -211,7 +211,7 @@ def home_query(device_id="",user_id=-1,query="",offset=0,size=10):
...
@@ -211,7 +211,7 @@ def home_query(device_id="",user_id=-1,query="",offset=0,size=10):
@bind
(
"physical/search/topic_detail_page_recommend"
)
@bind
(
"physical/search/topic_detail_page_recommend"
)
def
topic_detail_page_recommend
(
user_id
=-
1
,
topic_id
=-
1
,
topic_group_id
=-
1
,
topic_user_id
=-
1
,
filter_topic_user_id
=
False
,
offset
=
0
,
size
=
10
):
def
topic_detail_page_recommend
(
device_id
=
""
,
user_id
=-
1
,
topic_id
=-
1
,
topic_group_id
=-
1
,
topic_user_id
=-
1
,
filter_topic_user_id
=
False
,
offset
=
0
,
size
=
10
):
"""
"""
:remark:帖子详情页推荐策略,缺少第一个卡片策略
:remark:帖子详情页推荐策略,缺少第一个卡片策略
:param user_id:
:param user_id:
...
@@ -224,17 +224,28 @@ def topic_detail_page_recommend(user_id=-1,topic_id=-1,topic_group_id=-1,topic_u
...
@@ -224,17 +224,28 @@ def topic_detail_page_recommend(user_id=-1,topic_id=-1,topic_group_id=-1,topic_u
if
not
isinstance
(
user_id
,
int
):
if
not
isinstance
(
user_id
,
int
):
user_id
=
-
1
user_id
=
-
1
redis_key
=
"physical:topic_detail_page_recommend"
+
":user_id:"
+
str
(
user_id
)
+
":device_id:"
+
str
(
device_id
)
have_read_topic_redis_data
=
redis_client
.
get
(
redis_key
)
have_read_topic_list
=
json
.
loads
(
have_read_topic_redis_data
)
if
have_read_topic_redis_data
else
[]
#获取es链接对象
#获取es链接对象
es_cli_obj
=
ESPerform
.
get_cli
()
es_cli_obj
=
ESPerform
.
get_cli
()
# 获取帖子标签列表
# 获取帖子标签列表
topic_tag_list
=
TopicUtils
.
get_topic_tag_id_list
(
topic_id
,
es_cli_obj
)
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
,
topic_user_id
,
filter_topic_user_id
,
offset
,
size
,
es_cli_obj
)
result_list
=
TopicUtils
.
get_topic_detail_recommend_list
(
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
)
recommend_topic_ids_list
=
list
()
recommend_topic_ids_list
=
list
()
if
len
(
result_list
)
>
0
:
if
len
(
result_list
)
>
0
:
recommend_topic_ids_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_list
]
recommend_topic_ids_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_list
]
have_read_topic_list
.
extend
(
recommend_topic_ids_list
)
have_read_topic_len
=
len
(
have_read_topic_list
)
if
have_read_topic_len
>
5000
:
have_read_topic_list
=
have_read_topic_list
[(
have_read_topic_len
-
5000
):]
redis_client
.
set
(
json
.
dumps
(
have_read_topic_list
))
return
{
"recommend_topic_ids"
:
recommend_topic_ids_list
}
return
{
"recommend_topic_ids"
:
recommend_topic_ids_list
}
except
:
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
...
...
This diff is collapsed.
Click to expand it.
trans2es/management/commands/trans2es_data2es_parallel.py
View file @
560d3c2f
...
@@ -116,10 +116,8 @@ class Command(BaseCommand):
...
@@ -116,10 +116,8 @@ class Command(BaseCommand):
type_info
=
get_type_info_map
()[
type_name
]
type_info
=
get_type_info_map
()[
type_name
]
query_set
=
type_info
.
queryset
query_set
=
type_info
.
queryset
logging
.
info
(
"before TableSlicer"
)
slicer
=
TableSlicer
(
queryset
=
query_set
,
chunk_size
=
type_info
.
bulk_insert_chunk_size
)
slicer
=
TableSlicer
(
queryset
=
query_set
,
chunk_size
=
type_info
.
bulk_insert_chunk_size
)
for
chunk
in
slicer
.
chunks
():
for
chunk
in
slicer
.
chunks
():
logging
.
info
(
"in chunks...."
)
job
=
Job
(
job
=
Job
(
sub_index_name
=
type_name
,
sub_index_name
=
type_name
,
type_name
=
type_name
,
type_name
=
type_name
,
...
...
This diff is collapsed.
Click to expand it.
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