Module: Supernova::Solr

Included in:
SolrIndexer
Defined in:
lib/supernova/solr.rb

Defined Under Namespace

Classes: ConnectionDummy

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.urlObject

Returns the value of attribute url.



25
26
27
# File 'lib/supernova/solr.rb', line 25

def url
  @url
end

Class Method Details

.add(row) ⇒ Object

only to be used for testing



50
51
52
# File 'lib/supernova/solr.rb', line 50

def add(row)
  Supernova::SolrIndexer.new.index_with_json([row])
end

.commit!Object



45
46
47
# File 'lib/supernova/solr.rb', line 45

def commit!
  update_request("<commit />")
end

.connectionObject



31
32
33
# File 'lib/supernova/solr.rb', line 31

def connection
  ConnectionDummy.new
end

.included(base) ⇒ Object



55
56
57
58
# File 'lib/supernova/solr.rb', line 55

def self.included(base)
  base.extend(Supernova::ClassMethods)
  base.criteria_class = Supernova::SolrCriteria
end

.select_urlObject



27
28
29
# File 'lib/supernova/solr.rb', line 27

def select_url
  "#{url}/select"
end

.truncate!Object



41
42
43
# File 'lib/supernova/solr.rb', line 41

def truncate!
  update_request("<delete><query>*:*</query></delete>")
end

.update_request(payload) ⇒ Object



35
36
37
38
39
# File 'lib/supernova/solr.rb', line 35

def update_request(payload)
  Typhoeus::Request.post("#{url}/update", 
    :body => %(<?xml version="1.0" encoding="UTF-8"?>#{payload}), :headers => { "Content-Type" => "text/xml"}
  )
end