Module: Elasticsearch::Model::ClassMethods
- Included in:
- Elasticsearch::Model
- Defined in:
- lib/elasticsearch/model.rb
Instance Method Summary collapse
-
#client ⇒ Object
Get the client common for all models.
-
#client=(client) ⇒ Object
Set the client for all models.
-
#inheritance_enabled ⇒ Object
Check if inheritance is enabled.
-
#inheritance_enabled=(inheritance_enabled) ⇒ Object
Enable inheritance of index_name and document_type.
-
#search(query_or_payload, models = [], options = {}) ⇒ Elasticsearch::Model::Response::Response
Search across multiple models.
Instance Method Details
#client ⇒ Object
Get the client common for all models
147 148 149 |
# File 'lib/elasticsearch/model.rb', line 147 def client @client ||= Elasticsearch::Client.new end |
#client=(client) ⇒ Object
Note:
You have to set the client before you call Elasticsearch methods on the model, or set it directly on the model; see Elasticsearch::Model::Client::ClassMethods#client
Set the client for all models
161 162 163 |
# File 'lib/elasticsearch/model.rb', line 161 def client=(client) @client = client end |
#inheritance_enabled ⇒ Object
Note:
Inheritance is disabled by default.
Check if inheritance is enabled
194 195 196 |
# File 'lib/elasticsearch/model.rb', line 194 def inheritance_enabled @inheritance_enabled ||= false end |
#inheritance_enabled=(inheritance_enabled) ⇒ Object
Enable inheritance of index_name and document_type
204 205 206 |
# File 'lib/elasticsearch/model.rb', line 204 def inheritance_enabled=(inheritance_enabled) @inheritance_enabled = inheritance_enabled end |
#search(query_or_payload, models = [], options = {}) ⇒ Elasticsearch::Model::Response::Response
Search across multiple models
By default, all models which include the ‘Elasticsearch::Model` module are searched
184 185 186 187 188 |
# File 'lib/elasticsearch/model.rb', line 184 def search(query_or_payload, models=[], ={}) models = Multimodel.new(models) request = Searching::SearchRequest.new(models, query_or_payload, ) Response::Response.new(models, request) end |