Object
opts can be an instance of org.apache.solr.servlet.DirectSolrConnection if opts is NOT an instance of org.apache.solr.servlet.DirectSolrConnection then... required: opts is absolute path to solr home (the directory with "data", "config" etc.)
# File lib/rsolr-direct.rb, line 55 def initialize opts begin org.apache.solr.servlet.DirectSolrConnection rescue NameError raise MissingRequiredJavaLibs end if opts.is_a?(Hash) and opts[:solr_home] raise InvalidSolrHome unless File.exists?(opts[:solr_home]) opts[:data_dir] ||= File.join(opts[:solr_home], 'data') @opts = opts elsif opts.class.to_s == "Java::OrgApacheSolrCore::SolrCore" @direct = org.apache.solr.servlet.DirectSolrConnection.new(opts) elsif opts.class.to_s == "Java::OrgApacheSolrServlet::DirectSolrConnection" @direct = opts end opts[:auto_connect] = true unless opts.key?(:auto_connect) self.direct if opts[:auto_connect] end
# File lib/rsolr-direct.rb, line 82 def close if @direct @direct.close @direct = nil end end
sets the @direct instance variable if it has not yet been set
# File lib/rsolr-direct.rb, line 75 def direct @direct ||= org.apache.solr.servlet.DirectSolrConnection.new(opts[:solr_home], @opts[:data_dir], nil) end
send a request to the connection
# File lib/rsolr-direct.rb, line 90 def execute client, request_context #data = request_context[:data] #data = data.to_xml if data.respond_to?(:to_xml) url = [request_context[:path], request_context[:query]].join("?") url = "/" + url unless url[0].chr == "/" begin body = direct.request(url, request_context[:data]) rescue $!.extend RSolr::Error::SolrContext $!.request = request_context raise $! end { :status => 200, :body => body, :headers => {} } end
Generated with the Darkfish Rdoc Generator 2.