Commit 1cc300cd authored by lixiaofang's avatar lixiaofang

add

parent f250dc7c
{
"dynamic":"strict",
"properties": {
"id":{"type":"text"},
"suggest":{
"analyzer":"keyword",
"search_analyzer":"keyword",
"type":"completion",
"contexts":[
{
"name":"is_online",
"type": "category"
}
]
},
"suggest_type":{"type":"long"},//0-汉字,1-汉字全拼,2-拼音,3-拼音全拼,4-拼音简写,5-拼音简写全拼
"agile_tag_type":{"type":"long"},//tips数据所属类型,0-tag,1-hospital,2-doctor,3-wiki
"ori_name":{"type":"keyword"},//原名称
"results_num":{"type":"integer"},//结果数量
"is_online":{"type":"boolean"},//上线
"offline_score":{"type":"double"},//离线分
"agile_tag_id":{"type":"long"},//标签ID
"create_tag_type":{"type":"long"},//标签创建类型
"style":{"type":"long"},//新标签样式
"topic_recommend_sort":{"type":"long"},
"api_agile_tag_recommend_type":{"type":"long"}
}
}
{
"dynamic":"strict",
"properties": {
"id":{"type":"text"},
"suggest":{
"analyzer":"keyword",
"search_analyzer":"keyword",
"type":"completion",
"contexts":[
{
"name":"is_online",
"type": "category"
}
]
},
"suggest_type":{"type":"long"},//0-汉字,1-汉字全拼,2-拼音,3-拼音全拼,4-拼音简写,5-拼音简写全拼
"agile_tag_type":{"type":"long"},//tips数据所属类型,0-tag,1-hospital,2-doctor,3-wiki
"ori_name":{"type":"keyword"},//原名称
"results_num":{"type":"integer"},//结果数量
"is_online":{"type":"boolean"},//上线
"offline_score":{"type":"double"},//离线分
"agile_tag_id":{"type":"long"},//标签ID
"create_tag_type":{"type":"long"},//标签创建类型
"style":{"type":"long"},//新标签样式
"topic_recommend_sort":{"type":"long"},
"api_agile_tag_recommend_type":{"type":"long"}
}
}
{
"dynamic":"strict",
"properties": {
"id":{"type":"text"},
"suggest":{
"analyzer":"keyword",
"search_analyzer":"keyword",
"type":"completion",
"contexts":[
{
"name":"is_online",
"type": "category"
}
]
},
"suggest_type":{"type":"long"},//0-汉字,1-汉字全拼,2-拼音,3-拼音全拼,4-拼音简写,5-拼音简写全拼
"agile_tag_type":{"type":"long"},//tips数据所属类型,0-tag,1-hospital,2-doctor,3-wiki
"ori_name":{"type":"keyword"},//原名称
"results_num":{"type":"integer"},//结果数量
"is_online":{"type":"boolean"},//上线
"offline_score":{"type":"double"},//离线分
"agile_tag_id":{"type":"long"},//标签ID
"create_tag_type":{"type":"long"},//标签创建类型
"style":{"type":"long"},//新标签样式
"topic_recommend_sort":{"type":"long"},
"api_agile_tag_recommend_type":{"type":"long"}
}
}
{
"dynamic":"strict",
"properties": {
"id":{"type":"text"},
"suggest":{
"analyzer":"keyword",
"search_analyzer":"keyword",
"type":"completion",
"contexts":[
{
"name":"is_online",
"type": "category"
}
]
},
"suggest_type":{"type":"long"},//0-汉字,1-汉字全拼,2-拼音,3-拼音全拼,4-拼音简写,5-拼音简写全拼
"agile_tag_type":{"type":"long"},//tips数据所属类型,0-tag,1-hospital,2-doctor,3-wiki
"ori_name":{"type":"keyword"},//原名称
"results_num":{"type":"integer"},//结果数量
"is_online":{"type":"boolean"},//上线
"offline_score":{"type":"double"},//离线分
"agile_tag_id":{"type":"long"},//标签ID
"create_tag_type":{"type":"long"},//标签创建类型
"style":{"type":"long"},//新标签样式
"topic_recommend_sort":{"type":"long"},
"api_agile_tag_recommend_type":{"type":"long"}
}
}
{
"dynamic":"strict",
"properties": {
"id":{"type":"text"},
"suggest":{
"analyzer":"keyword",
"search_analyzer":"keyword",
"type":"completion",
"contexts":[
{
"name":"is_online",
"type": "category"
}
]
},
"suggest_type":{"type":"long"},//0-汉字,1-汉字全拼,2-拼音,3-拼音全拼,4-拼音简写,5-拼音简写全拼
"agile_tag_type":{"type":"long"},//tips数据所属类型,0-tag,1-hospital,2-doctor,3-wiki
"ori_name":{"type":"keyword"},//原名称
"results_num":{"type":"integer"},//结果数量
"is_online":{"type":"boolean"},//上线
"offline_score":{"type":"double"},//离线分
"agile_tag_id":{"type":"long"},//标签ID
"create_tag_type":{"type":"long"},//标签创建类型
"style":{"type":"long"},//新标签样式
"topic_recommend_sort":{"type":"long"},
"api_agile_tag_recommend_type":{"type":"long"}
}
}
{
"dynamic":"strict",
"properties": {
"id":{"type":"text"},
"suggest":{
"analyzer":"keyword",
"search_analyzer":"keyword",
"type":"completion",
"contexts":[
{
"name":"is_online",
"type": "category"
}
]
},
"suggest_type":{"type":"long"},//0-汉字,1-汉字全拼,2-拼音,3-拼音全拼,4-拼音简写,5-拼音简写全拼
"agile_tag_type":{"type":"long"},//tips数据所属类型,0-tag,1-hospital,2-doctor,3-wiki
"ori_name":{"type":"keyword"},//原名称
"results_num":{"type":"integer"},//结果数量
"is_online":{"type":"boolean"},//上线
"offline_score":{"type":"double"},//离线分
"agile_tag_id":{"type":"long"},//标签ID
"create_tag_type":{"type":"long"},//标签创建类型
"style":{"type":"long"},//新标签样式
"topic_recommend_sort":{"type":"long"},
"api_agile_tag_recommend_type":{"type":"long"}
}
}
......@@ -10,6 +10,22 @@ from libs.es import ESPerform
def get_suggest_tips(query, agile_tag_type):
try:
# ios输入法在某些情况下会携带\\u2006
if agile_tag_type == 1:
index_name = "associate_tag_project"
elif agile_tag_type == 2:
index_name = "associate_tag_position"
elif agile_tag_type == 3:
index_name = "associate_tag_brand"
elif agile_tag_type == 4:
index_name = "associate_tag_instrument"
elif agile_tag_type == 5:
index_name = "associate_tag_hospital"
elif agile_tag_type == 6:
index_name = "associate_tag_doctor"
else:
index_name = 'associate_tag'
query = query.replace("\u2006", '')
q = {
"suggest": {
......@@ -32,7 +48,7 @@ def get_suggest_tips(query, agile_tag_type):
logging.info("get qqqqqqqq:%s" % q)
have_read_tips_set = set()
ret_list = list()
result_dict = ESPerform.get_search_results(ESPerform.get_cli(), sub_index_name="associate_tag", query_body=q,
result_dict = ESPerform.get_search_results(ESPerform.get_cli(), sub_index_name=index_name, query_body=q,
offset=0, size=50, is_suggest_request=True)
agile_type_id = set()
......
......@@ -249,7 +249,67 @@ def get_type_info_map():
bulk_insert_chunk_size=100,
round_insert_chunk_size=5,
round_insert_period=2,
)
),
TypeInfo(
name='associate_tag_brand',
type='associate_tag_brand',
model=agile_tag.AgileTagType,
query_deferred=lambda: agile_tag.AgileTag.objects.filter().query,
get_data_func=TagTransfer.get_tag_suggest_brand_data_list,
bulk_insert_chunk_size=100,
round_insert_chunk_size=5,
round_insert_period=2,
),
TypeInfo(
name='associate_tag_doctor',
type='associate_tag_doctor',
model=agile_tag.AgileTagType,
query_deferred=lambda: agile_tag.AgileTag.objects.all().query,
get_data_func=TagTransfer.get_tag_suggest_doctor_data_list,
bulk_insert_chunk_size=100,
round_insert_chunk_size=5,
round_insert_period=2,
),
TypeInfo(
name='associate_tag_hospital',
type='associate_tag_hospital',
model=agile_tag.AgileTagType,
query_deferred=lambda: agile_tag.AgileTag.objects.all().query,
get_data_func=TagTransfer.get_tag_suggest_hospital_data_list,
bulk_insert_chunk_size=100,
round_insert_chunk_size=5,
round_insert_period=2,
),
TypeInfo(
name='associate_tag_instrument',
type='associate_tag_instrument',
model=agile_tag.AgileTagType,
query_deferred=lambda: agile_tag.AgileTag.objects.all().query,
get_data_func=TagTransfer.get_tag_suggest_instrument_data_list,
bulk_insert_chunk_size=100,
round_insert_chunk_size=5,
round_insert_period=2,
),
TypeInfo(
name='associate_tag_position',
type='associate_tag_position',
model=agile_tag.AgileTagType,
query_deferred=lambda: agile_tag.AgileTag.objects.all().query,
get_data_func=TagTransfer.get_tag_suggest_position_data_list,
bulk_insert_chunk_size=100,
round_insert_chunk_size=5,
round_insert_period=2,
),
TypeInfo(
name='associate_tag_project',
type='associate_tag_project',
model=agile_tag.AgileTagType,
query_deferred=lambda: agile_tag.AgileTag.objects.all().query,
get_data_func=TagTransfer.get_tag_suggest_project_data_list,
bulk_insert_chunk_size=100,
round_insert_chunk_size=5,
round_insert_period=2,
),
]
type_info_map = {
......
......@@ -14,6 +14,10 @@ from associate.models import agile_tag
from associate.commons.commons import get_tips_suggest_list
from django.conf import settings
from associate.commons.words_utils import QueryWordAttr
from associate.models import agile_tag
from gm_types.gaia import (
AGILE_TAG_TYPE,
)
class TagTransfer(object):
......@@ -48,7 +52,193 @@ class TagTransfer(object):
return ([], [])
@classmethod
def get_tractate_data_name_mapping_results_to_redis(cls, name):
def get_tag_suggest_brand_data_list(self, instance):
try:
result = agile_tag.AgileTagType.objects.filter(agile_tag_id=instance.id,
agile_tag_type=AGILE_TAG_TYPE.BRAND)
if result:
ret_list = list()
item_dict = dict()
item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["ori_name"] = instance.name.strip()
item_dict["is_online"] = instance.is_online
random_num = random.randint(3000, 10000)
item_dict["results_num"] = random_num
item_dict["offline_score"] = 0.0
item_dict["create_tag_type"] = instance.create_tag_type
item_dict["style"] = instance.style
item_dict["topic_recommend_sort"] = instance.topic_recommend_sort
item_dict["agile_tag_type"] = instance.get_agile_tag_type()
item_dict["agile_tag_id"] = instance.id
item_dict["api_agile_tag_recommend_type"] = instance.get_api_agile_tag_recommend_type()
ret_list.append(item_dict)
suggest_list = get_tips_suggest_list(instance.name)
logging.info("get ret_list:%s" % ret_list)
logging.info("get suggest_list:%s" % ret_list)
return (item_dict, suggest_list)
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return ([], [])
@classmethod
def get_tag_suggest_project_data_list(self, instance):
try:
result = agile_tag.AgileTagType.objects.filter(agile_tag_id=instance.id,
agile_tag_type=AGILE_TAG_TYPE.PROJECT)
if result:
ret_list = list()
item_dict = dict()
item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["ori_name"] = instance.name.strip()
item_dict["is_online"] = instance.is_online
random_num = random.randint(3000, 10000)
item_dict["results_num"] = random_num
item_dict["offline_score"] = 0.0
item_dict["create_tag_type"] = instance.create_tag_type
item_dict["style"] = instance.style
item_dict["topic_recommend_sort"] = instance.topic_recommend_sort
item_dict["agile_tag_type"] = instance.get_agile_tag_type()
item_dict["agile_tag_id"] = instance.id
item_dict["api_agile_tag_recommend_type"] = instance.get_api_agile_tag_recommend_type()
ret_list.append(item_dict)
suggest_list = get_tips_suggest_list(instance.name)
logging.info("get ret_list:%s" % ret_list)
logging.info("get suggest_list:%s" % ret_list)
return (item_dict, suggest_list)
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return ([], [])
@classmethod
def get_tag_suggest_position_data_list(self, instance):
try:
result = agile_tag.AgileTagType.objects.filter(agile_tag_id=instance.id,
agile_tag_type=AGILE_TAG_TYPE.POSITION)
if result:
ret_list = list()
item_dict = dict()
item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["ori_name"] = instance.name.strip()
item_dict["is_online"] = instance.is_online
random_num = random.randint(3000, 10000)
item_dict["results_num"] = random_num
item_dict["offline_score"] = 0.0
item_dict["create_tag_type"] = instance.create_tag_type
item_dict["style"] = instance.style
item_dict["topic_recommend_sort"] = instance.topic_recommend_sort
item_dict["agile_tag_type"] = instance.get_agile_tag_type()
item_dict["agile_tag_id"] = instance.id
item_dict["api_agile_tag_recommend_type"] = instance.get_api_agile_tag_recommend_type()
ret_list.append(item_dict)
suggest_list = get_tips_suggest_list(instance.name)
logging.info("get ret_list:%s" % ret_list)
logging.info("get suggest_list:%s" % ret_list)
return (item_dict, suggest_list)
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return ([], [])
@classmethod
def get_tag_suggest_instrument_data_list(self, instance):
try:
result = agile_tag.AgileTagType.objects.filter(agile_tag_id=instance.id,
agile_tag_type=AGILE_TAG_TYPE.INSTRUMENT)
if result:
ret_list = list()
item_dict = dict()
item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["ori_name"] = instance.name.strip()
item_dict["is_online"] = instance.is_online
random_num = random.randint(3000, 10000)
item_dict["results_num"] = random_num
item_dict["offline_score"] = 0.0
item_dict["create_tag_type"] = instance.create_tag_type
item_dict["style"] = instance.style
item_dict["topic_recommend_sort"] = instance.topic_recommend_sort
item_dict["agile_tag_type"] = instance.get_agile_tag_type()
item_dict["agile_tag_id"] = instance.id
item_dict["api_agile_tag_recommend_type"] = instance.get_api_agile_tag_recommend_type()
ret_list.append(item_dict)
suggest_list = get_tips_suggest_list(instance.name)
logging.info("get ret_list:%s" % ret_list)
logging.info("get suggest_list:%s" % ret_list)
return (item_dict, suggest_list)
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return ([], [])
@classmethod
def get_tag_suggest_hospital_data_list(self, instance):
try:
result = agile_tag.AgileTagType.objects.filter(agile_tag_id=instance.id,
agile_tag_type=AGILE_TAG_TYPE.HOSPITAL)
if result:
ret_list = list()
item_dict = dict()
item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["ori_name"] = instance.name.strip()
item_dict["is_online"] = instance.is_online
random_num = random.randint(3000, 10000)
item_dict["results_num"] = random_num
item_dict["offline_score"] = 0.0
item_dict["create_tag_type"] = instance.create_tag_type
item_dict["style"] = instance.style
item_dict["topic_recommend_sort"] = instance.topic_recommend_sort
item_dict["agile_tag_type"] = instance.get_agile_tag_type()
item_dict["agile_tag_id"] = instance.id
item_dict["api_agile_tag_recommend_type"] = instance.get_api_agile_tag_recommend_type()
ret_list.append(item_dict)
suggest_list = get_tips_suggest_list(instance.name)
logging.info("get ret_list:%s" % ret_list)
logging.info("get suggest_list:%s" % ret_list)
return (item_dict, suggest_list)
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return ([], [])
@classmethod
def get_tag_suggest_doctor_data_list(self, instance):
try:
result = agile_tag.AgileTagType.objects.filter(agile_tag_id=instance.id,
agile_tag_type=AGILE_TAG_TYPE.DOCTOR)
if result:
ret_list = list()
item_dict = dict()
item_dict["id"] = getMd5Digest(str(instance.name))
item_dict["ori_name"] = instance.name.strip()
item_dict["is_online"] = instance.is_online
random_num = random.randint(3000, 10000)
item_dict["results_num"] = random_num
item_dict["offline_score"] = 0.0
item_dict["create_tag_type"] = instance.create_tag_type
item_dict["style"] = instance.style
item_dict["topic_recommend_sort"] = instance.topic_recommend_sort
item_dict["agile_tag_type"] = instance.get_agile_tag_type()
item_dict["agile_tag_id"] = instance.id
item_dict["api_agile_tag_recommend_type"] = instance.get_api_agile_tag_recommend_type()
ret_list.append(item_dict)
suggest_list = get_tips_suggest_list(instance.name)
logging.info("get ret_list:%s" % ret_list)
logging.info("get suggest_list:%s" % ret_list)
return (item_dict, suggest_list)
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return ([], [])
@classmethod
def get_tractate_data_name_mapping_results_to_redis(self, name):
try:
tag_name = name
......
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