mirror of https://github.com/apache/lucene.git
Enable Solr::Request::Select to work as a general pass through to any registered request handler using /select?..., and a few other minor changes
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@581952 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a415d8077c
commit
4efd666e24
|
@ -2,6 +2,8 @@ v0.0.6:
|
|||
release_date: TBD
|
||||
changes:
|
||||
- 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 ordering
|
||||
|
||||
v0.0.5:
|
||||
release_date: 2007-08-27
|
||||
|
|
|
@ -17,6 +17,6 @@ class Solr::Request::IndexInfo < Solr::Request::Select
|
|||
end
|
||||
|
||||
def to_hash
|
||||
{:numTerms => 0, :show => 'schema'}.merge(super.to_hash)
|
||||
{:numTerms => 0}.merge(super.to_hash)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -17,8 +17,9 @@ class Solr::Request::Select < Solr::Request::Base
|
|||
|
||||
attr_reader :query_type
|
||||
|
||||
def initialize(qt=nil)
|
||||
def initialize(qt=nil, params={})
|
||||
@query_type = qt
|
||||
@select_params = params
|
||||
end
|
||||
|
||||
def response_format
|
||||
|
@ -34,7 +35,7 @@ class Solr::Request::Select < Solr::Request::Base
|
|||
end
|
||||
|
||||
def to_hash
|
||||
return {:qt => query_type, :wt => 'ruby'}
|
||||
return {:qt => query_type, :wt => 'ruby'}.merge(@select_params)
|
||||
end
|
||||
|
||||
def to_s
|
||||
|
|
|
@ -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'
|
||||
require 'solr/response/optimize'
|
||||
require 'solr/response/select'
|
|
@ -11,7 +11,7 @@
|
|||
# limitations under the License.
|
||||
|
||||
class Solr::Response::Ruby < Solr::Response::Base
|
||||
attr_reader :data
|
||||
attr_reader :data, :header
|
||||
|
||||
def initialize(ruby_code)
|
||||
super
|
||||
|
|
|
@ -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
|
||||
end
|
|
@ -18,8 +18,7 @@ class ModifyDocumentTest < Test::Unit::TestCase
|
|||
def test_update_formatting
|
||||
request = 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.handler
|
||||
end
|
||||
end
|
||||
|
|
|
@ -32,11 +32,12 @@ class ResponseTest < SolrMockBaseTestCase
|
|||
Solr::Response::Ruby.new(' {...')
|
||||
end
|
||||
end
|
||||
|
||||
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
|
||||
# end
|
||||
|
||||
end
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue