def signalSearch(request,query): """ """ query = solrutils.scapeSolrQuery(query) dataDict={} getDict = {'facet':"true", 'facet.field':"tags", 'facet.mincount':1, 'wt':'python', 'rows':settings.MAX_SOLR_ROWS, 'q':"text:" + '"'+query.encode("latin-1")+'"' } url_fin = settings.SIGNALS_SOLR_SELECT + "?" + urllib.urlencode(getDict) print url_fin request = urllib2.Request(url_fin) response = urllib2.urlopen(request) response_data = eval(response.read()) signals = [] for doc in response_data['response']['docs']: signalDict = {} signalDict['name'] = doc['name'] signalDict['id'] = doc['id'] signalDict['name'] = doc['name'] signalDict['text'] = doc['text'] signalDict['owner'] = doc['owner'] fechaOk = doc['datetime'][0:10]+" " + doc['datetime'][11:19] signalDict['timestamp'] = fechaOk signals.append(signalDict) # Aqui meto unas facetas y conteos de prueba... facets=[] aux = response_data['facet_counts']['facet_fields']['tags'] for i in range(0, len(aux), 2): facetDict={} facetDict['name']=aux[i] facetDict['counts']=aux[i+1] facets.append(facetDict) dataDict['signals'] = signals dataDict['numSignals'] = len(signals) dataDict['facets'] = facets return HttpResponse(simplejson.dumps(dataDict,indent=4), mimetype='application/javascript')
def signalTagAllSearch(request,signalId,tag): """ """ tag = solrutils.scapeSolrQuery(tag) dataDict={} getDict = {'facet':"true", 'facet.field':"tags", 'facet.mincount':1, 'wt':'python', 'rows':settings.MAX_SOLR_ROWS, # 'q':"signal_id:"+str(signalId)+" AND tags:"+"#"+tag.encode("latin-1") 'q':"signal_id:"+str(signalId)+" AND tags:"+ '"'+tag.encode("latin-1")+'"' } url_fin = settings.POINTS_SOLR_SELECT + "?" + urllib.urlencode(getDict) print url_fin request = urllib2.Request(url_fin) response = urllib2.urlopen(request) response_data = eval(response.read()) markers = [] for doc in response_data['response']['docs']: pointDict = {} pointDict['lat'] = doc['pos_geo'].split(",")[0] pointDict['long'] = doc['pos_geo'].split(",")[1] pointDict['pointId'] = doc['id'] markers.append(pointDict) # Aqui meto unas facetas y conteos de prueba... facets=[] aux = response_data['facet_counts']['facet_fields']['tags'] for i in range(0, len(aux), 2): facetDict={} facetDict['name']=aux[i] facetDict['counts']=aux[i+1] facets.append(facetDict) dataDict['markers'] = markers dataDict['numMarkers'] = len(markers) dataDict['facets'] = facets return HttpResponse(simplejson.dumps(dataDict,indent=4), mimetype='application/javascript')
def signalTextSearch(request,signalId,query): """ """ query = solrutils.scapeSolrQuery(query) dataDict={} print 'http://'+settings.SOLR_IP+':8080/solr_signals/signals/select/?facet=true&facet.field=tags&facet.mincount=1&wt=python&q=id:%s+AND+%s' % (str(signalId),query) url_fin = settings.SIGNALS_SOLR_SELECT+'?facet=true&facet.field=tags&facet.mincount=1&wt=python&q=id:%s+AND+%s' % (str(signalId),query) #print urllib.quote_plus('http://localhost:8080/solr_signals/select/?fq=pos_geo:[42.27730877423709,-6.08642578125%20TO%2042.81152174509788,-5.11962890625]&facet=true&facet.field=tags&facet.mincount=1&wt=python&q=signal:%s' % str(signalId)) request = urllib2.Request(url_fin) response = urllib2.urlopen(request) response_data = eval(response.read()) #r2 = simplejson.load(response_data) #print r2 signals = [] for doc in response_data['response']['docs']: pointDict = {} pointDict['name'] = doc['name'] pointDict['text'] = doc['text'] signals.append(pointDict) # Aqui meto unas facetas y conteos de prueba... facets=[] aux = response_data['facet_counts']['facet_fields']['tags'] for i in range(0, len(aux), 2): facetDict={} facetDict['name']=aux[i] facetDict['counts']=aux[i+1] facets.append(facetDict) dataDict['signals'] = signals dataDict['numSignals'] = len(signals) dataDict['facets'] = facets return HttpResponse(simplejson.dumps(dataDict,indent=4), mimetype='application/javascript')