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.
-
#search(query_or_payload, models = [], options = {}) ⇒ Elasticsearch::Model::Response::Response
Search across multiple models.
-
#settings ⇒ Object
Access the module settings.
Instance Method Details
#client ⇒ Object
Get the client common for all models
135 136 137 |
# File 'lib/elasticsearch/model.rb', line 135 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
149 150 151 |
# File 'lib/elasticsearch/model.rb', line 149 def client=(client) @client = client 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
172 173 174 175 176 |
# File 'lib/elasticsearch/model.rb', line 172 def search(query_or_payload, models=[], ={}) models = Multimodel.new(models) request = Searching::SearchRequest.new(models, query_or_payload, ) Response::Response.new(models, request) end |
#settings ⇒ Object
Access the module settings
180 181 182 |
# File 'lib/elasticsearch/model.rb', line 180 def settings @settings ||= {} end |