Class: RSolr::Adapter::HTTP

Inherits:
Object
  • Object
show all
Defined in:
lib/rsolr/adapter/http.rb

Overview

Connection for standard HTTP Solr server

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}, &block) ⇒ HTTP

opts can have:

:url => 'http://localhost:8080/solr'


10
11
12
13
14
# File 'lib/rsolr/adapter/http.rb', line 10

def initialize(opts={}, &block)
  opts[:url]||='http://127.0.0.1:8983/solr'
  @opts = opts
  @connector = RSolr::HTTPClient::Connector.new
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



6
7
8
# File 'lib/rsolr/adapter/http.rb', line 6

def connection
  @connection
end

#connectorObject (readonly)

Returns the value of attribute connector.



6
7
8
# File 'lib/rsolr/adapter/http.rb', line 6

def connector
  @connector
end

#optsObject (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>’



22
23
24
25
26
27
28
29
30
31
# File 'lib/rsolr/adapter/http.rb', line 22

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