Commit d9111408 authored by lixiaofang's avatar lixiaofang

add

parent 8ebb295a
......@@ -95,10 +95,7 @@ def get_suggest_tips(query, lat, lng, offset=0, size=50):
QUERY_KEY = "query:{}:search_tips"
query_base64 = base64.b64encode(query.encode('utf8')).decode('utf8')
key = QUERY_KEY.format(query_base64)
logging.info("get key:%s" % key)
labels = list(map(lambda x: x.decode("utf8"), list(redis_client.smembers(key))))
logging.info("get labels:%s" % labels)
for i in labels:
ori = i.split(":")[0]
ori_name = base64.b64decode(ori.encode('utf8')).decode('utf8')
......
......@@ -170,7 +170,6 @@ from gm_types.doris import MIND_TYPE
QUERY_KEY = "query:{}:set"
LABEL_VALUE = {
MIND_TYPE.PROJECT: 8,
MIND_TYPE.HOSPITAL: 7,
......@@ -202,8 +201,5 @@ def get_tips_word_type(query=''):
labels.append(MIND_TYPE.UNKNOWN)
if query in QUERY_WORD_LABEL_NEED_MODIFIED:
labels.append(MIND_TYPE.PROJECT)
logging.info("get labels:%s" % labels)
labels.sort(key=label_key, reverse=True)
return labels[0]
......@@ -147,18 +147,6 @@ class TypeInfo(object):
suggest_dict["suggest_type"] = suggest_item["suggest_type"]
suggest_dict["offline_score"] = suggest_item["word_weight"] + suggest_dict["order_weight"]
suggest_dict["id"] = str(suggest_dict["id"]) + "_" + str(suggest_item["cur_index"])
# if suggest_item["suggest_type"] == 1 and item_dict["tips_name_type"] == 4:
# for resemble in resemble_list:
# suggest_item["input"].append(str(resemble))
#
# suggest_dict["suggest"] = {
# "input": suggest_item["input"],
# "weight": int(suggest_dict["offline_score"]),
# "contexts": {
# "is_online": suggest_dict["is_online"]
# }
# }
# else:
suggest_dict["suggest"] = {
"input": suggest_item["input"],
"weight": int(suggest_dict["offline_score"]),
......@@ -167,18 +155,17 @@ class TypeInfo(object):
}
}
data_list.append(suggest_dict)
# if item_dict["tips_name_type"] != 4:
for resemble_item in resemble_list:
resemble_dict = copy.deepcopy(suggest_dict)
resemble_dict["id"] = suggest_dict["id"] + "_" + getMd5Digest(resemble_item)
resemble_dict["ori_name"] = resemble_item
resemble_dict["results_num"] = QueryWordAttr.get_query_results_num(resemble_item)
resemble_dict["offline_score"] = 0
resemble_dict["suggest"]["weight"] = 0
data_list.append(resemble_dict)
# else:
# pass
if item_dict["tips_name_type"] != 4:
for resemble_item in resemble_list:
resemble_dict = copy.deepcopy(suggest_dict)
resemble_dict["id"] = suggest_dict["id"] + "_" + getMd5Digest(resemble_item)
resemble_dict["ori_name"] = resemble_item
resemble_dict["results_num"] = QueryWordAttr.get_query_results_num(resemble_item)
resemble_dict["offline_score"] = 0
resemble_dict["suggest"]["weight"] = 0
data_list.append(resemble_dict)
else:
pass
except Exception:
traceback.print_exc()
logging.exception('bulk_get_data for name={}, doc_type={}, pk={}'.format(
......
......@@ -151,11 +151,9 @@ class WordResemble(object):
# result = wordresemble.WordRel.objects.all().values("keyword", "id")
# for wordrm in result:
logging.info("get instance:%s" % instance.keyword)
query_sql_item = wordresemble.WordRel.objects.filter(keyword=instance.keyword)
for sql_obj in query_sql_item:
words = list(sql_obj.all_resembles.all().values_list('word', flat=True))
logging.info("get words:%s" % words)
for items in words:
# 先存储本体词
query_base64 = base64.b64encode(instance.keyword.encode('utf8')).decode('utf8')
......@@ -170,7 +168,6 @@ class WordResemble(object):
total_count = int(redis_val_dict['t'])
# 存储到Redis
logging.info("get items:%s" % items)
value = value_name + str(":" + str(total_count))
redis_client.sadd(key, value)
......
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