我的 PySolr 代码如下
filter_queries = []
facet_fields = []
for key, value in request.GET._iterlists():
if(key != 'Rows' and key != 'Sort' and key != 'Facet' and key != 'FacetFields' ):
filter_queries.append(key + ':' + request.GET[key])
else:
if(key == 'Rows'):
rows = request.GET['Rows']
if(key == 'Sort'):
sort = request.GET['Sort']
if(key == 'Facet'):
facet = request.GET['Facet']
if(key == 'FacetFields'):
facet_fields = request.GET['FacetFields'].split(",")
if(key == 'Start'):
start = request.GET['Start']
params = {
'fq': filter_queries,
'facet': facet,
'facet.field': facet_fields,
'rows': rows,
'sort': sort,
'start':start,
}
try:
results = solr.search(q='*', **params)
documents = json.dumps(results, default=lambda o: o.__dict__)
except Exception as e:
# handles SOLR invalid queries
documents = json.dumps({'error': 1, 'reason': str(e)})
return HttpResponse(documents)
当我通过?CityId = 3156
它的工作正常时,但现在我需要为 CityId 传递两个值(例如 solr query url ?q=CityId:3156+OR+CityId:2278
)如何在 PySolr 中实现这一点?