class Elasticsearch::Resources::Document

Public Class Methods

new(type:, id:, attributes: {}) click to toggle source
# File lib/elasticsearch/resources/document.rb, line 10
def initialize(type:, id:, attributes: {})
  self.type = type
  self.id = id
  self.attributes = attributes
end

Public Instance Methods

client() click to toggle source
# File lib/elasticsearch/resources/document.rb, line 24
def client
  type.client
end
cluster() click to toggle source
# File lib/elasticsearch/resources/document.rb, line 16
def cluster
  index.cluster
end
create(options = {}) click to toggle source
# File lib/elasticsearch/resources/document.rb, line 38
def create(options = {})
  params = {
    body: attributes
  }.merge(options)

  query(:create, params)
end
find_cluster() click to toggle source
# File lib/elasticsearch/resources/document.rb, line 60
def find_cluster
  self.cluster
end
find_index(index: nil) click to toggle source
# File lib/elasticsearch/resources/document.rb, line 64
def find_index(index: nil)
  self.index
end
find_type(index: nil, type: nil) click to toggle source
# File lib/elasticsearch/resources/document.rb, line 68
def find_type(index: nil, type: nil)
  self.type
end
index() click to toggle source
# File lib/elasticsearch/resources/document.rb, line 20
def index
  type.index
end
query(action, options = {}) click to toggle source
Calls superclass method
# File lib/elasticsearch/resources/document.rb, line 28
def query(action, options = {})
  params = {
    index: index.name,
    type: type.name,
    id: id
  }.merge(options)

  super(action, **params)
end
update(options = {}) click to toggle source
# File lib/elasticsearch/resources/document.rb, line 46
def update(options = {})
  params = {
    body: attributes
  }.merge(options)

  query(:update, params)
end