diff --git a/trans2es/management/commands/trans2es_mapping2es.py b/trans2es/management/commands/trans2es_mapping2es.py index b7b749daccb40a2dd83f302df98ab3f15a12e740..62ecc195e55cf4e387209e7b1b25046a4e6485c8 100644 --- a/trans2es/management/commands/trans2es_mapping2es.py +++ b/trans2es/management/commands/trans2es_mapping2es.py @@ -39,17 +39,16 @@ class Command(BaseCommand): if len(options["type"]): if type_name==options["type"]: - ESPerform.put_index_mapping(es_cli, type_name, force_sync=True) + # 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!" % type_name) + ESPerform.create_index(es_cli,type_name) - # 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) + logging.info("begin create [%s] mapping!" % type_name) + ESPerform.put_index_mapping(es_cli,type_name,force_sync=True) if len(options["indices_template"]):