Class: Elasticsearch::Resources::Document
- Inherits:
-
Object
- Object
- Elasticsearch::Resources::Document
- Includes:
- Describable, Identifiable, Queryable, Resource, Typeable
- Defined in:
- lib/elasticsearch/resources/document.rb
Instance Method Summary collapse
- #client ⇒ Object
- #cluster ⇒ Object
- #create(options = {}) ⇒ Object
- #find_cluster ⇒ Object
- #find_index(index: nil) ⇒ Object
- #find_type(index: nil, type: nil) ⇒ Object
- #index ⇒ Object
-
#initialize(type:, id:, attributes: {}) ⇒ Document
constructor
A new instance of Document.
- #query(action, options = {}) ⇒ Object
- #update(options = {}) ⇒ Object
Methods included from Describable
Methods included from Identifiable
Methods included from Typeable
Methods included from Queryable
Methods included from Resource
Constructor Details
#initialize(type:, id:, attributes: {}) ⇒ Document
Returns a new instance of Document.
10 11 12 13 14 |
# File 'lib/elasticsearch/resources/document.rb', line 10 def initialize(type:, id:, attributes: {}) self.type = type self.id = id self.attributes = attributes end |
Instance Method Details
#client ⇒ Object
24 25 26 |
# File 'lib/elasticsearch/resources/document.rb', line 24 def client type.client end |
#cluster ⇒ Object
16 17 18 |
# File 'lib/elasticsearch/resources/document.rb', line 16 def cluster index.cluster end |
#create(options = {}) ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/elasticsearch/resources/document.rb', line 38 def create( = {}) params = { body: attributes }.merge() query(:create, params) end |
#find_cluster ⇒ Object
60 61 62 |
# File 'lib/elasticsearch/resources/document.rb', line 60 def find_cluster self.cluster end |
#find_index(index: nil) ⇒ Object
64 65 66 |
# File 'lib/elasticsearch/resources/document.rb', line 64 def find_index(index: nil) self.index end |
#find_type(index: nil, type: nil) ⇒ Object
68 69 70 |
# File 'lib/elasticsearch/resources/document.rb', line 68 def find_type(index: nil, type: nil) self.type end |
#index ⇒ Object
20 21 22 |
# File 'lib/elasticsearch/resources/document.rb', line 20 def index type.index end |
#query(action, options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/elasticsearch/resources/document.rb', line 28 def query(action, = {}) params = { index: index.name, type: type.name, id: id }.merge() super(action, **params) end |
#update(options = {}) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/elasticsearch/resources/document.rb', line 46 def update( = {}) params = { body: attributes }.merge() query(:update, params) end |