Class: Supernova::BatchIndexer

Inherits:
Object
  • Object
show all
Defined in:
lib/supernova/batch_indexer.rb

Instance Method Summary collapse

Constructor Details

#initialize(index, batch_size = 1_000) ⇒ BatchIndexer

Returns a new instance of BatchIndexer.



2
3
4
5
6
7
8
9
10
# File 'lib/supernova/batch_indexer.rb', line 2

def initialize(index, batch_size = 1_000)
  @index = index
  @batch_size = batch_size
  @docs = []
  if block_given?
    yield(self)
    finish
  end
end

Instance Method Details

#finishObject



19
20
21
# File 'lib/supernova/batch_indexer.rb', line 19

def finish
  do_index
end

#index_doc(doc) ⇒ Object



12
13
14
15
16
17
# File 'lib/supernova/batch_indexer.rb', line 12

def index_doc(doc)
  @docs << doc
  if should_index?
    do_index
  end
end