I've just pushed a new 0.0.8 gem to Rubyforge that includes the fix I described for the sort parameter.

        Erik


On Oct 12, 2009, at 11:03 AM, Paul Rosen wrote:

I did an experiment that worked. In Solr::Request::Standard, in the to_hash() method, I changed the commented line below to the two lines following it.

   sort = @params[:sort].collect do |sort|
     key = sort.keys[0]
     "#{key.to_s} #{sort[key] == :descending ? 'desc' : 'asc'}"
   end.join(',') if @params[:sort]

# START OF CHANGES
   #hash[:q] = sort ? "#...@params[:query]};#{sort}" : @params[:query]
   hash[:q] = @params[:query]
   hash[:sort] = sort if sort != nil
# END OF CHANGES

   hash["q.op"] = @params[:operator]
   hash[:df] = @params[:default_field]

Does this make sense? Should this be changed in the next version of the solr-ruby gem?

Paul Rosen wrote:
Hi all,
I'm using solr-ruby 0.0.7 and am having trouble getting Sort to work.
I have the following statement:
req = Solr::Request::Standard.new(:start => start, :rows => max,
:sort => [ :title_sort => :ascending ],
:query => query, :filter_queries => filter_queries,
:field_list => @field_list,
:facets => {:fields => @facet_fields, :mincount => 1, :missing => true, :limit => -1}, :highlighting => {:field_list => ['text'], :fragment_size => 600}, :shards => @cores) That produces no results, but removing the :sort parameter off does give results.
Here is the output from solr:
INFO: [merged] webapp=/solr path=/select params = {wt = ruby &facet .limit = -1 &rows=30&start=0&facet=true&facet.mincount=1&q=(rossetti);title_sort + asc &fl = archive ,date_label ,genre ,role_ART ,role_AUT ,role_EDT ,role_PBL ,role_TRL ,source ,image ,thumbnail ,text_url ,title ,alternative ,uri ,url ,exhibit_type ,license ,title_sort ,author_sort &qt = standard &facet .missing = true &hl .fl = text &facet .field = genre &facet .field = archive &facet.field=freeculture&hl.fragsize=600&hl=true&shards=localhost: 8983/solr/merged} status=0 QTime=19 It looks to me like the string should have "&sort=title_sort+asc" instead of ";title_sort_asc" tacked on to the query, but I'm not sure about that.
Any clues what I'm doing wrong?
Thanks,
Paul


Reply via email to