Update standard request to modern sort parameter style

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@803735 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erik Hatcher 2009-08-12 22:48:43 +00:00
parent 4256d6693a
commit 56e0a65193
3 changed files with 10 additions and 4 deletions

View File

@ -1,3 +1,8 @@
v0.0.8:
release_date: TBD
changes:
- Updated Solr::Request::Standard to use modern style sort parameter rather
v0.0.7:
release_date: 2009-03-06
changes:

View File

@ -46,11 +46,11 @@ class Solr::Request::Standard < Solr::Request::Select
hash = {}
# standard request param processing
sort = @params[:sort].collect do |sort|
hash[:sort] = @params[:sort].collect do |sort|
key = sort.keys[0]
"#{key.to_s} #{sort[key] == :descending ? 'desc' : 'asc'}"
end.join(',') if @params[:sort]
hash[:q] = sort ? "#{@params[:query]};#{sort}" : @params[:query]
hash[:q] = @params[:query]
hash["q.op"] = @params[:operator]
hash[:df] = @params[:default_field]

View File

@ -95,8 +95,9 @@ class StandardRequestTest < Test::Unit::TestCase
end
def test_basic_sort
request = Solr::Request::Standard.new(:query => 'query', :sort => [{:title => :descending}])
assert_equal 'query;title desc', request.to_hash[:q]
request = Solr::Request::Standard.new(:query => 'query', :sort => [{:title => :descending}, {:date => :ascending}])
assert_equal 'query', request.to_hash[:q]
assert_equal 'title desc,date asc', request.to_hash[:sort]
end
def test_highlighting