mirror of https://github.com/apache/lucene.git
SOLR-151: Added <optimize/> command support. Also, committing a few files missed from previous dismax support commit.
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@505109 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4ac217681f
commit
cd44713a89
|
@ -90,16 +90,12 @@ class Solr::Connection
|
|||
return response.ok?
|
||||
end
|
||||
|
||||
# TODO add optimize, which can be hacked like this, interestingly!
|
||||
# class OptimizeRequest
|
||||
# def handler
|
||||
# "update"
|
||||
# end
|
||||
# def to_s
|
||||
# "<optimize/>"
|
||||
# end
|
||||
# end
|
||||
|
||||
# sends an optimize message to the server
|
||||
def optimize
|
||||
response = send(Solr::Request::Optimize.new)
|
||||
return response.ok?
|
||||
end
|
||||
|
||||
# pings the connection and returns true/false if it is alive or not
|
||||
def ping
|
||||
begin
|
||||
|
|
|
@ -21,3 +21,4 @@ require 'solr/request/standard'
|
|||
require 'solr/request/dismax'
|
||||
require 'solr/request/update'
|
||||
require 'solr/request/index_info'
|
||||
require 'solr/request/optimize'
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
class Solr::Request::Dismax < Solr::Request::Standard
|
||||
|
||||
VALID_PARAMS.replace(VALID_PARAMS + [:tie_breaker, :query_fields, :minimum_match, :phrase_fields, :phrase_slop,
|
||||
:boost_query, :boost_functions])
|
||||
|
||||
def initialize(params)
|
||||
super(params)
|
||||
@query_type = "dismax"
|
||||
end
|
||||
|
||||
def to_hash
|
||||
hash = super
|
||||
hash[:tie] = @params[:tie_breaker]
|
||||
hash[:mm] = @params[:minimum_match]
|
||||
hash[:qf] = @params[:query_fields]
|
||||
hash[:pf] = @params[:phrase_fields]
|
||||
hash[:ps] = @params[:phrase_slop]
|
||||
hash[:bq] = @params[:boost_query]
|
||||
hash[:bf] = @params[:boost_functions]
|
||||
return hash
|
||||
end
|
||||
|
||||
end
|
|
@ -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.
|
||||
|
||||
require 'solr/xml'
|
||||
|
||||
class Solr::Request::Optimize < Solr::Request::Update
|
||||
|
||||
def to_s
|
||||
Solr::XML::Element.new('optimize').to_s
|
||||
end
|
||||
|
||||
end
|
|
@ -20,4 +20,5 @@ require 'solr/response/standard'
|
|||
require 'solr/response/dismax'
|
||||
require 'solr/response/commit'
|
||||
require 'solr/response/delete'
|
||||
require 'solr/response/index_info'
|
||||
require 'solr/response/index_info'
|
||||
require 'solr/response/optimize'
|
|
@ -0,0 +1,8 @@
|
|||
class Solr::Response::Dismax < Solr::Response::Standard
|
||||
# no need for special processing
|
||||
|
||||
# FIXME: 2007-02-07 <coda.hale@gmail.com> -- The existence of this class indicates that
|
||||
# the Request/Response pair architecture is a little hinky. Perhaps we could refactor
|
||||
# out some of the most common functionality -- Common Query Parameters, Highlighting Parameters,
|
||||
# Simple Facet Parameters, etc. -- into modules?
|
||||
end
|
|
@ -0,0 +1,14 @@
|
|||
# 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::Optimize < Solr::Response::Commit
|
||||
end
|
|
@ -97,6 +97,11 @@ class ServerTest < Test::Unit::TestCase
|
|||
assert_equal "<result status=\"0\"></result>", response.raw_response
|
||||
end
|
||||
|
||||
def test_optimize
|
||||
response = @connection.send(Solr::Request::Optimize.new)
|
||||
assert_equal "<result status=\"0\"></result>", response.raw_response
|
||||
end
|
||||
|
||||
def test_ping
|
||||
assert_equal true, @connection.ping
|
||||
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 DismaxRequestTest < Test::Unit::TestCase
|
||||
|
||||
def test_basic_query
|
||||
request = Solr::Request::Dismax.new(:query => 'query', :phrase_slop => '1000')
|
||||
assert_match(/q=query/, request.to_s)
|
||||
assert_match(/qt=dismax/, request.to_s)
|
||||
assert_match(/ps=1000/, request.to_s)
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue