Commit 04e64992 authored by 段英荣's avatar 段英荣

modify

parent f1227b18
#!/usr/bin/env python
# -*- coding: utf-8 -*-
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 search.utils.auto_tips import get_suggest_tips
@bind("search_tips/search/auto_complete_query")
def auto_complete_query(q):
try:
"""auto complate words/tags/doctors etc.
URL:
~/api/auto_complete?scope=[kw]&q=双
Return:
{'error': 0|1, 'data': [word, word, word],}
"""
# q = request.GET.get('q', '').strip()
# if not q:
# return json_http_response({'error': 0, 'data': []})
data = get_suggest_tips(q)
result = {
'error': 0,
'data': data,
}
return {"data":data}
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return {"data":[]}
#!/usr/bin/env python
# -*- coding: utf-8 -*-
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 django.shortcuts import render
# Create your views here.
def auto_complete(request):
try:
"""auto complate words/tags/doctors etc.
URL:
~/api/auto_complete?scope=[kw]&q=双
Return:
{'error': 0|1, 'data': [word, word, word],}
"""
q = request.GET.get('q', '').strip()
if not q:
return json_http_response({'error': 0, 'data': []})
data = get_suggest_tips(q)
result = {
'error': 0,
'data': data,
}
return json_http_response(result)
except:
logging.error("catch exception,err_msg:%s" % traceback.format_exc())
return json_http_response({'error': 1, 'data': []})
......@@ -18,5 +18,5 @@ from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^auto_complete$', 'search.views.auto_tips.auto_complete'),
url(r'^auto_complete$', 'search.views.auto_complete'),
]
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