Commit 213d6a70 authored by lixiaofang's avatar lixiaofang

新增搜索域

parent 62339c2e
......@@ -10,6 +10,6 @@
<element value="search_tips.django_init"/>
<element value="search.view.auto_tips"/>
<element value="associate.search.views.auto_tips"/>
<element value="associate.search.views.hotword_results"/>
<element value="associate.search.views.hotword_result"/>
</config>
</gm_rpcd_config>
......@@ -2,4 +2,4 @@ from django.apps import AppConfig
class Trans2EsConfig(AppConfig):
name = 'trans2es'
name = 'associate'
......@@ -3,19 +3,15 @@
import django.db.models
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import BaseCommand
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
from libs.table_scan import TableSlicer, TableSlicerChunk
from associate.type_info import get_type_info_map, TypeInfo
class Job(object):
......@@ -46,22 +42,22 @@ class Job(object):
)
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('-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='')
make_option('-S', '--sync_type', dest='sync_type', help='sync data to es', metavar='TYPE', default='')
)
def __sync_data_by_type(self, type_name):
......@@ -86,7 +82,7 @@ class Command(BaseCommand):
for type_name in type_name_list:
if len(options["type"]):
if options["type"] == "all" or type_name==options["type"]:
if options["type"] == "all" or type_name == options["type"]:
logging.info("begin sync [%s] data to es!" % type_name)
self.__sync_data_by_type(type_name)
......
......@@ -6,7 +6,7 @@ from django.core.management.base import BaseCommand
import traceback
import logging
from libs.es import ESPerform
from trans2es.type_info import get_type_info_map
from associate.type_info import get_type_info_map
class Command(BaseCommand):
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import django.db.models
from django.conf import settings
from django.core.management.base import BaseCommand, CommandError
from django.core.management.base import BaseCommand
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, tips_attr_sync_to_redis_type_info_map
from libs.cache import redis_client
import json
from libs.table_scan import TableSlicer
from associate.type_info import tips_attr_sync_to_redis_type_info_map
class Command(BaseCommand):
......
......@@ -5,15 +5,11 @@ from __future__ import unicode_literals, absolute_import, print_function
from gm_rpcd.all import bind
import logging
import traceback
import json
from libs.es import ESPerform
from libs.cache import redis_client
from libs.tools import json_http_response
from associate.search.utils.auto_tips import get_suggest_tips
@bind("associate/search/auto_complete_query")
def auto_complete_query(query, agile_tag_type=-1):
@bind("search_tips/search/auto_associate_query")
def auto_associate_query(query, agile_tag_type=-1):
try:
"""auto complate words/tags/doctors etc.
......
......@@ -8,7 +8,7 @@ import traceback
from associate.commons.words_utils import QueryWordAttr
@bind("associate/search/tag_hotword_num")
@bind("search_tips/search/tag_hotword_num")
def get_hotword_num(tag_id_list):
try:
tag_id_num = list()
......
......@@ -6,21 +6,12 @@ import datetime
import logging
import traceback
import django.db.models
from django.conf import settings
from libs.es import ESPerform
import elasticsearch
import elasticsearch.helpers
import sys
import copy
from libs.es import ESPerform
from libs.tools import tzlc, getMd5Digest
from trans2es.models import agile_tag
from trans2es.utils.agile_tag_transfer import TagTransfer
from associate.models import agile_tag
from associate.utils import TagTransfer
from gm_types.gaia import (
AGILE_TAG_TYPE,
AGILE_TAG_CREATE_TYPE,
AGILE_TAG_STYLE,
AGILE_TAG_RECOMMEND_TYPE,
)
__es = None
......
......@@ -9,10 +9,10 @@ from libs.es import ESPerform
from libs.cache import redis_client
import json
import base64
from trans2es.models import agile_tag
from trans2es.commons.commons import get_tips_suggest_list
from associate.models import agile_tag
from associate.commons.commons import get_tips_suggest_list
from django.conf import settings
from trans2es.commons.words_utils import QueryWordAttr
from associate.commons.words_utils import QueryWordAttr
class TagTransfer(object):
......
import sys
from gm_rpcd.commands.utils import add_cwd_to_path
from gm_rpcd.internals.utils import serve
def main(args):
add_cwd_to_path()
from gm_rpcd.internals.configuration import config
config.is_develop_mode = True
config.freeze()
host = '127.0.0.1'
port = 9000
try:
first_arg = args[0]
except IndexError:
pass
else:
if ':' in first_arg:
host, port = first_arg.split(':')
port = int(port)
else:
port = int(first_arg)
print('Serving on {}:{}'.format(host, port))
serve(host=host, port=port)
if __name__ == '__main__':
main(sys.argv[1:])
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