本文整理汇总了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)
示例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")
示例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)
示例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))
示例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))
示例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))
示例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,
})