Module: EagleSearch::Model::InstanceMethods

Defined in:
lib/eagle_search/model.rb

Instance Method Summary collapse

Instance Method Details

#reindexObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# 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