Method: Elasticsearch::Model::Indexing::ClassMethods#refresh_index!

Defined in:
lib/elasticsearch/model/indexing.rb

#refresh_index!(options = {}) ⇒ Object

Performs the “refresh” operation for the index (useful e.g. in tests)

Examples:

Refresh the index for the ‘Article` model


Article.__elasticsearch__.refresh_index!

Pass a specific index name


Article.__elasticsearch__.refresh_index! index: 'my-index'

See Also:

[View source]

304
305
306
307
308
309
310
311
312
313
314
315
316
317
# File 'lib/elasticsearch/model/indexing.rb', line 304

def refresh_index!(options={})
  target_index = options.delete(:index) || self.index_name

  begin
    self.client.indices.refresh index: target_index
  rescue Exception => e
    if e.class.to_s =~ /NotFound/ && options[:force]
      client.transport.logger.debug("[!!!] Index does not exist (#{e.class})") if client.transport.logger
      nil
    else
      raise e
    end
  end
end