From 75b09521a44ebe2f3398e2267b433df57939b06b Mon Sep 17 00:00:00 2001 From: kindly Date: Sun, 7 Apr 2013 02:45:50 +0100 Subject: [PATCH] 739 add extra options to solr query --- ckan/lib/search/query.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/ckan/lib/search/query.py b/ckan/lib/search/query.py index e43825f8d1e..5d6c519ebac 100644 --- a/ckan/lib/search/query.py +++ b/ckan/lib/search/query.py @@ -16,9 +16,9 @@ _open_licenses = None VALID_SOLR_PARAMETERS = set([ - 'q', 'fl', 'fq', 'rows', 'sort', 'start', 'wt', 'qf', + 'q', 'fl', 'fq', 'rows', 'sort', 'start', 'wt', 'qf', 'bf', 'facet', 'facet.mincount', 'facet.limit', 'facet.field', - 'extras' # Not used by Solr, but useful for extensions + 'extras', 'fq_list', 'tie', 'defType', 'mm' ]) # for (solr) package searches, this specifies the fields that are searched @@ -332,7 +332,10 @@ def run(self, query): # filter for package status if not '+state:' in fq: fq += " +state:active" - query['fq'] = fq + query['fq'] = [fq] + + fq_list = query.get('fq_list', []) + query['fq'].extend(fq_list) # faceting query['facet'] = query.get('facet', 'true') @@ -346,12 +349,13 @@ def run(self, query): query['wt'] = query.get('wt', 'json') # If the query has a colon in it then consider it a fielded search and do use dismax. - if ':' not in query['q']: - query['defType'] = 'dismax' - query['tie'] = '0.1' + defType = query.get('defType', 'dismax') + if ':' not in query['q'] or defType == 'edismax': + query['defType'] = defType + query['tie'] = query.get('tie', '0.1') # this minimum match is explained # http://wiki.apache.org/solr/DisMaxQParserPlugin#mm_.28Minimum_.27Should.27_Match.29 - query['mm'] = '2<-1 5<80%' + query['mm'] = query.get('mm', '2<-1 5<80%') query['qf'] = query.get('qf', QUERY_FIELDS) conn = make_connection()