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

modify

parent 35ff4dfa
...@@ -29,6 +29,30 @@ def query_tag(query,offset,size): ...@@ -29,6 +29,30 @@ def query_tag(query,offset,size):
try: try:
if query: if query:
query = query.lower() query = query.lower()
pre_q = {
"query":{
"bool": {
"must":[
{"term":{"name_pre": query}},
{"term":{"is_online": True}}
]
}
},
"_source": {
"include": ["id", "name", "is_deleted", "is_online"]
}
}
ret_list = list()
result_dict = ESPerform.get_search_results(ESPerform.get_cli(),sub_index_name="tag",query_body=pre_q,offset=0,size=1)
if len(result_dict["hits"])>0:
hitLight = u'<ems>%s</ems>' % query
result_dict["hits"][0]["_source"]["highlight"] = result_dict["hits"][0]["name"].replace(query, hitLight)
ret_list.append(result_dict["hits"][0]["_source"])
size -= 1
q = { q = {
"suggest":{ "suggest":{
"tips-suggest":{ "tips-suggest":{
...@@ -51,7 +75,6 @@ def query_tag(query,offset,size): ...@@ -51,7 +75,6 @@ def query_tag(query,offset,size):
} }
} }
ret_list = list()
result_dict = ESPerform.get_search_results(ESPerform.get_cli(),sub_index_name="tag",query_body=q,offset=offset,size=size,is_suggest_request=True) result_dict = ESPerform.get_search_results(ESPerform.get_cli(),sub_index_name="tag",query_body=q,offset=offset,size=size,is_suggest_request=True)
for tips_item in result_dict["suggest"]["tips-suggest"]: for tips_item in result_dict["suggest"]["tips-suggest"]:
......
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