Class: Elasticsearch::Resources::Type
- Inherits:
-
Object
- Object
- Elasticsearch::Resources::Type
- Includes:
- Configurable, Indexable, Nameable, Queryable, Resource
- Defined in:
- lib/elasticsearch/resources/type.rb
Constant Summary collapse
- ACTIONS =
[ :exists?, :create, :update, :delete, :get ].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #client ⇒ Object
- #cluster ⇒ Object
- #count(body, options = {}) ⇒ Object
- #document_class ⇒ Object
- #find_cluster ⇒ Object
- #find_index(index: nil) ⇒ Object
- #find_type(index: nil, type:) ⇒ Object
-
#initialize(index:, &block) ⇒ Type
constructor
A new instance of Type.
- #name ⇒ Object
- #query(action, options = {}) ⇒ Object
- #search(body, options = {}) ⇒ Object
Methods included from Nameable
Methods included from Indexable
Methods included from Configurable
Methods included from Queryable
Methods included from Resource
Constructor Details
#initialize(index:, &block) ⇒ Type
Returns a new instance of Type.
20 21 22 23 |
# File 'lib/elasticsearch/resources/type.rb', line 20 def initialize(index:, &block) self.index = index configure(&block) end |
Class Method Details
.document_class ⇒ Object
84 85 86 |
# File 'lib/elasticsearch/resources/type.rb', line 84 def self.document_class Object.const_get(@document_class) if @document_class end |
Instance Method Details
#client ⇒ Object
29 30 31 |
# File 'lib/elasticsearch/resources/type.rb', line 29 def client index.client end |
#cluster ⇒ Object
25 26 27 |
# File 'lib/elasticsearch/resources/type.rb', line 25 def cluster index.cluster end |
#count(body, options = {}) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/elasticsearch/resources/type.rb', line 54 def count(body, = {}) params = { body: body }.merge() query(:count, params) end |
#document_class ⇒ Object
80 81 82 |
# File 'lib/elasticsearch/resources/type.rb', line 80 def document_class self.class.document_class end |
#find_cluster ⇒ Object
68 69 70 |
# File 'lib/elasticsearch/resources/type.rb', line 68 def find_cluster self.cluster end |
#find_index(index: nil) ⇒ Object
72 73 74 |
# File 'lib/elasticsearch/resources/type.rb', line 72 def find_index(index: nil) self.index end |
#find_type(index: nil, type:) ⇒ Object
76 77 78 |
# File 'lib/elasticsearch/resources/type.rb', line 76 def find_type(index: nil, type:) matches_name?(type) ? self : nil end |
#name ⇒ Object
33 34 35 |
# File 'lib/elasticsearch/resources/type.rb', line 33 def name settings.name end |
#query(action, options = {}) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/elasticsearch/resources/type.rb', line 37 def query(action, = {}) params = { index: index.name, type: name }.merge() super(action, **params) end |
#search(body, options = {}) ⇒ Object
46 47 48 49 50 51 52 |
# File 'lib/elasticsearch/resources/type.rb', line 46 def search(body, = {}) params = { body: body }.merge() query(:search, params) end |