Class: AboutPage::Solr
Instance Attribute Summary collapse
Instance Method Summary
collapse
#add_header, #expects, #messages, render_with, #set_headers!
Constructor Details
#initialize(rsolr_instance, options = {}) ⇒ Solr
Returns a new instance of Solr.
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/about_page/solr.rb', line 15
def initialize rsolr_instance, options = {}
self.rsolr = rsolr_instance
self.options = options
self.options[:luke] ||= 'admin/luke'
if self.options[:registry] == :registry
self.options[:registry] = 'admin/registry.jsp'
else
self.options[:registry] ||= 'admin/mbeans'
end
self.options[:expects] ||= {}
self.options[:expects][:numDocs] ||= 1
@request_expectations = {}
end
|
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
4
5
6
|
# File 'lib/about_page/solr.rb', line 4
def options
@options
end
|
#rsolr ⇒ Object
Returns the value of attribute rsolr.
4
5
6
|
# File 'lib/about_page/solr.rb', line 4
def rsolr
@rsolr
end
|
Instance Method Details
#index ⇒ Object
59
60
61
|
# File 'lib/about_page/solr.rb', line 59
def index
(schema || {})['index'] || {}
end
|
#numDocs ⇒ Object
67
|
# File 'lib/about_page/solr.rb', line 67
def numDocs; index[:numDocs] || index['numDocs']; end
|
#ping ⇒ Object
30
31
32
33
34
|
# File 'lib/about_page/solr.rb', line 30
def ping
rsolr.get('admin/ping')['status']
rescue
nil
end
|
#preflight(request) ⇒ Object
69
70
71
72
73
74
|
# File 'lib/about_page/solr.rb', line 69
def preflight request
@schema = nil
@registry = nil
super
end
|
#registry ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/about_page/solr.rb', line 42
def registry
@registry ||= begin
h = {}
resp = rsolr.get self.options[:registry], :params => { :wt => 'xml' }
doc = Nokogiri::XML resp
doc.xpath('/solr/*').each do |node|
next if node.name == "solr-info"
h[node.name] = node.text
end
h
end
rescue
{}
end
|
#schema ⇒ Object
36
37
38
39
40
|
# File 'lib/about_page/solr.rb', line 36
def schema
@schema ||= rsolr.get self.options[:luke], :params => { :show => 'schema', :numTerms => 0 }
rescue
{}
end
|
#to_h ⇒ Object
63
64
65
|
# File 'lib/about_page/solr.rb', line 63
def to_h
indexend
|