• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python models.augment_solr_response函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中search.models.augment_solr_response函数的典型用法代码示例。如果您正苦于以下问题:Python augment_solr_response函数的具体用法?Python augment_solr_response怎么用?Python augment_solr_response使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了augment_solr_response函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: search

def search(request):
    response = {}

    collection = json.loads(request.POST.get("collection", "{}"))
    query = json.loads(request.POST.get("query", "{}"))
    query["download"] = "download" in request.POST

    if collection:
        try:
            response = SolrApi(SOLR_URL.get(), request.user).query(collection, query)
            response = augment_solr_response(response, collection, query)
        except RestException, e:
            try:
                message = json.loads(e.message)
                response["error"] = message["error"].get("msg", message["error"]["trace"])
            except Exception, e2:
                LOG.exception("failed to extract json message: %s" % force_unicode(e2))
                LOG.exception("failed to parse json response: %s" % force_unicode(e))
                response["error"] = force_unicode(e)
开发者ID:cloudera,项目名称:hue,代码行数:19,代码来源:views.py


示例2: get_timeline

def get_timeline(request):
  result = {'status': -1, 'message': 'Error'}

  try:
    collection = json.loads(request.POST.get('collection', '{}'))
    query = json.loads(request.POST.get('query', '{}'))
    facet = json.loads(request.POST.get('facet', '{}'))
    qdata = json.loads(request.POST.get('qdata', '{}'))
    multiQ = request.POST.get('multiQ', 'query')

    if multiQ == 'query':
      label = qdata['q']
      query['qs'] = [qdata]
    elif facet['type'] == 'range':
      _prop = filter(lambda prop: prop['from'] == qdata, facet['properties'])[0]
      label = '%(from)s - %(to)s ' % _prop
      facet_id = facet['id']
      # Only care about our current field:value filter
      for fq in query['fqs']:
        if fq['id'] == facet_id:
          fq['properties'] = [_prop]
    else:
      label = qdata
      facet_id = facet['id']
      # Only care about our current field:value filter
      for fq in query['fqs']:
        if fq['id'] == facet_id:
          fq['filter'] = [qdata]

    # Remove other facets from collection for speed
    collection['facets'] = filter(lambda f: f['widgetType'] == 'histogram-widget', collection['facets'])

    response = SolrApi(SOLR_URL.get(), request.user).query(collection, query)
    response = augment_solr_response(response, collection, query)

    label += ' (%s) ' % response['response']['numFound']

    result['series'] = {'label': label, 'counts': response['normalized_facets'][0]['counts']}
    result['status'] = 0
    result['message'] = ''
  except Exception, e:
    result['message'] = unicode(str(e), "utf8")
开发者ID:Altiscale,项目名称:hue,代码行数:42,代码来源:views.py


示例3: get_timeline

def get_timeline(request):
    result = {"status": -1, "message": "Error"}

    try:
        collection = json.loads(request.POST.get("collection", "{}"))
        query = json.loads(request.POST.get("query", "{}"))
        facet = json.loads(request.POST.get("facet", "{}"))
        qdata = json.loads(request.POST.get("qdata", "{}"))
        multiQ = request.POST.get("multiQ", "query")

        if multiQ == "query":
            label = qdata["q"]
            query["qs"] = [qdata]
        elif facet["type"] == "range":
            _prop = filter(lambda prop: prop["from"] == qdata, facet["properties"])[0]
            label = "%(from)s - %(to)s " % _prop
            facet_id = facet["id"]
            # Only care about our current field:value filter
            for fq in query["fqs"]:
                if fq["id"] == facet_id:
                    fq["properties"] = [_prop]
        else:
            label = qdata
            facet_id = facet["id"]
            # Only care about our current field:value filter
            for fq in query["fqs"]:
                if fq["id"] == facet_id:
                    fq["filter"] = [{"value": qdata, "exclude": False}]

        # Remove other facets from collection for speed
        collection["facets"] = filter(lambda f: f["widgetType"] == "histogram-widget", collection["facets"])

        response = SolrApi(SOLR_URL.get(), request.user).query(collection, query)
        response = augment_solr_response(response, collection, query)

        label += " (%s) " % response["response"]["numFound"]

        result["series"] = {"label": label, "counts": response["normalized_facets"][0]["counts"]}
        result["status"] = 0
        result["message"] = ""
    except Exception, e:
        result["message"] = force_unicode(e)
开发者ID:cloudera,项目名称:hue,代码行数:42,代码来源:views.py


示例4: search

def search(request):
  response = {}

  collection = json.loads(request.POST.get('collection', '{}'))
  query = json.loads(request.POST.get('query', '{}'))
  query['download'] = 'download' in request.POST

  if collection:
    try:
      response = SolrApi(SOLR_URL.get(), request.user).query(collection, query)
      response = augment_solr_response(response, collection, query)
    except RestException, e:
      try:
        response['error'] = json.loads(e.message)['error']['msg']
      except:
        response['error'] = force_unicode(str(e))
    except Exception, e:
      raise PopupException(e, title=_('Error while accessing Solr'))

      response['error'] = force_unicode(str(e))
开发者ID:rocwzp,项目名称:hue,代码行数:20,代码来源:views.py


示例5: search

def search(request):
  response = {}

  collection = json.loads(request.POST.get('collection', '{}'))
  query = json.loads(request.POST.get('query', '{}'))
  # todo: remove the selected histo facet if multiq

  if collection['id']:
    hue_collection = Collection.objects.get(id=collection['id']) # TODO perms

  if collection:
    try:
      response = SolrApi(SOLR_URL.get(), request.user).query(collection, query)
      response = augment_solr_response(response, collection, query)
    except RestException, e:
      try:
        response['error'] = json.loads(e.message)['error']['msg']
      except:
        response['error'] = force_unicode(str(e))
    except Exception, e:
      raise PopupException(e, title=_('Error while accessing Solr'))

      response['error'] = force_unicode(str(e))
开发者ID:Altiscale,项目名称:hue,代码行数:23,代码来源:views.py


示例6: search

def search(request):
    response = {}

    collection = json.loads(request.POST.get("collection", "{}"))
    query = json.loads(request.POST.get("query", "{}"))
    query["download"] = "download" in request.POST
    # todo: remove the selected histo facet if multiq

    if collection["id"]:
        hue_collection = Collection.objects.get(id=collection["id"])  # TODO perms

    if collection:
        try:
            response = SolrApi(SOLR_URL.get(), request.user).query(collection, query)
            response = augment_solr_response(response, collection, query)
        except RestException, e:
            try:
                response["error"] = json.loads(e.message)["error"]["msg"]
            except:
                response["error"] = force_unicode(str(e))
        except Exception, e:
            raise PopupException(e, title=_("Error while accessing Solr"))

            response["error"] = force_unicode(str(e))
开发者ID:tp0101,项目名称:hue,代码行数:24,代码来源:views.py


示例7: SolrApi

    solr_query['search_time'] = 0

    try:
      hue_collection = Collection.objects.get(id=collection_id)
      solr_query['collection'] = hue_collection.name
      response = SolrApi(SOLR_URL.get(), request.user).query(solr_query, hue_collection)
      solr_query['total_pages'] = int(math.ceil((float(response['response']['numFound']) / float(solr_query['rows']))))
      solr_query['search_time'] = response['responseHeader']['QTime']
    except Exception, e:
      error['title'] = force_unicode(e.title) if hasattr(e, 'title') else ''
      error['message'] = force_unicode(str(e))
  else:
    error['message'] = _('There is no collection to search.')

  if hue_collection is not None:
    response = augment_solr_response(response, hue_collection.facets.get_data())

  if request.GET.get('format') == 'json':
    return HttpResponse(json.dumps(response), mimetype="application/json")

  return render('search.mako', request, {
    'search_form': search_form,
    'response': response,
    'error': error,
    'solr_query': solr_query,
    'hue_collection': hue_collection,
    'hue_collections': hue_collections,
    'current_collection': collection_id,
    'json': json,
  })
开发者ID:Web5design,项目名称:hue,代码行数:30,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python search_controller.SearchController类代码示例发布时间:2022-05-27
下一篇:
Python forms.SearchForm类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap