Commit ae39eda7 authored by lixiaofang's avatar lixiaofang

add

parent 2d063776
......@@ -35,11 +35,11 @@ class Command(BaseCommand):
es_cli = ESPerform.get_cli()
type_name1 = "suggest-v1"
type_name2 = "suggest-v2"
type_name = "suggest"
if len(options["type"]):
if options["type"] == "all" or type_name == options["type"] or type_name1 == options["type"]:
if options["type"] == "all" or type_name == options["type"] or type_name1 == options["type"] or type_name2 == options['type']:
type_name = options["type"]
official_index_name = ESPerform.get_official_index_name(type_name)
index_exists = es_cli.indices.exists(official_index_name)
......
{
"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-拼音简写全拼
"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"},//离线分
"results_num":{"type":"integer"},//结果数量
"type_flag":{"type":"keyword"},
"is_online":{"type":"boolean"}//上线
}
}
# coding=utf8
from __future__ import unicode_literals, absolute_import, print_function
from django.db import models
from django.conf import settings
class StrategyHistoryQueryWords(models.Model):
"""
历史搜索词
"""
class Meta:
app_label = 'doris'
db_table = 'strategy_history_query_words'
keyword = models.CharField(u'项目介绍', max_length=48)
is_delete = models.BooleanField(u'是否上线', default=True)
search_num = models.IntegerField(verbose_name=u'搜索次数')
answer_num = models.IntegerField(verbose_name=u'回答搜索结果次数')
tractate_num = models.IntegerField(verbose_name=u'帖子搜索结果次数')
diary_num = models.IntegerField(verbose_name=u'日记搜索结果次数')
......@@ -13,7 +13,7 @@ import elasticsearch.helpers
import sys
import copy
from trans2es.models import doctor, itemwiki, collectwiki, brandwiki, productwiki, tag, wordresemble
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
......@@ -22,6 +22,8 @@ from trans2es.utils.brandwiki_transfer import BrandWikiTransfer
from trans2es.utils.productwiki_transfer import ProduceWikiTransfer
from trans2es.utils.tag_transfer import TagTransfer
from trans2es.utils.wordresemble import WordResemble
from trans2es.utils.search_query import SearchWord
from libs.es import ESPerform
from libs.tools import tzlc, getMd5Digest
from trans2es.commons.words_utils import QueryWordAttr
......@@ -139,7 +141,7 @@ class TypeInfo(object):
(item_dict, suggest_list) = data
if item_dict:
if item_dict["tips_name_type"] == 4:
if item_dict["tips_name_type"] == 4 or item_dict["tips_name_type"] == 5:
instance.name = instance.keyword
resemble_list = WordResemble.get_word_resemble_list(str(instance.name))
......@@ -365,6 +367,18 @@ def get_type_info_map():
round_insert_chunk_size=5,
round_insert_period=2,
),
TypeInfo(
name='suggest',
type='search_query', # tag
model=strategy_search_word.StrategyHistoryQueryWords,
query_deferred=lambda: strategy_search_word.StrategyHistoryQueryWords.objects.using(
settings.DORIS_DB_NAME).all().query,
get_data_func=SearchWord.get_search_query,
bulk_insert_chunk_size=100,
round_insert_chunk_size=5,
round_insert_period=2
),
# TypeInfo(
# name='suggest-v1',
# type='doctor_tips', # doctor
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import traceback
from libs.tools import getMd5Digest
from trans2es.commons.words_utils import QueryWordAttr, get_tips_word_type
from trans2es.commons.commons import get_tips_suggest_list
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["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)
item_dict["offline_score"] = 0.0
item_dict["tips_name_type"] = 5
ret_list.append(item_dict)
suggest_list = get_tips_suggest_list(str(instance.keyword).lower(), is_weighting=True)
return (item_dict, suggest_list)
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
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