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
09e9f154
Commit
09e9f154
authored
6 years ago
by
段英荣
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modify mapping bug
parent
e68270df
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
11 deletions
+15
-11
es.py
libs/es.py
+2
-2
trans2es_mapping2es.py
trans2es/management/commands/trans2es_mapping2es.py
+13
-9
No files found.
libs/es.py
View file @
09e9f154
...
@@ -94,7 +94,7 @@ class ESPerform(object):
...
@@ -94,7 +94,7 @@ class ESPerform(object):
return
False
return
False
@classmethod
@classmethod
def
put_index_mapping
(
cls
,
es_cli
,
sub_index_name
,
mapping_type
=
"_doc"
):
def
put_index_mapping
(
cls
,
es_cli
,
sub_index_name
,
mapping_type
=
"_doc"
,
force_sync
=
False
):
"""
"""
:remark: put index mapping
:remark: put index mapping
:param es_cli:
:param es_cli:
...
@@ -107,7 +107,7 @@ class ESPerform(object):
...
@@ -107,7 +107,7 @@ class ESPerform(object):
write_alias_name
=
cls
.
get_official_index_name
(
sub_index_name
,
"write"
)
write_alias_name
=
cls
.
get_official_index_name
(
sub_index_name
,
"write"
)
index_exist
=
es_cli
.
indices
.
exists
(
write_alias_name
)
index_exist
=
es_cli
.
indices
.
exists
(
write_alias_name
)
if
not
index_exist
:
if
not
index_exist
and
not
force_sync
:
return
False
return
False
mapping_dict
=
cls
.
__load_mapping
(
sub_index_name
)
mapping_dict
=
cls
.
__load_mapping
(
sub_index_name
)
...
...
This diff is collapsed.
Click to expand it.
trans2es/management/commands/trans2es_mapping2es.py
View file @
09e9f154
...
@@ -37,15 +37,19 @@ class Command(BaseCommand):
...
@@ -37,15 +37,19 @@ class Command(BaseCommand):
for
type_name
in
type_name_list
:
for
type_name
in
type_name_list
:
if
len
(
options
[
"type"
]):
if
len
(
options
[
"type"
]):
if
options
[
"type"
]
==
"all"
or
type_name
==
options
[
"type"
]:
if
type_name
==
options
[
"type"
]:
official_index_name
=
ESPerform
.
get_official_index_name
(
type_name
)
index_exists
=
es_cli
.
indices
.
exists
(
official_index_name
)
ESPerform
.
put_index_mapping
(
es_cli
,
type_name
,
force_sync
=
True
)
if
not
index_exists
:
logging
.
info
(
"begin create [
%
s] index and mapping!"
%
type_name
)
ESPerform
.
create_index
(
es_cli
,
type_name
)
# official_index_name = ESPerform.get_official_index_name(type_name)
ESPerform
.
put_index_mapping
(
es_cli
,
type_name
)
# index_exists = es_cli.indices.exists(official_index_name)
else
:
# if not index_exists:
logging
.
warning
(
"index:[
%
s] has already existing!"
%
type_name
)
# logging.info("begin create [%s] index and mapping!" % type_name)
# ESPerform.create_index(es_cli,type_name)
# ESPerform.put_index_mapping(es_cli,type_name)
# else:
# logging.warning("index:[%s] has already existing!" % type_name)
if
len
(
options
[
"indices_template"
]):
if
len
(
options
[
"indices_template"
]):
...
...
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