Module: Gummi::Document

Extended by:
ActiveSupport::Concern
Defined in:
lib/gummi/document.rb,
lib/gummi/document/object.rb,
lib/gummi/document/attributes.rb,
lib/gummi/document/search/raw.rb,
lib/gummi/document/search/result.rb,
lib/gummi/document/search/filtered.rb,
lib/gummi/document/search/searching.rb

Defined Under Namespace

Modules: Attributes, ClassMethods, Object, Search

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#idObject

Returns the value of attribute id.



10
11
12
# File 'lib/gummi/document.rb', line 10

def id
  @id
end

#versionObject

Returns the value of attribute version.



11
12
13
# File 'lib/gummi/document.rb', line 11

def version
  @version
end

Instance Method Details

#createObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/gummi/document.rb', line 24

def create
  response = client.create index: index.name, type: document_type, id: id, body: attributes
  if response["ok"]
    self.version = response["_version"]
    self.id = response["_id"]
    true
  else
    false
  end
end

#overwriteObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/gummi/document.rb', line 13

def overwrite
  response = client.index index: index.name, type: document_type, id: id, body: attributes
  if response["ok"]
    self.version = response["_version"]
    self.id = response["_id"]
    true
  else
    false
  end
end

#updateObject



35
36
37
38
39
40
41
42
43
# File 'lib/gummi/document.rb', line 35

def update
  response = client.update index: index.name, type: document_type, id: id, retry_on_conflict: 0, version: version, body: { doc: attributes.as_json }
  if response["ok"]
    self.version = response["_version"]
    true
  else
    false
  end
end