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
29f2b897
Commit
29f2b897
authored
Dec 11, 2018
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify
parent
65b11f1f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
26 deletions
+22
-26
type_info.py
trans2es/type_info.py
+22
-26
No files found.
trans2es/type_info.py
View file @
29f2b897
...
@@ -137,33 +137,29 @@ class TypeInfo(object):
...
@@ -137,33 +137,29 @@ class TypeInfo(object):
return
data_list
return
data_list
def
elasticsearch_bulk_insert_data
(
self
,
sub_index_name
,
data_list
,
es
=
None
):
def
elasticsearch_bulk_insert_data
(
self
,
sub_index_name
,
data_list
,
es
=
None
):
if
es
is
None
:
es
=
get_es_list_by_type
(
self
.
type
)
if
not
isinstance
(
es
,
(
list
,
tuple
,)):
es
=
[
es
]
index
=
ESPerform
.
get_official_index_name
(
sub_index_name
=
sub_index_name
,
index_flag
=
"write"
)
bulk_actions
=
[]
for
data
in
data_list
:
bulk_actions
.
append
({
'_op_type'
:
'index'
,
'_index'
:
index
,
'_type'
:
self
.
type
,
'_id'
:
data
[
'id'
],
'_source'
:
data
,
})
es_result
=
None
if
bulk_actions
:
for
t
in
es
:
try
:
es_result
=
elasticsearch
.
helpers
.
bulk
(
client
=
t
,
actions
=
bulk_actions
)
except
Exception
as
e
:
traceback
.
print_exc
()
es_result
=
'error'
return
es_result
# assert (es is not None)
# index = ESPerform.get_official_index_name(sub_index_name=sub_index_name,index_flag="write")
# bulk_actions = []
# for data in data_list:
# bulk_actions.append({
# '_op_type': 'index',
# '_index': index,
# '_type': "_doc",
# '_id': data['id'],
# '_source': data,
# })
#
# es_result = None
# if bulk_actions:
# for t in es:
# try:
# es_result = elasticsearch.helpers.bulk(client=t, actions=bulk_actions)
# except Exception as e:
# traceback.print_exc()
# es_result = 'error'
return
ESPerform
.
es_helpers_bulk
(
es
,
data_list
,
sub_index_name
,
True
)
def
elasticsearch_bulk_insert
(
self
,
sub_index_name
,
instance_iterable
,
es
=
None
):
def
elasticsearch_bulk_insert
(
self
,
sub_index_name
,
instance_iterable
,
es
=
None
):
data_list
=
self
.
bulk_get_data
(
instance_iterable
)
data_list
=
self
.
bulk_get_data
(
instance_iterable
)
...
...
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