Commit fd94d0d2 authored by lixiaofang's avatar lixiaofang

mapping

parent 6fdcd970
...@@ -57,7 +57,7 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50): ...@@ -57,7 +57,7 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
if hit_item["_source"]["type_flag"] == "hospital": if hit_item["_source"]["type_flag"] == "hospital":
if lat is not None and lng is not None: if lat is not None and lng is not None and lat != 0.0 and lng != 0.0:
if hit_item["_source"]["ori_name"] in g_hospital_pos_dict: if hit_item["_source"]["ori_name"] in g_hospital_pos_dict:
distance = point_distance(lng, lat, distance = point_distance(lng, lat,
g_hospital_pos_dict[hit_item["_source"]["ori_name"]][0], g_hospital_pos_dict[hit_item["_source"]["ori_name"]][0],
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.conf import settings from django.conf import settings
from django.core.management.base import BaseCommand, CommandError from django.core.management.base import BaseCommand
import traceback import traceback
import logging import logging
from libs.es import ESPerform from libs.es import ESPerform
from trans2es.type_info import get_type_info_map, TypeInfo from trans2es.type_info import get_type_info_map
class Command(BaseCommand): class Command(BaseCommand):
...@@ -30,22 +30,31 @@ class Command(BaseCommand): ...@@ -30,22 +30,31 @@ class Command(BaseCommand):
) )
def handle(self, *args, **options): def handle(self, *args, **options):
try: try:
if not options['type']:
raise logging.info('type name must be specified')
elif not (options['type'] in [
'suggest',
]):
raise logging.info(
'unknown type name, type must be one of [suggest]')
es_cli = ESPerform.get_cli() es_cli = ESPerform.get_cli()
type_name_list = get_type_info_map().keys() type_name = "suggest"
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 options["type"] == "all" or type_name == options["type"]:
official_index_name = ESPerform.get_official_index_name(type_name) official_index_name = ESPerform.get_official_index_name(type_name)
index_exists = es_cli.indices.exists(official_index_name) index_exists = es_cli.indices.exists(official_index_name)
if not index_exists: if not index_exists:
logging.info("begin create [%s] index!" % type_name) logging.info("begin create [%s] index!" % type_name)
ESPerform.create_index(es_cli, type_name) ESPerform.create_index(es_cli, type_name)
logging.info("begin create [%s] mapping!" % type_name) logging.info("begin create [%s] mapping!" % type_name)
ESPerform.put_index_mapping(es_cli, type_name) ESPerform.put_index_mapping(es_cli, type_name)
if len(options["indices_template"]): if len(options["indices_template"]):
template_file_name = options["indices_template"] template_file_name = 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