本文整理汇总了Python中service_api.ServiceApi.search方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceApi.search方法的具体用法?Python ServiceApi.search怎么用?Python ServiceApi.search使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类service_api.ServiceApi
的用法示例。
在下文中一共展示了ServiceApi.search方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: search
# 需要导入模块: from service_api import ServiceApi [as 别名]
# 或者: from service_api.ServiceApi import search [as 别名]
def search(query=None):
if request.is_xhr:
search_query = escape(request.args.get('query'))
search_results = ServiceApi.search(quote(search_query))
return search_results
else:
return render_app_template(request.path)
示例2: search
# 需要导入模块: from service_api import ServiceApi [as 别名]
# 或者: from service_api.ServiceApi import search [as 别名]
def search(query=None):
if request.is_xhr:
if request.method == "GET":
search_query = request.args.get('query')
search_results = ServiceApi.search(search_query)
return render_json_response(search_results)
else:
adv_query_string = request.form['adv_query_string']
adv_query_chunks = parse_qs(adv_query_string)
geospatial_bounds = {'north': adv_query_chunks.get('north', [''])[0],
'east': adv_query_chunks.get('east', [''])[0],
'south': adv_query_chunks.get('south', [''])[0],
'west': adv_query_chunks.get('west', [''])[0]}
vertical_bounds = {'lower': adv_query_chunks.get('vertical-lower-bound', [''])[0],
'upper': adv_query_chunks.get('vertical-upper-bound', [''])[0]}
temporal_bounds = {'from': adv_query_chunks.get('temporal-from-ctrl', [''])[0],
'to': adv_query_chunks.get('temporal-to-ctrl', [''])[0]}
search_criteria = zip(adv_query_chunks.get('filter_var', []),
adv_query_chunks.get('filter_operator', []),
adv_query_chunks.get('filter_arg', []))
search_results = ServiceApi.adv_search(geospatial_bounds,
vertical_bounds,
temporal_bounds,
search_criteria)
return render_json_response(search_results)
else:
return render_app_template(request.path)
示例3: test_quick_search
# 需要导入模块: from service_api import ServiceApi [as 别名]
# 或者: from service_api.ServiceApi import search [as 别名]
def test_quick_search(self):
with self.app_context:
sa = ServiceApi()
search_query = "parsed"
results = sa.search(search_query=search_query)
self.assertTrue(results != [])
search_query_found = False
for result in results:
for key, value in result['_source'].iteritems():
if type(value) is str or type(value) is unicode:
if value.lower().find(search_query.lower()) > -1:
search_query_found = True
self.assertTrue(search_query_found)
search_query = "parseD"
results = sa.search(search_query=search_query)
self.assertTrue(results != [])
search_query_found = False
for result in results:
for key, value in result['_source'].iteritems():
if type(value) is str or type(value) is unicode:
if value.lower().find(search_query.lower()) > -1:
search_query_found = True
self.assertTrue(search_query_found)