本文整理汇总了Python中elastic.search.Search.field_search_query方法的典型用法代码示例。如果您正苦于以下问题:Python Search.field_search_query方法的具体用法?Python Search.field_search_query怎么用?Python Search.field_search_query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类elastic.search.Search
的用法示例。
在下文中一共展示了Search.field_search_query方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ajax_search
# 需要导入模块: from elastic.search import Search [as 别名]
# 或者: from elastic.search.Search import field_search_query [as 别名]
def ajax_search(request, query, search_idx, ajax):
''' Return count or paginated elastic result as a JSON '''
if ajax == 'count':
elastic = Search.field_search_query(query, fields=fields, idx=search_idx)
return JsonResponse(elastic.get_count())
search_from = request.POST.get("from")
size = request.POST.get("size")
elastic = Search.field_search_query(query, fields=fields, search_from=search_from,
size=size, idx=search_idx)
return JsonResponse(elastic.get_json_response())
示例2: search
# 需要导入模块: from elastic.search import Search [as 别名]
# 或者: from elastic.search.Search import field_search_query [as 别名]
def search(request, query, search_idx=ElasticSettings.indices_str()):
''' Renders a elastic results page based on the query '''
aggs = Aggs(Agg("categories", "terms", {"field": "_type", "size": 0}))
elastic = Search.field_search_query(query, aggs=aggs, fields=fields,
search_from=0, size=20, idx=search_idx)
result = elastic.search()
context = {}
context['diseases'] = _add_diseases()
context['total'] = result.hits_total
context['db'] = result.idx
context['size'] = result.size
context['query'] = result.query
context["idxs"] = _categories(result.idx)
return render(request, 'search/searchresults.html', context,
content_type='text/html')