Class: RSolr::Adapter::HTTP
- Inherits:
-
Object
- Object
- RSolr::Adapter::HTTP
- Defined in:
- lib/rsolr/adapter/http.rb
Overview
Connection for standard HTTP Solr server
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#connector ⇒ Object
readonly
Returns the value of attribute connector.
-
#opts ⇒ Object
readonly
Returns the value of attribute opts.
Instance Method Summary collapse
-
#initialize(opts = {}, &block) ⇒ HTTP
constructor
opts can have: :url => ‘localhost:8080/solr’ :select_path => ‘/the/url/path/to/the/select/handler’ :update_path => ‘/the/url/path/to/the/update/handler’ :luke_path => ‘/admin/luke’.
-
#send_request(path, params = {}, data = nil) ⇒ Object
send a request to the connection request ‘/update’, :wt=>:xml, ‘</commit>’.
Constructor Details
#initialize(opts = {}, &block) ⇒ HTTP
opts can have:
:url => 'http://localhost:8080/solr'
:select_path => '/the/url/path/to/the/select/handler'
:update_path => '/the/url/path/to/the/update/handler'
:luke_path => '/admin/luke'
14 15 16 17 18 |
# File 'lib/rsolr/adapter/http.rb', line 14 def initialize(opts={}, &block) opts[:url]||='http://127.0.0.1:8983/solr' @opts = opts @connector = RSolr::HTTPClient::Connector.new end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
6 7 8 |
# File 'lib/rsolr/adapter/http.rb', line 6 def connection @connection end |
#connector ⇒ Object (readonly)
Returns the value of attribute connector.
6 7 8 |
# File 'lib/rsolr/adapter/http.rb', line 6 def connector @connector end |
#opts ⇒ Object (readonly)
Returns the value of attribute opts.
6 7 8 |
# File 'lib/rsolr/adapter/http.rb', line 6 def opts @opts end |
Instance Method Details
#send_request(path, params = {}, data = nil) ⇒ Object
send a request to the connection request ‘/update’, :wt=>:xml, ‘</commit>’
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rsolr/adapter/http.rb', line 26 def send_request(path, params={}, data=nil) data = data.to_xml if data.respond_to?(:to_xml) if data http_context = connection.post(path, data, params, post_headers) else http_context = connection.get(path, params) end raise RSolr::RequestError.new(http_context[:body]) unless http_context[:status_code] == 200 http_context end |