Apache Solr open-source search software
Enable Solr::Request::Select to work as a general pass through to any registered request handler using /select?..., and a few other minor changes
Erik Hatcher4efd666e2406
diff --git a/client/ruby/solr-ruby/CHANGES.yml b/client/ruby/solr-ruby/CHANGES.ymlindex 68fdb302d0d..193a7c7cc99 100644--- a/client/ruby/solr-ruby/CHANGES.yml+++ b/client/ruby/solr-ruby/CHANGES.yml@@ -2,6 +2,8 @@ v0.0.6:release_date: TBDchanges:- Added Solr::Request::Spellcheck+ - Enabled Solr::Requst::Select to work as a general pass through to any registered request handler+ - Fixed modify_document_test.rb so as to not be brittle with Hash orderingv0.0.5:release_date: 2007-08-27diff --git a/client/ruby/solr-ruby/lib/solr/request/index_info.rb b/client/ruby/solr-ruby/lib/solr/request/index_info.rbindex 30431711fe1..d4eeea54d67 100755--- a/client/ruby/solr-ruby/lib/solr/request/index_info.rb+++ b/client/ruby/solr-ruby/lib/solr/request/index_info.rb@@ -17,6 +17,6 @@ class Solr::Request::IndexInfo < Solr::Request::Selectenddef to_hash- {:numTerms => 0, :show => 'schema'}.merge(super.to_hash)+ {:numTerms => 0}.merge(super.to_hash)endenddiff --git a/client/ruby/solr-ruby/lib/solr/request/select.rb b/client/ruby/solr-ruby/lib/solr/request/select.rbindex eec4fa71bb8..122c5b71156 100644--- a/client/ruby/solr-ruby/lib/solr/request/select.rb+++ b/client/ruby/solr-ruby/lib/solr/request/select.rb@@ -17,8 +17,9 @@ class Solr::Request::Select < Solr::Request::Baseattr_reader :query_type- def initialize(qt=nil)+ def initialize(qt=nil, params={})@query_type = qt+ @select_params = paramsenddef response_format@@ -34,7 +35,7 @@ class Solr::Request::Select < Solr::Request::Baseenddef to_hash- return {:qt => query_type, :wt => 'ruby'}+ return {:qt => query_type, :wt => 'ruby'}.merge(@select_params)enddef to_sdiff --git a/client/ruby/solr-ruby/lib/solr/response.rb b/client/ruby/solr-ruby/lib/solr/response.rbindex ce3c0812b3d..72c55fe664c 100755--- a/client/ruby/solr-ruby/lib/solr/response.rb+++ b/client/ruby/solr-ruby/lib/solr/response.rb@@ -23,4 +23,5 @@ require 'solr/response/dismax'require 'solr/response/commit'require 'solr/response/delete'require 'solr/response/index_info'-require 'solr/response/optimize'\ No newline at end of file+require 'solr/response/optimize'+require 'solr/response/select'\ No newline at end of filediff --git a/client/ruby/solr-ruby/lib/solr/response/ruby.rb b/client/ruby/solr-ruby/lib/solr/response/ruby.rbindex 05619b9a20a..6e8f651748c 100644--- a/client/ruby/solr-ruby/lib/solr/response/ruby.rb+++ b/client/ruby/solr-ruby/lib/solr/response/ruby.rb@@ -11,7 +11,7 @@# limitations under the License.class Solr::Response::Ruby < Solr::Response::Base- attr_reader :data+ attr_reader :data, :headerdef initialize(ruby_code)superdiff --git a/client/ruby/solr-ruby/lib/solr/response/select.rb b/client/ruby/solr-ruby/lib/solr/response/select.rbnew file mode 100755index 00000000000..8e2185d67de--- /dev/null+++ b/client/ruby/solr-ruby/lib/solr/response/select.rb@@ -0,0 +1,17 @@+# The ASF licenses this file to You under the Apache License, Version 2.0+# (the "License"); you may not use this file except in compliance with+# the License. You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.++class Solr::Response::Select < Solr::Response::Ruby+ def initialize(ruby_code)+ super+ end+enddiff --git a/client/ruby/solr-ruby/test/unit/modify_document_test.rb b/client/ruby/solr-ruby/test/unit/modify_document_test.rbindex 5760058c2fa..9291dd16623 100755--- a/client/ruby/solr-ruby/test/unit/modify_document_test.rb+++ b/client/ruby/solr-ruby/test/unit/modify_document_test.rb@@ -18,8 +18,7 @@ class ModifyDocumentTest < Test::Unit::TestCasedef test_update_formattingrequest = Solr::Request::ModifyDocument.new(:id => 10, :overwrite => {:name => ['val1', 'val2'], :copyfield => nil})assert_equal :xml, request.response_format- assert_equal 'update?mode=copyfield:OVERWRITE,name:OVERWRITE', request.handler-- assert_match(/<add>[\s]*<doc>[\s]*<field name=["']id['"]>10<\/field>[\s]*<field name=['"]name['"]>val1<\/field>[\s]*<field name=['"]name['"]>val2<\/field>[\s]*<\/doc>[\s]*<\/add>/, request.to_s)+ assert_match /copyfield\:OVERWRITE/, request.handler+ assert_match /name\:OVERWRITE/, request.handlerendenddiff --git a/client/ruby/solr-ruby/test/unit/response_test.rb b/client/ruby/solr-ruby/test/unit/response_test.rbindex 846510c04b8..1496262beed 100644--- a/client/ruby/solr-ruby/test/unit/response_test.rb+++ b/client/ruby/solr-ruby/test/unit/response_test.rb@@ -32,11 +32,12 @@ class ResponseTest < SolrMockBaseTestCaseSolr::Response::Ruby.new(' {...')endend-- def test_bogus_request_handling- assert_raise(Solr::Exception) do- Solr::Response::Base.make_response(Solr::Request::Select.new, "response data")- end- end++ # This is now an acceptable use of Select, for the default request handler with no parameters (other than &wt=ruby)+ # def test_bogus_request_handling+ # assert_raise(Solr::Exception) do+ # Solr::Response::Base.make_response(Solr::Request::Select.new, "response data")+ # end+ # endenddiff --git a/client/ruby/solr-ruby/test/unit/select_test.rb b/client/ruby/solr-ruby/test/unit/select_test.rbnew file mode 100755index 00000000000..ae1a40bb719--- /dev/null+++ b/client/ruby/solr-ruby/test/unit/select_test.rb@@ -0,0 +1,25 @@+# The ASF licenses this file to You under the Apache License, Version 2.0+# (the "License"); you may not use this file except in compliance with+# the License. You may obtain a copy of the License at+#+# http://www.apache.org/licenses/LICENSE-2.0+#+# Unless required by applicable law or agreed to in writing, software+# distributed under the License is distributed on an "AS IS" BASIS,+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+# See the License for the specific language governing permissions and+# limitations under the License.++require 'test/unit'+require 'solr'++class SelectTest < Test::Unit::TestCase++ def test_basic_query+ request = Solr::Request::Select.new('custom', :q => 'query')+ assert_equal :ruby, request.response_format+ assert_equal 'select', request.handler+ assert_equal 'query', request.to_hash[:q]+ end++end