[ckan-dev] Case insensitive package sort
Khalegh Mamakani
khalegh at highwaythreesolutions.com
Mon Jun 23 21:47:06 UTC 2014
Implementing before_index and rebuilding search index solved my problem.
def before_index(self, pkg_dict):
title = pkg_dict['title']
if title:
pkg_dict['title_string'] = title.lower()
return pkg_dict
-Khalegh
On Jun 23, 2014, at 2:30 PM, Khalegh Mamakani <khalegh at highwaythreesolutions.com> wrote:
> Hi everybody,
>
> When sorting the list of packages, ckan tackes character cases into account. I tried to do a case insensitive sorting by changing the Solr schema, but it wasn’t successful.
> Ckan uses title_string as a copy of package title for sorting. The index_package method of PackageSearchIndex class assigns the value of title to title string :
>
>
> # add to string field for sorting
> title = pkg_dict.get('title')
> if title:
> pkg_dict['title_string'] = title
>
> But, shouldn’t it use title.lower() instead? It might be even better to use a configuration attribute to let the user set the his/her own sorting preferences and based on that assigns title or title.lower() to title_string.
>
> Does any body know a better way of achieving a case insensitive sort?
>
> Thanks,
> Khalegh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/ckan-dev/attachments/20140623/787f76c1/attachment-0003.html>
More information about the ckan-dev
mailing list