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
d20d9170
Commit
d20d9170
authored
Jul 08, 2019
by
lixiaofang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add
parent
210be7ef
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
22 deletions
+23
-22
es.py
libs/es.py
+17
-16
product.py
trans2es/models/product.py
+4
-4
product_transfer.py
trans2es/utils/product_transfer.py
+2
-2
No files found.
libs/es.py
View file @
d20d9170
...
...
@@ -155,9 +155,9 @@ class ESPerform(object):
bulk_actions
=
[]
if
sub_index_name
==
"topic"
or
\
sub_index_name
==
"topic-star-routing"
or
\
sub_index_name
==
"topic-high-star"
:
if
sub_index_name
==
"topic"
or
\
sub_index_name
==
"topic-star-routing"
or
\
sub_index_name
==
"topic-high-star"
:
for
data
in
data_list
:
if
data
:
bulk_actions
.
append
({
...
...
@@ -232,7 +232,7 @@ class ESPerform(object):
return
{
"total_count"
:
0
,
"hits"
:
[]}
@classmethod
def
get_analyze_results
(
cls
,
es_cli
,
sub_index_name
,
query_body
):
def
get_analyze_results
(
cls
,
es_cli
,
sub_index_name
,
query_body
):
try
:
assert
(
es_cli
is
not
None
)
...
...
@@ -242,7 +242,7 @@ class ESPerform(object):
logging
.
error
(
"index:
%
s is not existing,get_search_results error!"
%
official_index_name
)
return
None
res
=
es_cli
.
indices
.
analyze
(
index
=
official_index_name
,
body
=
query_body
)
res
=
es_cli
.
indices
.
analyze
(
index
=
official_index_name
,
body
=
query_body
)
return
res
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
...
...
@@ -276,7 +276,7 @@ class ESPerform(object):
if
high_num
>
3
:
logging
.
info
(
"check es_nodes_load high,cpu load:
%
s,ori_cpu_info:
%
s"
%
(
str
(
es_nodes_list
),
str
(
es_nodes_info_list
)))
str
(
es_nodes_list
),
str
(
es_nodes_info_list
)))
return
True
else
:
return
False
...
...
@@ -298,8 +298,8 @@ class ESPerform(object):
functions_list
+=
[
{
"filter"
:
{
"constant_score"
:{
"filter"
:{
"constant_score"
:
{
"filter"
:
{
"term"
:
{
"content_level"
:
6
}}
}
},
...
...
@@ -307,8 +307,8 @@ class ESPerform(object):
},
{
"filter"
:
{
"constant_score"
:{
"filter"
:{
"constant_score"
:
{
"filter"
:
{
"term"
:
{
"content_level"
:
5
}}
}
},
...
...
@@ -316,8 +316,8 @@ class ESPerform(object):
},
{
"filter"
:
{
"constant_score"
:{
"filter"
:{
"constant_score"
:
{
"filter"
:
{
"term"
:
{
"content_level"
:
4
}}
}
},
...
...
@@ -411,7 +411,7 @@ class ESPerform(object):
}
},
"_source"
:
{
"include"
:
[
"id"
,
"user_id"
]
"include"
:
[
"id"
,
"user_id"
]
},
"sort"
:
[
{
"_score"
:
{
"order"
:
"desc"
}},
...
...
@@ -420,7 +420,7 @@ class ESPerform(object):
],
"collapse"
:
{
"field"
:
"user_id"
}
}
}
if
len
(
have_read_topic_id_list
)
>
0
:
...
...
@@ -429,7 +429,8 @@ class ESPerform(object):
"id"
:
have_read_topic_id_list
}
}
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
sub_index_name
=
"topic-high-star"
,
query_body
=
q
,
result_dict
=
ESPerform
.
get_search_results
(
ESPerform
.
get_cli
(),
sub_index_name
=
"topic-high-star"
,
query_body
=
q
,
offset
=
0
,
size
=
size
,
routing
=
"6"
)
topic_id_list
=
[
item
[
"_source"
][
"id"
]
for
item
in
result_dict
[
"hits"
]]
...
...
@@ -441,7 +442,7 @@ class ESPerform(object):
logging
.
info
(
"topic_id_list:
%
s"
%
str
(
topic_id_dict
))
return
topic_id_list
,
topic_id_dict
return
topic_id_list
,
topic_id_dict
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
return
list
()
trans2es/models/product.py
View file @
d20d9170
...
...
@@ -46,9 +46,9 @@ class CommodityProduct(models.Model):
category_id
=
CommodityProductCategory
.
objects
.
filter
(
product_id
=
self
.
id
,
is_deleted
=
False
)
.
values_list
(
"category_id"
,
flat
=
True
)
result_name
=
CommodityCategory
.
objects
.
filter
(
id
=
category_id
,
is_online
=
True
,
is_deleted
=
False
)
.
values_list
(
"cn_name"
,
flat
=
True
)
.
first
()
is_deleted
=
False
)
.
values_list
(
"cn_name"
,
flat
=
True
)
return
result_name
return
list
(
result_name
)
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
...
...
@@ -59,9 +59,9 @@ class CommodityProduct(models.Model):
effect_id
=
CommodityProductEffect
.
objects
.
filter
(
product_id
=
self
.
id
,
is_deleted
=
False
)
.
values_list
(
"effect_id"
,
flat
=
True
)
result_name
=
CommodityEffect
.
objects
.
filter
(
id
=
effect_id
,
is_deleted
=
False
)
.
values_list
(
"cn_name"
,
flat
=
True
)
.
first
()
flat
=
True
)
return
result_name
return
list
(
result_name
)
except
:
logging
.
error
(
"catch exception,err_msg:
%
s"
%
traceback
.
format_exc
())
...
...
trans2es/utils/product_transfer.py
View file @
d20d9170
...
...
@@ -43,13 +43,13 @@ class ProductTransfer(object):
if
category_cn_name
:
res
[
"category_cn_name"
]
=
category_cn_name
else
:
res
[
"category_cn_name"
]
=
""
res
[
"category_cn_name"
]
=
[]
effect_cn_name
=
instance
.
get_effect_cn_name
()
if
effect_cn_name
:
res
[
'effect_cn_name'
]
=
effect_cn_name
else
:
res
[
"effect_cn_name"
]
=
""
res
[
"effect_cn_name"
]
=
[]
logging
.
info
(
"get product:
%
s"
%
res
)
return
res
...
...
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