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
c6999aba
Commit
c6999aba
authored
Apr 02, 2019
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add topic star routing
parent
bb0ffd05
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
97 additions
and
11 deletions
+97
-11
es.py
libs/es.py
+20
-8
topic-high-star.json
trans2es/mapping/topic-high-star.json
+2
-2
topic-star-routing.json
trans2es/mapping/topic-star-routing.json
+54
-0
user.py
trans2es/models/user.py
+9
-0
type_info.py
trans2es/type_info.py
+10
-0
topic_transfer.py
trans2es/utils/topic_transfer.py
+2
-1
No files found.
libs/es.py
View file @
c6999aba
...
...
@@ -154,14 +154,26 @@ class ESPerform(object):
cls
.
put_index_mapping
(
es_cli
,
sub_index_name
)
bulk_actions
=
[]
for
data
in
data_list
:
bulk_actions
.
append
({
'_op_type'
:
'index'
,
'_index'
:
official_index_name
,
'_type'
:
doc_type
,
'_id'
:
data
[
'id'
],
'_source'
:
data
,
})
if
sub_index_name
==
"topic"
:
for
data
in
data_list
:
bulk_actions
.
append
({
'_op_type'
:
'index'
,
'_index'
:
official_index_name
,
'_type'
:
doc_type
,
'_id'
:
data
[
'id'
],
'_source'
:
data
,
'routing'
:
data
[
"content_level"
]
})
else
:
for
data
in
data_list
:
bulk_actions
.
append
({
'_op_type'
:
'index'
,
'_index'
:
official_index_name
,
'_type'
:
doc_type
,
'_id'
:
data
[
'id'
],
'_source'
:
data
,
})
elasticsearch
.
helpers
.
bulk
(
es_cli
,
bulk_actions
)
return
True
...
...
trans2es/mapping/topic-high-star.json
View file @
c6999aba
...
...
@@ -11,6 +11,7 @@
"content"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"content_level"
:{
"type"
:
"text"
},
"user_id"
:{
"type"
:
"long"
},
"user_nick_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
//帖子用户名
"group_id"
:{
"type"
:
"long"
},
//所在组ID
"tag_list"
:{
"type"
:
"long"
},
//标签属性
"edit_tag_list"
:{
"type"
:
"long"
},
//编辑标签
...
...
@@ -50,4 +51,4 @@
}
}
}
\ No newline at end of file
}
trans2es/mapping/topic-star-routing.json
0 → 100644
View file @
c6999aba
{
"dynamic"
:
"strict"
,
"properties"
:
{
"id"
:{
"type"
:
"long"
},
"is_online"
:{
"type"
:
"boolean"
},
//上线
"is_deleted"
:{
"type"
:
"boolean"
},
"vote_num"
:{
"type"
:
"long"
},
"reply_num"
:{
"type"
:
"long"
},
"name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"description"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"content"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"content_level"
:{
"type"
:
"text"
},
"user_id"
:{
"type"
:
"long"
},
"user_nick_name"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
//帖子用户名
"group_id"
:{
"type"
:
"long"
},
//所在组ID
"tag_list"
:{
"type"
:
"long"
},
//标签属性
"edit_tag_list"
:{
"type"
:
"long"
},
//编辑标签
"tag_name_list"
:{
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
},
"share_num"
:{
"type"
:
"long"
},
"pick_id_list"
:{
"type"
:
"long"
},
"offline_score"
:{
"type"
:
"double"
},
//离线算分
"manual_score"
:{
"type"
:
"double"
},
//人工赋分
"has_image"
:{
"type"
:
"boolean"
},
//是否有图
"has_video"
:{
"type"
:
"boolean"
},
//是否是视频
"create_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"update_time"
:{
"type"
:
"date"
,
"format"
:
"date_time_no_millis"
},
"create_time_val"
:{
"type"
:
"long"
},
"update_time_val"
:{
"type"
:
"long"
},
"language_type"
:{
"type"
:
"long"
},
"is_shadow"
:
{
"type"
:
"boolean"
},
"is_recommend"
:
{
"type"
:
"boolean"
},
"is_complaint"
:
{
"type"
:
"boolean"
},
//
是否被举报
"virtual_content_level"
:{
"type"
:
"text"
},
"like_num_crawl"
:
{
"type"
:
"long"
},
//
爬取点赞数
"comment_num_crawl"
:
{
"type"
:
"long"
},
//
爬取评论数
"is_crawl"
:
{
"type"
:
"boolean"
},
"platform"
:
{
"type"
:
"long"
},
"platform_id"
:
{
"type"
:
"long"
},
"drop_score"
:{
"type"
:
"double"
},
//
人工降分
"sort_score"
:{
"type"
:
"double"
},
//
排序分
"pictorial_id"
:{
"type"
:
"long"
},
//所在组ID
"pictorial_name"
:{
//
所在组名称
"type"
:
"text"
,
"analyzer"
:
"gm_default_index"
,
"search_analyzer"
:
"gm_default_index"
}
}
}
trans2es/models/user.py
View file @
c6999aba
...
...
@@ -34,6 +34,15 @@ class User(models.Model):
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
update_time
=
models
.
DateTimeField
(
verbose_name
=
u'更新时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
@classmethod
def
get_user_nick_name
(
cls
,
user_id
):
try
:
nick_name_obj
=
User
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
user_id
=
user_id
)
.
values_list
(
"nick_name"
)
return
nick_name_obj
.
nick_name
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
None
def
get_is_recommend_flag
(
self
):
is_shadow
=
False
is_recommend
=
False
...
...
trans2es/type_info.py
View file @
c6999aba
...
...
@@ -274,6 +274,16 @@ def get_type_info_map():
return
_get_type_info_map_result
type_info_list
=
[
TypeInfo
(
name
=
'topic-star-routing'
,
type
=
'topic-star-routing'
,
model
=
topic
.
Topic
,
query_deferred
=
lambda
:
topic
.
Topic
.
objects
.
all
()
.
query
,
get_data_func
=
TopicTransfer
.
get_topic_data
,
bulk_insert_chunk_size
=
100
,
round_insert_chunk_size
=
5
,
round_insert_period
=
2
,
),
TypeInfo
(
name
=
'topic-high-star'
,
# >=4星日记
type
=
'topic-high-star'
,
...
...
trans2es/utils/topic_transfer.py
View file @
c6999aba
...
...
@@ -8,7 +8,7 @@ from libs.tools import tzlc
import
time
import
re
import
datetime
from
trans2es.models.user
import
User
class
TopicTransfer
(
object
):
...
...
@@ -27,6 +27,7 @@ class TopicTransfer(object):
res
[
"content"
]
=
instance
.
content
res
[
"content_level"
]
=
instance
.
content_level
res
[
"user_id"
]
=
instance
.
user_id
res
[
"user_nick_name"
]
=
User
.
get_user_nick_name
(
instance
.
user_id
)
if
instance
.
group
:
res
[
"group_id"
]
=
instance
.
group
.
id
...
...
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