Module: CommonIndexer::Base

Extended by:
ActiveSupport::Concern
Defined in:
lib/common_indexer/base.rb

Instance Method Summary collapse

Instance Method Details

#delete_documentObject



18
19
20
21
22
23
24
# File 'lib/common_indexer/base.rb', line 18

def delete_document
  CommonIndexer.client.delete index: CommonIndexer.index_name,
                              id: id,
                              type: '_doc'
rescue Elasticsearch::Transport::Transport::Error => err
  Rails.logger.warn("Common Index delete failure: #{err.message}")
end

#to_common_indexObject

Override to_common_index in the including model and return a hash of common index attributes



14
15
16
# File 'lib/common_indexer/base.rb', line 14

def to_common_index
  raise CommonIndexer::Error, "Index Error: #{self.class.name} does not implement #to_common_index!"
end

#update_common_indexObject



26
27
28
29
30
31
32
33
# File 'lib/common_indexer/base.rb', line 26

def update_common_index
  CommonIndexer.client.index index: CommonIndexer.index_name,
                             id: id,
                             type: '_doc',
                             body: to_common_index
rescue Elasticsearch::Transport::Transport::Error => err
  Rails.logger.warn("Common Indexing failure: #{err.message}")
end