Commit 9636d4c0 authored by 段英荣's avatar 段英荣

Merge branch 'only_no_see' into 'master'

modify mapping bug

See merge request alpha/physical!114
parents cfbf0e94 09e9f154
......@@ -94,7 +94,7 @@ class ESPerform(object):
return False
@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
:param es_cli:
......@@ -107,7 +107,7 @@ class ESPerform(object):
write_alias_name = cls.get_official_index_name(sub_index_name,"write")
index_exist = es_cli.indices.exists(write_alias_name)
if not index_exist:
if not index_exist and not force_sync:
return False
mapping_dict = cls.__load_mapping(sub_index_name)
......
......@@ -37,15 +37,19 @@ class Command(BaseCommand):
for type_name in type_name_list:
if len(options["type"]):
if options["type"] == "all" or type_name==options["type"]:
official_index_name = ESPerform.get_official_index_name(type_name)
index_exists = es_cli.indices.exists(official_index_name)
if not index_exists:
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 type_name==options["type"]:
ESPerform.put_index_mapping(es_cli, type_name, force_sync=True)
# official_index_name = ESPerform.get_official_index_name(type_name)
# index_exists = es_cli.indices.exists(official_index_name)
# if not index_exists:
# 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"]):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment