Tuesday, August 7, 2007

Sorting and indexing

I have made a few changes to the portal, mostly adding support for date, title and score sorting
as well as a few minor wording changes per Katherine. I still have not had a chance to go over
Advanced Searching as much as I would like, sometimes it seems to make sense, sometimes it does not.

I am rebuilding the indexes with some date sorting. I need to go over the dates used for sorting. Practically I think
we need to have one sortable date per record, and I need an algorithm for picking that date.
I think the logic should be go through the various date fields in the originInfo in some agreed upon order
first looking for one with a keyDate = w3cdtf attribute
Failing that look again through the list for any keyDate value
Failing that look again through the list for the first date.

I am running the date I get from above (actually at the moment just DateIssued) through a combination of
a standard Java date parser and failing that through the CDL temper library that attempts to normalize the date.
Mostly from that I get some kind of date range. I have arbitrarily chosen the middle date of that range as the sorting
date for that record.

Any comments on the above process would be appreciated.

Another struggle was getting the acts_as_solr module to correctly sort the result sets. I finally found the solution in the acts_methods.rb where it documents that the configuration fields options passed to acts_as_solr can be an array of hashes. This finally got it working, prior to the change, everything was getting a '_t' tacked on to the end which was breaking the date sorting. I still never got it to correctly order by score. But since that was the default is to sort by score, in that case I just don't pass in an :order specification when I call find_by_solr

1 comment:

Bernie Kravitz said...

I'm having a similar issue with sort order, and I'm not quite sure what you are referring to you in your post. Do you mind posting some sample code?