Skip to content

Commit

Permalink
739 add extra options to solr query
Browse files Browse the repository at this point in the history
  • Loading branch information
kindly committed Apr 7, 2013
1 parent b5b2f92 commit f9bb3ee
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions ckan/lib/search/query.py
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand All @@ -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()
Expand Down

0 comments on commit f9bb3ee

Please sign in to comment.