module Estella::Helpers::ClassMethods

Public Instance Methods

batch_to_bulk(batch_of_ids) click to toggle source
# File lib/estella/helpers.rb, line 58
def batch_to_bulk(batch_of_ids)
  find(batch_of_ids).map(&:es_transform)
end
bulk_index(batch_of_ids) click to toggle source
# File lib/estella/helpers.rb, line 62
def bulk_index(batch_of_ids)
  create_index! unless index_exists?
  __elasticsearch__.client.bulk index: index_name, type: model_name.element, body: batch_to_bulk(batch_of_ids)
end
create_index!() click to toggle source
# File lib/estella/helpers.rb, line 76
def create_index!
  __elasticsearch__.client.indices.create index: index_name, body: { settings: settings.to_hash, mappings: mappings.to_hash }
end
delete_index!() click to toggle source
# File lib/estella/helpers.rb, line 72
def delete_index!
  __elasticsearch__.client.indices.delete index: index_name
end
es_delete_document(id) click to toggle source
# File lib/estella/helpers.rb, line 95
def es_delete_document(id)
  __elasticsearch__.client.delete type: document_type, id: id, index: index_name
end
index_exists?() click to toggle source

@return true if the index exists

# File lib/estella/helpers.rb, line 68
def index_exists?
  __elasticsearch__.client.indices.exists index: index_name
end
recreate_index!() click to toggle source
# File lib/estella/helpers.rb, line 85
def recreate_index!
  reload_index!
  import
  refresh_index!
end
refresh_index!() click to toggle source
# File lib/estella/helpers.rb, line 91
def refresh_index!
  __elasticsearch__.refresh_index!
end
reload_index!() click to toggle source
# File lib/estella/helpers.rb, line 80
def reload_index!
  delete_index! if index_exists?
  create_index!
end
search_index_name() click to toggle source

default index naming scheme is pluralized model_name

# File lib/estella/helpers.rb, line 54
def search_index_name
  model_name.route_key
end