Class: TheShoveler::Targets::Solr

Inherits:
TheShoveler::Target show all
Defined in:
lib/theShoveler/targets/solr.rb

Instance Attribute Summary collapse

Attributes inherited from TheShoveler::Target

#connection_info

Instance Method Summary collapse

Constructor Details

#initialize(connection_info) ⇒ Solr

Returns a new instance of Solr.



6
7
8
9
10
# File 'lib/theShoveler/targets/solr.rb', line 6

def initialize(connection_info)
  super(connection_info)
  @starting_id ||= 0
  @solr = RSolr.connect url: connection_info[:url]
end

Instance Attribute Details

#starting_idObject

Returns the value of attribute starting_id.



5
6
7
# File 'lib/theShoveler/targets/solr.rb', line 5

def starting_id
  @starting_id
end

Instance Method Details

#add(document) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/theShoveler/targets/solr.rb', line 12

def add(document)
  super(document)
  unless document.doc_attributes[:id]
    document.doc_attributes[:id] = @starting_id
    @starting_id += 1
  end
  return @solr.add document.doc_attributes
end