Commit a5d195d9 authored by 段英荣's avatar 段英荣

add

parent b4362b77
......@@ -28,7 +28,7 @@ SECRET_KEY = 'e%$v6snev0807=t0@gk_n2#r5m6r1h(eil6cp^y3ub@ja@gk_t'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
ALLOWED_HOSTS = ["192.168.78.2"]
SENTRY_CELERY_ENDPOINT="http://60b0004c8884420f8067fb32fc3ed244:20f97fc73ffa4aad9735d0e6542a6d78@sentry.igengmei.com/140"
BROKER_URL = "redis://127.0.0.1:6379/8"
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import django.db.models
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
import traceback
import logging
import six
import sys
from libs.es import ESPerform
import trans2es.models as md
from libs.table_scan import TableSlicer,TableSlicerChunk
from trans2es.type_info import get_type_info_map,TypeInfo
from libs.cache import redis_client
import json
class Command(BaseCommand):
args = ''
help = 'dump data to elasticsearch, parallel'
from optparse import make_option
option_list = BaseCommand.option_list + (
make_option('-t', '--type', dest='type', help='type name to dump data to elasticsearch', metavar='TYPE',default=''),
make_option('-i', '--index-prefix', dest='index_prefix', help='index name to dump data to elasticsearch', metavar='INDEX_PREFIX'),
make_option('-p', '--parallel', dest='parallel', help='parallel process count', metavar='PARALLEL'),
make_option('-s', '--pks', dest='pks', help='specify sync pks, comma separated', metavar='PKS', default=''),
make_option('--streaming-slicing', dest='streaming_slicing', action='store_true', default=True),
make_option('--no-streaming-slicing', dest='streaming_slicing', action='store_false', default=True),
make_option('-S', '--sync_type',dest='sync_type', help='sync data to es',metavar='TYPE',default='')
)
def handle(self, *args, **options):
try:
logging.info("test")
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
......@@ -6,7 +6,7 @@
"type":"completion"
},
"suggest_type":{"type":"long"},//0-汉字,1-汉字全拼,2-拼音,3-拼音全拼,4-拼音简写,5-拼音简写全拼
"data_type":{"type":"long"},//0-tag,1-hospital,2-doctor,3-wiki
"tips_name_type":{"type":"long"},//tips数据所属类型,0-tag,1-hospital,2-doctor,3-wiki
"ori_name":{"type":"keyword"},//原名称
"order_weight":{"type":"double"},//订单权重
"offline_score":{"type":"double"},//离线分
......
......@@ -19,6 +19,35 @@ class DoctorTransfer(object):
ch_prefix_weight = 1.5
py_prefix_weight = 1.0
# 命中开始部分加权
begin_prefix_weight = 1.2
@classmethod
def get_doctor_data_name_mapping_results_to_redis(cls, instance):
try:
doctor_name = instance.name
if doctor_name.strip():
multi_fields = {
'hospital.city_province_name': 1,
'hospital.name': 1,
'name': 1,
'hospital.city_name':1,
'hospital.officer_name':1,
'service_closure_tags':1
}
query_fields = ['^'.join((k, str(v))) for (k, v) in multi_fields.items()]
multi_match = {
'query': doctor_name,
'type': 'cross_fields',
'operator': 'and',
'fields': query_fields,
}
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
@classmethod
def get_doctor_suggest_data_list(cls,instance):
try:
......@@ -33,7 +62,7 @@ class DoctorTransfer(object):
item_dict["results_num"] = 0
item_dict["type_flag"] = "unknown"
item_dict["offline_score"] = 0.0
item_dict["data_type"] = 2
item_dict["tips_name_type"] = 2
ret_list.append(item_dict)
suggest_list = list()
......@@ -50,9 +79,10 @@ class DoctorTransfer(object):
if ch_name_term:
prefix_weight = cls.ch_prefix_weight if len(ch_name_term)!=len(ch_full_word) else cls.ch_full_weight
suggest_type = 0 if len(ch_name_term)!=len(ch_full_word) else 1
begin_prefix_weight = cls.begin_prefix_weight if i==0 else 1.0
suggest_item = {
"input":[ch_name_term],
"word_weight":(1.0*len(ch_name_term)/len((ch_full_word))) * prefix_weight,
"word_weight":(1.0*len(ch_name_term)/len((ch_full_word))) * prefix_weight * begin_prefix_weight,
"suggest_type": suggest_type,
"cur_index": cur_index
}
......@@ -66,9 +96,10 @@ class DoctorTransfer(object):
if py_name_term:
prefix_weight = cls.py_prefix_weight if len(py_name_term)!=len(py_full_word) else cls.py_full_weight
suggest_type = 2 if len(py_name_term)!=len(py_full_word) else 3
begin_prefix_weight = cls.begin_prefix_weight if i==0 else 1.0
suggest_item = {
"input":[py_name_term],
"word_weight":(1.0*len(py_name_term)/len(py_full_word)) * prefix_weight,
"word_weight":(1.0*len(py_name_term)/len(py_full_word)) * prefix_weight * begin_prefix_weight,
"suggest_type": suggest_type,
"cur_index": cur_index
}
......@@ -82,9 +113,10 @@ class DoctorTransfer(object):
if py_acronym_term:
prefix_weight = cls.py_acronym_prefix_weight if len(py_acronym_term)!=len(py_acronym_full_word) else cls.py_acronym_full_weight
suggest_type = 4 if len(py_acronym_term)!=len(py_acronym_full_word) else 5
begin_prefix_weight = cls.begin_prefix_weight if i==0 else 1.0
suggest_item = {
"input":[py_acronym_term],
"word_weight":(1.0*len(py_acronym_term)/len(py_acronym_full_word)) * prefix_weight,
"word_weight":(1.0*len(py_acronym_term)/len(py_acronym_full_word)) * prefix_weight * begin_prefix_weight,
"suggest_type": suggest_type,
"cur_index": cur_index
}
......
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