Apache Solr open-source search software
add new indexinfo request capability
Erik Hatcherd5bc3ec4ba58
diff --git a/client/ruby/solrb/lib/solr/request.rb b/client/ruby/solrb/lib/solr/request.rbindex a01d849763f..f0108a3aad7 100755--- a/client/ruby/solrb/lib/solr/request.rb+++ b/client/ruby/solrb/lib/solr/request.rb@@ -18,3 +18,4 @@ require 'solr/request/ping'require 'solr/request/select'require 'solr/request/standard'require 'solr/request/update'+require 'solr/request/index_info'diff --git a/client/ruby/solrb/lib/solr/request/index_info.rb b/client/ruby/solrb/lib/solr/request/index_info.rbnew file mode 100755index 00000000000..b97459ecfda--- /dev/null+++ b/client/ruby/solrb/lib/solr/request/index_info.rb@@ -0,0 +1,21 @@+# 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.++module Solr+ module Request+ class IndexInfo < Solr::Request::Select+ def initialize+ super('indexinfo')+ end+ end+ end+enddiff --git a/client/ruby/solrb/lib/solr/response.rb b/client/ruby/solrb/lib/solr/response.rbindex 6394c592e10..4f6b3e97f72 100755--- a/client/ruby/solrb/lib/solr/response.rb+++ b/client/ruby/solrb/lib/solr/response.rb@@ -18,3 +18,4 @@ require 'solr/response/add_document'require 'solr/response/standard'require 'solr/response/commit'require 'solr/response/delete'+require 'solr/response/index_info'\ No newline at end of filediff --git a/client/ruby/solrb/lib/solr/response/base.rb b/client/ruby/solrb/lib/solr/response/base.rbindex 7d492c2cab4..300d8f24eab 100644--- a/client/ruby/solrb/lib/solr/response/base.rb+++ b/client/ruby/solrb/lib/solr/response/base.rb@@ -28,6 +28,8 @@ module Solrraise Solr::Exception.new("unknown response format: #{request.response_format}" )end+ # TODO: Factor out this case... perhaps the request object should provide the response class instead? Or dynamically align by class name?+ # Maybe the request itself could have the response handling features that get mixed in with a single general purpose response object?case requestwhen Solr::Request::Pingreturn Solr::Response::Ping.new(raw)@@ -39,6 +41,8 @@ module Solrreturn Solr::Response::Standard.new(raw)when Solr::Request::Deletereturn Solr::Response::Delete.new(raw)+ when Solr::Request::IndexInfo+ return Solr::Response::IndexInfo.new(raw)elseraise Solr::Exception.new("unknown request type: #{request.class}")enddiff --git a/client/ruby/solrb/lib/solr/response/index_info.rb b/client/ruby/solrb/lib/solr/response/index_info.rbnew file mode 100755index 00000000000..98c20b74115--- /dev/null+++ b/client/ruby/solrb/lib/solr/response/index_info.rb@@ -0,0 +1,30 @@+# 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.++module Solr+ module Response+ class IndexInfo < Solr::Response::Ruby+ def initialize(ruby_code)+ super(ruby_code)+ end++ def num_docs+ return @data['index']['numDocs']+ end++ def field_names+ return @data['fields'].keys+ end++ end+ end+enddiff --git a/client/ruby/solrb/solr/solr/conf/solrconfig.xml b/client/ruby/solrb/solr/solr/conf/solrconfig.xmlindex 451f23a8bb1..ac3416b4c4e 100755--- a/client/ruby/solrb/solr/solr/conf/solrconfig.xml+++ b/client/ruby/solrb/solr/solr/conf/solrconfig.xml@@ -224,6 +224,7 @@The "standard" request handler is the default and will be used if qtis not specified in the request.-->+ <requestHandler name="indexinfo" class="solr.IndexInfoRequestHandler"/><requestHandler name="standard" class="solr.StandardRequestHandler"><!-- default values for query parameters --><lst name="defaults">diff --git a/client/ruby/solrb/solr/webapps/solr.war b/client/ruby/solrb/solr/webapps/solr.warindex f07c16e9f93..9dfbf082113 100644Binary files a/client/ruby/solrb/solr/webapps/solr.war and b/client/ruby/solrb/solr/webapps/solr.war differdiff --git a/client/ruby/solrb/test/conf/solrconfig.xml b/client/ruby/solrb/test/conf/solrconfig.xmlindex 451f23a8bb1..ac3416b4c4e 100755--- a/client/ruby/solrb/test/conf/solrconfig.xml+++ b/client/ruby/solrb/test/conf/solrconfig.xml@@ -224,6 +224,7 @@The "standard" request handler is the default and will be used if qtis not specified in the request.-->+ <requestHandler name="indexinfo" class="solr.IndexInfoRequestHandler"/><requestHandler name="standard" class="solr.StandardRequestHandler"><!-- default values for query parameters --><lst name="defaults">diff --git a/client/ruby/solrb/test/functional/server_test.rb b/client/ruby/solrb/test/functional/server_test.rbindex 52a93969d39..58256dafcde 100644--- a/client/ruby/solrb/test/functional/server_test.rb+++ b/client/ruby/solrb/test/functional/server_test.rb@@ -91,7 +91,7 @@ class ServerTest < Test::Unit::TestCasedef test_escapingdoc = Solr::Document.new :id => 47, :ruby_text => 'puts "ouch!"'- @connection.send(Solr::Request::AddDocument.new(doc))+ @connection.add(doc)@connection.commitrequest = Solr::Request::Standard.new :query => 'ouch'@@ -119,6 +119,14 @@ class ServerTest < Test::Unit::TestCaseassert_equal "ERROR:unknown field 'bogus'", response.status_messageend+ def test_index_info+ doc = {:id => 999, :test_index_facet => 'value'}+ @connection.add(doc)+ info = @connection.send(Solr::Request::IndexInfo.new)+ assert info.field_names.include?("id") && info.field_names.include?("test_index_facet")+ assert_equal 1, info.num_docs+ end+# wipe the index cleandef clean@connection.delete_by_query('[* TO *]')