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
4ae7e49f
Commit
4ae7e49f
authored
Jul 05, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改mapping
parent
c4378545
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
66 additions
and
40 deletions
+66
-40
topic.py
search/utils/topic.py
+21
-7
topic.py
search/views/topic.py
+0
-0
topic-high-star.json
trans2es/mapping/topic-high-star.json
+5
-2
topic-star-routing.json
trans2es/mapping/topic-star-routing.json
+13
-10
topic-star.json
trans2es/mapping/topic-star.json
+1
-1
topic.json
trans2es/mapping/topic.json
+9
-8
topic.py
trans2es/models/topic.py
+16
-12
topic_transfer.py
trans2es/utils/topic_transfer.py
+1
-0
No files found.
search/utils/topic.py
View file @
4ae7e49f
...
...
@@ -251,9 +251,9 @@ class TopicUtils(object):
]
if
query
is
not
None
:
# 搜索帖子
multi_fields
=
{
#'description': 200,
#
'description': 200,
'content'
:
300
,
#'name': 400,
#
'name': 400,
'tag_name_list'
:
300
,
}
query_fields
=
[
'^'
.
join
((
k
,
str
(
v
)))
for
(
k
,
v
)
in
multi_fields
.
items
()]
...
...
@@ -329,18 +329,18 @@ class TopicUtils(object):
'query'
:
query
,
'type'
:
'best_fields'
,
'operator'
:
'and'
,
'fields'
:
[
"content"
,
"tag_name_list"
],
'fields'
:
[
"content"
,
"tag_name_list"
],
}
functions_list
+=
[
{
"weight"
:
300
,
"filter"
:{
"bool"
:{
"must"
:{
"filter"
:
{
"bool"
:
{
"must"
:
{
"term"
:
{
"content_level"
:
6
},
},
"minimum_should_match"
:
1
,
"should"
:[
"should"
:
[
{
'multi_match'
:
multi_match
},
{
"term"
:
{
"tag_list"
:
tag_id
}},
{
"term"
:
{
"user_nick_name_pre"
:
query
.
lower
()}}
...
...
@@ -1067,6 +1067,20 @@ class TopicUtils(object):
}
},
})
elif
sort_by
==
TOPIC_SEARCH_SORT
.
TOPIC_ADD_TIME
:
sort_rule
.
append
({
"related_billboard.topic_add_createtime"
:
{
"order"
:
"desc"
,
"nested_path"
:
"related_billboard"
,
"nested_filter"
:
{
"term"
:
{
"related_billboard.pictorial_id"
:
pictorial_id
}
}
},
})
logging
.
info
(
"get picotirial:
%
s"
%
sort_rule
)
return
sort_rule
...
...
search/views/topic.py
View file @
4ae7e49f
This diff is collapsed.
Click to expand it.
trans2es/mapping/topic-high-star.json
View file @
4ae7e49f
{
"dynamic"
:
"strict"
,
{
"dynamic"
:
"strict"
,
"_routing"
:
{
"required"
:
true
},
"properties"
:
{
"id"
:{
"type"
:
"long"
},
...
...
@@ -60,6 +59,7 @@
"type"
:
"nested"
,
"properties"
:{
"pictorial_id"
:{
"type"
:
"long"
},
"topic_add_createtime"
:{
"type"
:
"long"
},
"real_vote_cnt"
:{
"type"
:
"long"
},
"virt_vote_cnt"
:{
"type"
:
"long"
},
"total_vote_cnt"
:{
"type"
:
"long"
}
...
...
@@ -67,3 +67,6 @@
}
}
}
trans2es/mapping/topic-star-routing.json
View file @
4ae7e49f
...
...
@@ -8,18 +8,18 @@
"vote_num"
:{
"type"
:
"long"
},
"total_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
"
},
"name"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"description"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"content"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"content_level"
:{
"type"
:
"text"
},
"user_id"
:{
"type"
:
"long"
},
"user_nick_name"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
//帖子用户名
"user_nick_name"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
//帖子用户名
"user_nick_name_pre"
:
{
"type"
:
"text"
,
"analyzer"
:
"keyword"
},
//不切词的用户名
"group_id"
:{
"type"
:
"long"
},
//所在组ID
"tag_list"
:{
"type"
:
"long"
},
//标签属性
"useful_tag_list"
:{
"type"
:
"long"
},
//有用标签属性
"edit_tag_list"
:{
"type"
:
"long"
},
//编辑标签
"tag_name_list"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
"tag_name_list"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"share_num"
:{
"type"
:
"long"
},
"pick_id_list"
:{
"type"
:
"long"
},
"offline_score"
:{
"type"
:
"double"
},
//离线算分
...
...
@@ -44,14 +44,14 @@
"platform"
:
{
"type"
:
"long"
},
"platform_id"
:
{
"type"
:
"long"
},
"drop_score"
:{
"type"
:
"
double
"
},
//
人工降分
"drop_score"
:{
"type"
:
"
long
"
},
//
人工降分
"sort_score"
:{
"type"
:
"double"
},
//
排序分
"pictorial_id"
:{
"type"
:
"long"
},
//所在组ID
"pictorial_name"
:{
//
所在组名称
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index
"
,
"search_analyzer"
:
"
gm_default_index
"
"analyzer"
:
"
keyword
"
,
"search_analyzer"
:
"
keyword
"
},
"is_excellent"
:{
"type"
:
"long"
},
"is_operation_home_recommend"
:
{
"type"
:
"boolean"
},
//是否首页运营推荐
...
...
@@ -60,10 +60,14 @@
"type"
:
"nested"
,
"properties"
:{
"pictorial_id"
:{
"type"
:
"long"
},
"topic_add_createtime"
:{
"type"
:
"long"
},
"real_vote_cnt"
:{
"type"
:
"long"
},
"virt_vote_cnt"
:{
"type"
:
"long"
},
"total_vote_cnt"
:{
"type"
:
"long"
}
}
}
}
}
\ No newline at end of file
}
trans2es/mapping/topic-star.json
View file @
4ae7e49f
...
...
@@ -44,7 +44,7 @@
"platform"
:
{
"type"
:
"long"
},
"platform_id"
:
{
"type"
:
"long"
},
"drop_score"
:{
"type"
:
"
double
"
},
//
人工降分
"drop_score"
:{
"type"
:
"
long
"
},
//
人工降分
"sort_score"
:{
"type"
:
"double"
},
//
排序分
"pictorial_id"
:{
"type"
:
"long"
},
//所在组ID
...
...
trans2es/mapping/topic.json
View file @
4ae7e49f
...
...
@@ -8,18 +8,18 @@
"vote_num"
:{
"type"
:
"long"
},
"total_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
"
},
"name"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"description"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"content"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"content_level"
:{
"type"
:
"text"
},
"user_id"
:{
"type"
:
"long"
},
"user_nick_name"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
//帖子用户名
"user_nick_name"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
//帖子用户名
"user_nick_name_pre"
:
{
"type"
:
"text"
,
"analyzer"
:
"keyword"
},
//不切词的用户名
"group_id"
:{
"type"
:
"long"
},
//所在组ID
"tag_list"
:{
"type"
:
"long"
},
//标签属性
"useful_tag_list"
:{
"type"
:
"long"
},
//有用标签属性
"edit_tag_list"
:{
"type"
:
"long"
},
//编辑标签
"tag_name_list"
:{
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index"
,
"search_analyzer"
:
"gm_default_index
"
},
"tag_name_list"
:{
"type"
:
"text"
,
"analyzer"
:
"
keyword"
,
"search_analyzer"
:
"keyword
"
},
"share_num"
:{
"type"
:
"long"
},
"pick_id_list"
:{
"type"
:
"long"
},
"offline_score"
:{
"type"
:
"double"
},
//离线算分
...
...
@@ -44,14 +44,14 @@
"platform"
:
{
"type"
:
"long"
},
"platform_id"
:
{
"type"
:
"long"
},
"drop_score"
:{
"type"
:
"
double
"
},
//
人工降分
"drop_score"
:{
"type"
:
"
long
"
},
//
人工降分
"sort_score"
:{
"type"
:
"double"
},
//
排序分
"pictorial_id"
:{
"type"
:
"long"
},
//所在组ID
"pictorial_name"
:{
//
所在组名称
"type"
:
"text"
,
"analyzer"
:
"
gm_default_index
"
,
"search_analyzer"
:
"
gm_default_index
"
"analyzer"
:
"
keyword
"
,
"search_analyzer"
:
"
keyword
"
},
"is_excellent"
:{
"type"
:
"long"
},
"is_operation_home_recommend"
:
{
"type"
:
"boolean"
},
//是否首页运营推荐
...
...
@@ -60,6 +60,7 @@
"type"
:
"nested"
,
"properties"
:{
"pictorial_id"
:{
"type"
:
"long"
},
"topic_add_createtime"
:{
"type"
:
"long"
},
"real_vote_cnt"
:{
"type"
:
"long"
},
"virt_vote_cnt"
:{
"type"
:
"long"
},
"total_vote_cnt"
:{
"type"
:
"long"
}
...
...
trans2es/models/topic.py
View file @
4ae7e49f
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from
__future__
import
unicode_literals
,
absolute_import
,
print_function
from
django.conf
import
settings
from
django.core.management.base
import
BaseCommand
,
CommandError
import
traceback
import
logging
import
datetime
import
time
from
libs.es
import
ESPerform
from
django.db
import
models
import
datetime
from
alpha_types.venus
import
GRAP_PLATFORM
from
.pick_topic
import
PickTopic
from
.tag
import
TopicTag
,
Tag
from
.user_extra
import
UserExtra
...
...
@@ -203,7 +202,7 @@ class Topic(models.Model):
tag_id_list
=
TopicTag
.
objects
.
using
(
settings
.
SLAVE_DB_NAME
)
.
filter
(
topic_id
=
self
.
id
,
is_collection
=
1
)
.
values_list
(
"tag_id"
,
flat
=
True
)
return
list
(
tag_id_list
)
return
list
(
tag_id_list
)
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
[]
...
...
@@ -283,25 +282,29 @@ class Topic(models.Model):
def
get_related_billboard
(
self
):
try
:
pictorial_ids
=
Topic
.
get_pictorial_id
(
self
)
#
pictorial_ids = Topic.get_pictorial_id(self)
pictorial_id_list
=
[]
related_billboard_list
=
list
()
for
pictorial_id
in
pictorial_ids
:
pictorials
=
PictorialTopic
.
objects
.
filter
(
topic_id
=
self
.
id
)
.
values
(
"pictorial_id"
,
"create_time"
)
for
pictorial_id
in
pictorials
:
query_result
=
TopicBillBoard
.
objects
.
filter
(
pictorial_id
=
pictorial_id
,
query_result
=
TopicBillBoard
.
objects
.
filter
(
pictorial_id
=
pictorial_id
.
get
(
'pictorial_id'
,
None
)
,
topic_id
=
self
.
id
)
.
values
()
.
first
()
if
query_result
==
None
:
related_billboard_list
.
append
({
"pictorial_id"
:
pictorial_id
,
"real_vote_cnt"
:
0
,
"virt_vote_cnt"
:
0
,
"total_vote_cnt"
:
0
})
related_billboard_list
.
append
({
"pictorial_id"
:
pictorial_id
.
get
(
'pictorial_id'
,
None
),
"real_vote_cnt"
:
0
,
"virt_vote_cnt"
:
0
,
"total_vote_cnt"
:
0
,
"topic_add_createtime"
:
int
(
time
.
mktime
(
pictorial_id
.
get
(
"create_time"
,
None
)
.
timetuple
()))})
else
:
total_vote_cnt
=
int
(
query_result
[
"virt_vote_cnt"
])
+
int
(
query_result
[
"real_vote_cnt"
])
related_billboard_list
.
append
(
{
"pictorial_id"
:
query_result
[
"pictorial_id"
],
"real_vote_cnt"
:
query_result
[
"real_vote_cnt"
],
"virt_vote_cnt"
:
query_result
[
"virt_vote_cnt"
],
"total_vote_cnt"
:
total_vote_cnt
})
"virt_vote_cnt"
:
query_result
[
"virt_vote_cnt"
],
"total_vote_cnt"
:
total_vote_cnt
,
"topic_add_createtime"
:
int
(
time
.
mktime
(
pictorial_id
.
get
(
"create_time"
,
None
)
.
timetuple
()))})
logging
.
info
(
"product_brand_info"
%
related_billboard_list
)
...
...
@@ -342,6 +345,7 @@ class PictorialTopic(models.Model):
topic_id
=
models
.
BigIntegerField
(
verbose_name
=
u'帖子ID'
)
is_online
=
models
.
BooleanField
(
verbose_name
=
u"是否有效"
,
default
=
True
)
is_deleted
=
models
.
BooleanField
(
verbose_name
=
u'是否删除'
)
create_time
=
models
.
DateTimeField
(
verbose_name
=
u'创建时间'
,
default
=
datetime
.
datetime
.
fromtimestamp
(
0
))
class
TopicExtra
(
models
.
Model
):
...
...
trans2es/utils/topic_transfer.py
View file @
4ae7e49f
...
...
@@ -8,6 +8,7 @@ from libs.tools import tzlc
import
time
import
re
import
datetime
from
trans2es.models.user
import
User
from
trans2es.models.topic
import
ExcellentTopic
,
TopicHomeRecommend
...
...
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