Commit 2b93be21 authored by lixiaofang's avatar lixiaofang

add

parent ae39eda7
......@@ -29,3 +29,6 @@ class CeleryTaskRouter(object):
queue_name_or_none = self.task_queue_map.get(task)
return queue_name_or_none
class DorisRouter(object):
def db_for_read(self, model, **hints):
if model._meta.app_label == "doris":
return 'doris'
return None
def db_for_write(self, model, **hints):
if model._meta.app_label == "doris":
return 'doris'
return None
def allow_relation(self, obj1, obj2, **hints):
if obj1._meta.app_label == 'doris' or \
obj2._meta.app_label == 'doris':
return True
return None
def allow_migrate(self, db, app_label, model_name=None, **hints):
if app_label == 'doris':
return db == 'doris'
return None
......@@ -18,7 +18,7 @@ def uuid4():
return uuid.uuid4().hex
def get_tips_suggest_list(instance_cn_name):
def get_tips_suggest_list(instance_cn_name, is_weighting=False):
try:
print(instance_cn_name)
# ch_full_weight = 6.0 * 1000
......
......@@ -29,9 +29,10 @@ class WordRel(models.Model):
class WordRelResemble(models.Model):
"""近义词数据表
"""
class Meta:
app_label = 'api'
db_table = 'api_wordrelresemble'
wordrel = models.ForeignKey(WordRel, related_name='all_resembles')
word = models.CharField(u'近义词', max_length=50, db_index=True)
\ No newline at end of file
word = models.CharField(u'近义词', max_length=50, db_index=True)
......@@ -13,7 +13,8 @@ import elasticsearch.helpers
import sys
import copy
from trans2es.models import doctor, itemwiki, collectwiki, brandwiki, productwiki, tag, wordresemble,strategy_search_word
from trans2es.models import doctor, itemwiki, collectwiki, brandwiki, productwiki, tag, wordresemble, \
strategy_search_word
from trans2es.utils.doctor_transfer import DoctorTransfer
from trans2es.utils.hospital_transfer import HospitalTransfer
from trans2es.utils.itemwiki_transfer import ItemWikiTransfer
......@@ -288,7 +289,8 @@ def get_type_info_map():
name='suggest',
type='doctor_tips', # doctor
model=doctor.Doctor,
query_deferred=lambda: doctor.Doctor.objects.all().filter(doctor_type__in=[DOCTOR_TYPE.DOCTOR,DOCTOR_TYPE.OFFICER]).query,
query_deferred=lambda: doctor.Doctor.objects.all().filter(
doctor_type__in=[DOCTOR_TYPE.DOCTOR, DOCTOR_TYPE.OFFICER]).query,
get_data_func=DoctorTransfer.get_doctor_suggest_data_list,
bulk_insert_chunk_size=100,
round_insert_chunk_size=5,
......@@ -368,7 +370,7 @@ def get_type_info_map():
round_insert_period=2,
),
TypeInfo(
name='suggest',
name='suggest-v2',
type='search_query', # tag
model=strategy_search_word.StrategyHistoryQueryWords,
query_deferred=lambda: strategy_search_word.StrategyHistoryQueryWords.objects.using(
......@@ -564,7 +566,7 @@ def tips_attr_sync_to_redis_type_info_map():
TypeInfo(
name='suggest',
type='wordresemble_results_num', # api_wordrelresemble
model= wordresemble.WordRel,
model=wordresemble.WordRel,
query_deferred=lambda: wordresemble.WordRel.objects.filter(
category__in=[13, 12, 11, 9, 1]).query,
get_data_func=WordResemble.set_data_to_redis,
......
......@@ -12,12 +12,11 @@ class SearchWord(object):
@classmethod
def get_search_query(self, instance):
try:
print("=-=-=-=-=-=-")
ret_list = list()
item_dict = dict()
item_dict["id"] = getMd5Digest(str(instance.keyword))
item_dict["ori_name"] = instance.keyword
item_dict["is_online"] = 1
item_dict["is_online"] = False if instance.is_delete else True
item_dict["order_weight"] = QueryWordAttr.get_project_query_word_weight(instance.keyword)
item_dict["results_num"] = QueryWordAttr.get_query_results_num(instance.keyword)
item_dict["type_flag"] = get_tips_word_type(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