当前位置: 首页>>代码示例>>Python>>正文


Python Search.field_search_query方法代码示例

本文整理汇总了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())
开发者ID:D-I-L,项目名称:django_template,代码行数:12,代码来源:views.py

示例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')
开发者ID:D-I-L,项目名称:django_template,代码行数:18,代码来源:views.py


注:本文中的elastic.search.Search.field_search_query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。