Skip to content

Commit

Permalink
[#739] Pop extras from query parameters before sending them to Solr
Browse files Browse the repository at this point in the history
Also move them from the root search params dict to 'extras', so they can
be also be used on GET requests, eg:

http://ckan/api/action/package_search?q=dogs&ext_bbox=1.36,41.13,1.38,41.15

gets transformed to:

{
    'q': 'dogs',
    'extras': {
        'ext_bbox': '1.36,41.13,1.38,41.15'
    }
}
  • Loading branch information
amercader committed Apr 12, 2013
1 parent a831e43 commit 7d12663
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ckan/lib/search/query.py
Expand Up @@ -358,6 +358,9 @@ def run(self, query):
query['mm'] = query.get('mm', '2<-1 5<80%')
query['qf'] = query.get('qf', QUERY_FIELDS)

# Pop these ones are Solr does not need them
query.pop('extras', None)

conn = make_connection()
log.debug('Package query: %r' % query)
try:
Expand Down
6 changes: 6 additions & 0 deletions ckan/logic/action/get.py
Expand Up @@ -1243,6 +1243,12 @@ def package_search(context, data_dict):

_check_access('package_search', context, data_dict)

# Move ext_ params to extras and remove them from the root of the search
# params, so they don't cause and error
data_dict['extras'] = data_dict.get('extras', {})
for key in [key for key in data_dict.keys() if key.startswith('ext_')]:
data_dict['extras'][key] = data_dict.pop(key)

# check if some extension needs to modify the search params
for item in plugins.PluginImplementations(plugins.IPackageController):
data_dict = item.before_search(data_dict)
Expand Down

0 comments on commit 7d12663

Please sign in to comment.