Skip to content

Commit

Permalink
[release-v1.6.1] Strip leading spaces from dataset title upon indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Murray committed Mar 21, 2012
1 parent 7b7ed10 commit 2bb7faa
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions ckan/lib/search/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ def index_package(self, pkg_dict):
# mark this CKAN instance as data source:
pkg_dict['site_id'] = config.get('ckan.site_id')

# Strip a selection of the fields.
# These fields are possible candidates for sorting search results on,
# so we strip leading spaces because solr will sort " " before "a" or "A".
for field_name in ['title']:
try:
pkg_dict[field_name] = pkg_dict[field_name].lstrip()
except KeyError:
pass

# add a unique index_id to avoid conflicts
import hashlib
pkg_dict['index_id'] = hashlib.md5('%s%s' % (pkg_dict['id'],config.get('ckan.site_id'))).hexdigest()
Expand Down

0 comments on commit 2bb7faa

Please sign in to comment.