module EagleSearch::Model::InstanceMethods

Public Instance Methods

reindex() click to toggle source
# File lib/eagle_search/model.rb, line 40
def reindex
  index = self.class.eagle_search_index
  reindex_option = index.settings[:reindex]

  if reindex_option.nil? || reindex_option
    begin
      index.info
    rescue Elasticsearch::Transport::Transport::Errors::NotFound
      index.create
    ensure
      index.refresh
      EagleSearch.client.index(
        index: index.alias_name,
        type: index.type_name,
        id: id,
        body: index_data
      )
    end
  end
end