Module: Escargot::LocalIndexing

Defined in:
lib/escargot/local_indexing.rb

Class Method Summary collapse

Class Method Details

.create_index_for_model(model) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/escargot/local_indexing.rb', line 4

def LocalIndexing.create_index_for_model(model)
  model = model.constantize if model.kind_of?(String)

  index_version = model.create_index_version

  model.find_in_batches do |batch|
    batch.each do |record|
      record.local_index_in_elastic_search(:index => index_version)
    end
  end

  $elastic_search_client.deploy_index_version(model.index_name, index_version)
end