Class: Solr::Adapter::Direct
- Inherits:
-
Object
- Object
- Solr::Adapter::Direct
- Includes:
- CommonMethods
- Defined in:
- lib/solr/adapter/direct.rb
Overview
Connection for JRuby + DirectSolrConnection
Instance Attribute Summary collapse
-
#connection ⇒ Object
Returns the value of attribute connection.
-
#home_dir ⇒ Object
Returns the value of attribute home_dir.
-
#opts ⇒ Object
Returns the value of attribute opts.
Instance Method Summary collapse
-
#initialize(opts) {|@connection| ... } ⇒ Direct
constructor
required: opts is absolute path to solr home (the directory with “data”, “config” etc.) opts must also contain either :dist_dir => ‘absolute path to solr distribution root or :jar_paths => [’array of directories containing the solr lib/jars’] OTHER OPTS: :select_path => ‘the/select/handler’ :update_path => ‘the/update/handler’ If a block is given, the @connection instance (DirectSolrConnection) is yielded.
-
#send_request(request_url_path, params = {}, data = nil) ⇒ Object
send a request to the connection request ‘/update’, :wt=>:xml, ‘</commit>’.
Constructor Details
#initialize(opts) {|@connection| ... } ⇒ Direct
required: opts is absolute path to solr home (the directory with “data”, “config” etc.) opts must also contain either
:dist_dir => 'absolute path to solr distribution root
or
:jar_paths => ['array of directories containing the solr lib/jars']
OTHER OPTS:
:select_path => 'the/select/handler'
:update_path => 'the/update/handler'
If a block is given, the @connection instance (DirectSolrConnection) is yielded
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/solr/adapter/direct.rb', line 23 def initialize(opts, &block) @home_dir = opts[:home_dir] opts[:data_dir] ||= File.join(@home_dir , 'data') if opts[:dist_dir] # add the standard lib and dist directories to the :jar_paths opts[:jar_paths] = [File.join(opts[:dist_dir], 'lib'), File.join(opts[:dist_dir], 'dist')] end @opts = .merge(opts) require_jars(@opts[:jar_paths]) import_dependencies @connection = DirectSolrConnection.new(@home_dir, @opts[:data_dir], nil) yield @connection if block_given? end |
Instance Attribute Details
#connection ⇒ Object
Returns the value of attribute connection.
12 13 14 |
# File 'lib/solr/adapter/direct.rb', line 12 def connection @connection end |
#home_dir ⇒ Object
Returns the value of attribute home_dir.
12 13 14 |
# File 'lib/solr/adapter/direct.rb', line 12 def home_dir @home_dir end |
#opts ⇒ Object
Returns the value of attribute opts.
12 13 14 |
# File 'lib/solr/adapter/direct.rb', line 12 def opts @opts end |
Instance Method Details
#send_request(request_url_path, params = {}, data = nil) ⇒ Object
send a request to the connection request ‘/update’, :wt=>:xml, ‘</commit>’
39 40 41 42 43 44 45 46 47 |
# File 'lib/solr/adapter/direct.rb', line 39 def send_request(request_url_path, params={}, data=nil) data = data.to_xml if data.respond_to?(:to_xml) full_path = build_url(request_url_path, params) begin @connection.request(full_path, data) rescue raise Solr::RequestError.new($!.) end end |