Commit ad283540 authored by 李小芳's avatar 李小芳

修改mapping

parent 257e255e
...@@ -127,5 +127,6 @@ class Command(BaseCommand): ...@@ -127,5 +127,6 @@ class Command(BaseCommand):
doc_type = "service" doc_type = "service"
if doc_type == "service_ngram": if doc_type == "service_ngram":
doc_type = "service" doc_type = "service"
print(put_mapping(es=es, index_prefix=index_prefix, doc_type=doc_type, print(put_mapping(es=es, index_prefix=index_prefix, doc_type=doc_type,
mapping=m, delete=delete)) mapping=m, delete=delete))
...@@ -36,11 +36,11 @@ def create_index(es, index_prefix, doc_type): ...@@ -36,11 +36,11 @@ def create_index(es, index_prefix, doc_type):
cl = es.indices cl = es.indices
index = es_index_adapt( index = es_index_adapt(
index_prefix=index_prefix, index_prefix=index_prefix,
doc_type=doc_type doc_type="_doc"
) )
if not cl.exists(index=index): if not cl.exists(index=index):
cl.create(index=index) cl.create(index=index)
init_alias(es, index_prefix, doc_type) init_alias(es, index_prefix, "_doc")
return True return True
else: else:
return False return False
...@@ -111,7 +111,7 @@ def put_mapping(es, index_prefix, doc_type, mapping, delete=False): ...@@ -111,7 +111,7 @@ def put_mapping(es, index_prefix, doc_type, mapping, delete=False):
import copy import copy
mapping_copy = copy.deepcopy(mapping) mapping_copy = copy.deepcopy(mapping)
mapping_copy = _mapping_modify(es, doc_type, mapping_copy) mapping_copy = _mapping_modify(es, doc_type, mapping_copy)
return cl.put_mapping(index=index, doc_type=doc_type, body=mapping_copy) return cl.put_mapping(index=index, doc_type="_doc", body=mapping_copy)
def alias_shift(es, alias, old_index, new_index): def alias_shift(es, alias, old_index, new_index):
......
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