class Elasticsearch::Extensions::Documents::Index

Attributes

adapter[R]

Public Class Methods

new(adapter = nil) click to toggle source
# File lib/elasticsearch/extensions/documents/index.rb, line 9
def initialize(adapter = nil)
  @adapter = adapter || Documents.index_adapter
end

Public Instance Methods

bulk_index(documents) click to toggle source
# File lib/elasticsearch/extensions/documents/index.rb, line 45
def bulk_index(documents)
  adapter.bulk_index(documents)
end
delete(document) click to toggle source
# File lib/elasticsearch/extensions/documents/index.rb, line 22
def delete(document)
  payload = {
    type:   document.class.type,
    id:     document.id,
  }
  adapter.delete payload
rescue Elasticsearch::Transport::Transport::Errors::NotFound => not_found
  Documents.logger.info "[Documents] Attempted to delete missing document: #{not_found}"
end
index(document) click to toggle source
# File lib/elasticsearch/extensions/documents/index.rb, line 13
def index(document)
  payload = {
    type:   document.class.type,
    id:     document.id,
    body:   document.as_hash,
  }
  adapter.index payload
end
refresh() click to toggle source
# File lib/elasticsearch/extensions/documents/index.rb, line 37
def refresh
  adapter.refresh
end
reindex(options = {}, &block) click to toggle source
# File lib/elasticsearch/extensions/documents/index.rb, line 41
def reindex(options = {}, &block)
  adapter.reindex(options, &block)
end