Commit 9741f3b4 authored by 李小芳's avatar 李小芳

Merge branch 'query_type' into 'master'

Query type

See merge request !92
parents 035d8c6a 378f5712
...@@ -204,8 +204,7 @@ def get_query_by_es(query='', lat=0, lng=0, size=0, offset=0, highlight_query=No ...@@ -204,8 +204,7 @@ def get_query_by_es(query='', lat=0, lng=0, size=0, offset=0, highlight_query=No
ret_list = list() ret_list = list()
doctor_hospital_equal_query = list() doctor_hospital_equal_query = list()
tag_equal_query = list() tag_equal_query = list()
result_dict = ESPerform.get_search_results(ESPerform.get_cli(), sub_index_name=sub_index_name, query_body=q, result_dict = ESPerform.get_search_results(ESPerform.get_cli(), sub_index_name=sub_index_name, query_body=q,offset=offset, size=size, is_suggest_request=True)
offset=offset, size=size, is_suggest_request=True)
for tips_item in result_dict["suggest"]["tips-suggest"]: for tips_item in result_dict["suggest"]["tips-suggest"]:
for hit_item in tips_item["options"]: for hit_item in tips_item["options"]:
hit_item["_source"]["ori_name"] = hit_item["_source"]["ori_name"].replace("超声刀", "超声提升") hit_item["_source"]["ori_name"] = hit_item["_source"]["ori_name"].replace("超声刀", "超声提升")
......
...@@ -68,7 +68,6 @@ class Command(BaseCommand): ...@@ -68,7 +68,6 @@ class Command(BaseCommand):
try: try:
type_info = get_type_info_map()[type_name] type_info = get_type_info_map()[type_name]
query_set = type_info.queryset query_set = type_info.queryset
slicer = TableSlicer(queryset=query_set, chunk_size=type_info.bulk_insert_chunk_size) slicer = TableSlicer(queryset=query_set, chunk_size=type_info.bulk_insert_chunk_size)
for chunk in slicer.chunks(): for chunk in slicer.chunks():
job = Job( job = Job(
......
...@@ -23,7 +23,8 @@ class BrandWikiTransfer(object): ...@@ -23,7 +23,8 @@ class BrandWikiTransfer(object):
suggest_list = list() suggest_list = list()
ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name)) ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name))
if ret_bol: if ret_bol:
item_dict["id"] = getMd5Digest(str(instance.name)) # item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["id"] = "brandwiki_" + str(instance.id)
item_dict["ori_name"] = instance.name item_dict["ori_name"] = instance.name
item_dict["is_online"] = instance.is_online item_dict["is_online"] = instance.is_online
item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name) item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name)
...@@ -49,7 +50,8 @@ class BrandWikiTransferV1(object): ...@@ -49,7 +50,8 @@ class BrandWikiTransferV1(object):
item_dict = dict() item_dict = dict()
ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name), type_v1=True) ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name), type_v1=True)
if ret_bol: if ret_bol:
item_dict["id"] = getMd5Digest(str(instance.name)) # item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["id"] = "brandwiki_" + str(instance.id)
item_dict["ori_name"] = instance.name item_dict["ori_name"] = instance.name
item_dict["is_online"] = instance.is_online item_dict["is_online"] = instance.is_online
item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name) item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name)
......
...@@ -23,7 +23,8 @@ class CollectWikiTransfer(object): ...@@ -23,7 +23,8 @@ class CollectWikiTransfer(object):
suggest_list = list() suggest_list = list()
ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name)) ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name))
if ret_bol: if ret_bol:
item_dict["id"] = getMd5Digest(str(instance.name)) # item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["id"] = "collectwiki_" + str(instance.id)
item_dict["ori_name"] = instance.name item_dict["ori_name"] = instance.name
item_dict["is_online"] = instance.is_online item_dict["is_online"] = instance.is_online
item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name) item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name)
...@@ -49,7 +50,8 @@ class CollectWikiTransferV1(object): ...@@ -49,7 +50,8 @@ class CollectWikiTransferV1(object):
suggest_list = list() suggest_list = list()
ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name), type_v1=True) ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name), type_v1=True)
if ret_bol: if ret_bol:
item_dict["id"] = getMd5Digest(str(instance.name)) # item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["id"] = "collectwiki_" + str(instance.id)
item_dict["ori_name"] = instance.name item_dict["ori_name"] = instance.name
item_dict["is_online"] = instance.is_online item_dict["is_online"] = instance.is_online
item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name) item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name)
......
...@@ -91,7 +91,8 @@ class DoctorTransfer(object): ...@@ -91,7 +91,8 @@ class DoctorTransfer(object):
item_dict = dict() item_dict = dict()
suggest_list = list() suggest_list = list()
if cut_bool == False: if cut_bool == False:
item_dict["id"] = getMd5Digest(str(instance.name)) # item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["id"] = "doctor_" + str(instance.id)
item_dict["ori_name"] = instance.name item_dict["ori_name"] = instance.name
item_dict["is_online"] = instance.is_online item_dict["is_online"] = instance.is_online
item_dict["order_weight"] = QueryWordAttr.get_doctor_query_word_weight(name=instance.name, item_dict["order_weight"] = QueryWordAttr.get_doctor_query_word_weight(name=instance.name,
...@@ -188,7 +189,8 @@ class DoctorTransferV1(object): ...@@ -188,7 +189,8 @@ class DoctorTransferV1(object):
item_dict = dict() item_dict = dict()
suggest_list = list() suggest_list = list()
if not cut_bool: if not cut_bool:
item_dict["id"] = getMd5Digest(str(instance.name)) # item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["id"] = "doctor_" + str(instance.id)
item_dict["ori_name"] = instance.name item_dict["ori_name"] = instance.name
item_dict["is_online"] = instance.is_online item_dict["is_online"] = instance.is_online
item_dict["order_weight"] = QueryWordAttr.get_doctor_query_word_weight(name=instance.name, item_dict["order_weight"] = QueryWordAttr.get_doctor_query_word_weight(name=instance.name,
......
...@@ -30,7 +30,8 @@ class HospitalTransfer(object): ...@@ -30,7 +30,8 @@ class HospitalTransfer(object):
suggest_list = list() suggest_list = list()
if cut_bool == False: if cut_bool == False:
item_dict = dict() item_dict = dict()
item_dict["id"] = getMd5Digest(str(name)) # item_dict["id"] = getMd5Digest(str(name))
item_dict["id"] = "hospital_" + str(instance.id)
item_dict["ori_name"] = name item_dict["ori_name"] = name
item_dict["is_online"] = by_hospital_id_judge_office_online(is_online=instance.is_online, item_dict["is_online"] = by_hospital_id_judge_office_online(is_online=instance.is_online,
hospital_id=instance.id, name=name) hospital_id=instance.id, name=name)
...@@ -81,7 +82,8 @@ class HospitalTransferV1(object): ...@@ -81,7 +82,8 @@ class HospitalTransferV1(object):
suggest_list = list() suggest_list = list()
if cut_bool == False: if cut_bool == False:
item_dict = dict() item_dict = dict()
item_dict["id"] = getMd5Digest(str(name)) # item_dict["id"] = getMd5Digest(str(name))
item_dict["id"] = "hospital_" + str(instance.id)
item_dict["ori_name"] = name item_dict["ori_name"] = name
item_dict["is_online"] = by_hospital_id_judge_office_online(is_online=instance.is_online, item_dict["is_online"] = by_hospital_id_judge_office_online(is_online=instance.is_online,
hospital_id=instance.id, name=name) hospital_id=instance.id, name=name)
......
...@@ -89,7 +89,8 @@ class ItemWikiTransfer(object): ...@@ -89,7 +89,8 @@ class ItemWikiTransfer(object):
ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name)) ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name))
logging.info("get_wiki_query:%s,ret_bol:%s" % (instance.name, ret_bol)) logging.info("get_wiki_query:%s,ret_bol:%s" % (instance.name, ret_bol))
if ret_bol: if ret_bol:
item_dict["id"] = getMd5Digest(str(instance.name)) # item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["id"] = "itemwiki_" + str(instance.id)
item_dict["ori_name"] = instance.name item_dict["ori_name"] = instance.name
item_dict["is_online"] = instance.is_online item_dict["is_online"] = instance.is_online
item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name) item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name)
...@@ -179,7 +180,8 @@ class ItemWikiTransferV1(object): ...@@ -179,7 +180,8 @@ class ItemWikiTransferV1(object):
suggest_list = list() suggest_list = list()
ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name), type_v1=True) ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name), type_v1=True)
if ret_bol: if ret_bol:
item_dict["id"] = getMd5Digest(str(instance.name)) # item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["id"] = "itemwiki_" + str(instance.id)
item_dict["ori_name"] = instance.name item_dict["ori_name"] = instance.name
item_dict["is_online"] = instance.is_online item_dict["is_online"] = instance.is_online
item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name) item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name)
......
...@@ -23,7 +23,8 @@ class ProduceWikiTransfer(object): ...@@ -23,7 +23,8 @@ class ProduceWikiTransfer(object):
suggest_list = list() suggest_list = list()
ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name)) ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name))
if ret_bol: if ret_bol:
item_dict["id"] = getMd5Digest(str(instance.name)) # item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["id"] = "productwiki_" + str(instance.id)
item_dict["ori_name"] = instance.name item_dict["ori_name"] = instance.name
item_dict["is_online"] = instance.is_online item_dict["is_online"] = instance.is_online
item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name) item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name)
...@@ -49,7 +50,8 @@ class ProduceWikiTransferV1(object): ...@@ -49,7 +50,8 @@ class ProduceWikiTransferV1(object):
suggest_list = list() suggest_list = list()
ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name), type_v1=True) ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name), type_v1=True)
if ret_bol: if ret_bol:
item_dict["id"] = getMd5Digest(str(instance.name)) # item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["id"] = "productwiki_" + str(instance.id)
item_dict["ori_name"] = instance.name item_dict["ori_name"] = instance.name
item_dict["is_online"] = instance.is_online item_dict["is_online"] = instance.is_online
item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name) item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name)
......
...@@ -12,7 +12,6 @@ class SearchWord(object): ...@@ -12,7 +12,6 @@ class SearchWord(object):
@classmethod @classmethod
def get_search_query(self, instance): def get_search_query(self, instance):
try: try:
ret_list = list() ret_list = list()
item_dict = dict() item_dict = dict()
...@@ -22,7 +21,8 @@ class SearchWord(object): ...@@ -22,7 +21,8 @@ class SearchWord(object):
ret_bol = QueryWordAttr.save_query_to_redis(query=sub_query) ret_bol = QueryWordAttr.save_query_to_redis(query=sub_query)
is_online = False is_online = False
if ret_bol: if ret_bol:
item_dict["id"] = getMd5Digest(keyword) # item_dict["id"] = getMd5Digest(keyword)
item_dict["id"] = "search_query_" + str(instance.id)
item_dict["ori_name"] = keyword item_dict["ori_name"] = keyword
total_num = QueryWordAttr.get_search_query_results_num(keyword) total_num = QueryWordAttr.get_search_query_results_num(keyword)
if total_num > 3: if total_num > 3:
...@@ -55,7 +55,8 @@ class SearchWord(object): ...@@ -55,7 +55,8 @@ class SearchWord(object):
keyword = str(sub_query).lower() keyword = str(sub_query).lower()
ret_bol = QueryWordAttr.save_query_to_redis(query=sub_query, type_v1=True) ret_bol = QueryWordAttr.save_query_to_redis(query=sub_query, type_v1=True)
if ret_bol: if ret_bol:
item_dict["id"] = getMd5Digest(keyword) # item_dict["id"] = getMd5Digest(keyword)
item_dict["id"] = "search_query_" + str(instance.id)
item_dict["ori_name"] = keyword item_dict["ori_name"] = keyword
if QueryWordAttr.get_search_query_results_num(keyword): if QueryWordAttr.get_search_query_results_num(keyword):
is_online = False if instance.is_delete else True is_online = False if instance.is_delete else True
......
...@@ -169,7 +169,8 @@ class TagTransfer(object): ...@@ -169,7 +169,8 @@ class TagTransfer(object):
item_dict = dict() item_dict = dict()
ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name)) ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name))
if not cut_bool and ret_bol: if not cut_bool and ret_bol:
item_dict["id"] = getMd5Digest(str(instance.name)) # item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["id"] = "tag_" + str(instance.id)
item_dict["ori_name"] = instance.name item_dict["ori_name"] = instance.name
item_dict["is_online"] = instance.is_online item_dict["is_online"] = instance.is_online
item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name) item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name)
...@@ -272,7 +273,8 @@ class TagTransferV1(object): ...@@ -272,7 +273,8 @@ class TagTransferV1(object):
item_dict = dict() item_dict = dict()
ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name), type_v1=True) ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.name), type_v1=True)
if not cut_bool and ret_bol: if not cut_bool and ret_bol:
item_dict["id"] = getMd5Digest(str(instance.name)) # item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["id"] = "tag_" + str(instance.id)
item_dict["ori_name"] = instance.name item_dict["ori_name"] = instance.name
item_dict["is_online"] = instance.is_online item_dict["is_online"] = instance.is_online
item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name) item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.name)
...@@ -282,6 +284,7 @@ class TagTransferV1(object): ...@@ -282,6 +284,7 @@ class TagTransferV1(object):
item_dict["tips_name_type"] = 0 item_dict["tips_name_type"] = 0
ret_list.append(item_dict) ret_list.append(item_dict)
suggest_list = get_tips_suggest_list_v1(str(instance.name).lower()) suggest_list = get_tips_suggest_list_v1(str(instance.name).lower())
logging.info("item_dict:%s, suggest_list:%s" % (item_dict, suggest_list))
return (item_dict, suggest_list) return (item_dict, suggest_list)
except: except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc()) logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......
...@@ -53,7 +53,8 @@ class WordResemble(object): ...@@ -53,7 +53,8 @@ class WordResemble(object):
cut_bool = True cut_bool = True
ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.keyword)) ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.keyword))
if not cut_bool and ret_bol: if not cut_bool and ret_bol:
item_dict["id"] = getMd5Digest(str(instance.keyword)) # item_dict["id"] = getMd5Digest(str(instance.keyword))
item_dict["id"] = "resemble_" + str(instance.id)
item_dict["ori_name"] = instance.keyword item_dict["ori_name"] = instance.keyword
item_dict["is_online"] = True item_dict["is_online"] = True
item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.keyword) item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.keyword)
...@@ -240,7 +241,8 @@ class WordResembleV1(object): ...@@ -240,7 +241,8 @@ class WordResembleV1(object):
cut_bool = True cut_bool = True
ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.keyword), type_v1=True) ret_bol = QueryWordAttr.save_query_to_redis(query=str(instance.keyword), type_v1=True)
if not cut_bool and ret_bol: if not cut_bool and ret_bol:
item_dict["id"] = getMd5Digest(str(instance.keyword)) # item_dict["id"] = getMd5Digest(str(instance.keyword))
item_dict["id"] = "resemble_" + str(instance.id)
item_dict["ori_name"] = instance.keyword item_dict["ori_name"] = instance.keyword
item_dict["is_online"] = True item_dict["is_online"] = True
item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.keyword) item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.keyword)
......
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