Commit a1bcd0ae authored by lixiaofang's avatar lixiaofang

add

parent 6ea69c52
......@@ -163,6 +163,7 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
ret_list.extend(get_tag_wiki_data)
ret_list.extend(get_doctor_hospital_data)
logging.info("get have_read_tips_set:%s" % have_read_tips_set)
if len(result_dict["suggest"]["tips-suggest"]) >= 50:
return ret_list
......@@ -172,7 +173,6 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
value_data = []
QUERY_KEY = "query:search_tip"
query_base64 = base64.b64encode(query.encode('utf8')).decode('utf8')
logging.info("get query_base64:%s" % query_base64)
if redis_client.hget(QUERY_KEY, query_base64) is not None:
value_data = json.loads(redis_client.hget(QUERY_KEY, query_base64))
logging.info("get value_data:%s" % value_data)
......@@ -184,6 +184,8 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
if ori_name not in have_read_tips_set:
have_read_tips_set.add(ori_name)
result_num = i.get(key, 0)
describe = "约" + str(result_num) + "个结果" if result_num else ""
logging.info("get result_num:%s" % result_num)
highlight_marks = u'<ems>%s</ems>' % query
highlight_name = ori_name.replace(query, highlight_marks)
if ori_name == query:
......@@ -191,13 +193,15 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
{"results_num": result_num, "ori_name": ori_name, "id": None, "is_online": True,
"offline_score": 0,
"type_flag": get_tips_word_type(ori_name), "highlight_name": highlight_name,
"describe": ""})
"describe": describe})
else:
wordresemble_ret_list.append(
{"results_num": result_num, "ori_name": ori_name, "id": None, "is_online": True,
"offline_score": 0,
"type_flag": get_tips_word_type(ori_name), "highlight_name": highlight_name,
"describe": ""})
"describe": describe})
logging.info("get query_ret_list:%s" % query_ret_list)
logging.info("get wordresemble_ret_list:%s" % wordresemble_ret_list)
ret_list.extend(query_ret_list)
ret_list.extend(wordresemble_ret_list)
if len(ret_list) >= 50:
......
......@@ -4,13 +4,13 @@ import os
import sys
import logging
import traceback
from libs.tools import tzlc,getMd5Digest
from libs.tools import tzlc, getMd5Digest
from libs.es import ESPerform
from libs.cache import redis_client
import json
from trans2es.commons.commons import get_tips_suggest_list
from trans2es.commons.words_utils import QueryWordAttr,get_tips_word_type
from trans2es.commons.words_utils import QueryWordAttr, get_tips_word_type
class ProduceWikiTransfer(object):
......@@ -35,7 +35,7 @@ class ProduceWikiTransfer(object):
suggest_list = get_tips_suggest_list(instance.name)
return (item_dict,suggest_list)
return (item_dict, suggest_list)
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return ([],[])
\ No newline at end of file
return ([], [])
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