Module: Escargot::DistributedIndexing

Defined in:
lib/escargot/distributed_indexing.rb

Defined Under Namespace

Classes: DeployNewVersion, IndexDocuments, ReIndexDocuments

Class Method Summary collapse

Class Method Details

.create_index_for_model(model) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/escargot/distributed_indexing.rb', line 10

def DistributedIndexing.create_index_for_model(model)
  load_dependencies

  index_version = model.create_index_version

  model.find_in_batches(:select => model.primary_key) do |batch|
    Escargot.queue_backend.enqueue(IndexDocuments, model.to_s, batch.map(&:id), index_version)
  end

  Escargot.queue_backend.enqueue(DeployNewVersion, model.index_name, index_version)
end

.load_dependenciesObject



6
7
8
# File 'lib/escargot/distributed_indexing.rb', line 6

def DistributedIndexing.load_dependencies
  require 'resque'
end