module Elasticsearch::Model::ClassMethods
Public Instance Methods
client()
click to toggle source
Get the client common for all models
@example Get the client
Elasticsearch::Model.client => #<Elasticsearch::Client:0x007f96a7d0d000... >
# File lib/elasticsearch/model.rb, line 132 def client @client ||= Elasticsearch::Client.new end
client=(client)
click to toggle source
Set the client for all models
@example Configure (set) the client for all models
Elasticsearch::Model.client = Elasticsearch::Client.new host: 'http://localhost:9200', tracer: true => #<Elasticsearch::Client:0x007f96a6dd0d80... >
@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}
# File lib/elasticsearch/model.rb, line 146 def client=(client) @client = client end
search(query_or_payload, models=[], options={})
click to toggle source
Search across multiple models
By default, all models which include the `Elasticsearch::Model` module are searched
@param query_or_payload [String,Hash,Object] The search request definition
(string, JSON, Hash, or object responding to `to_hash`)
@param models [Array] The Array of Model
objects to search @param options [Hash] Optional parameters to be passed to the Elasticsearch
client
@return [Elasticsearch::Model::Response::Response]
@example Search across specific models
Elasticsearch::Model.search('foo', [Author, Article])
@example Search across all models which include the `Elasticsearch::Model` module
Elasticsearch::Model.search('foo')
# File lib/elasticsearch/model.rb, line 169 def search(query_or_payload, models=[], options={}) models = Multimodel.new(models) request = Searching::SearchRequest.new(models, query_or_payload, options) Response::Response.new(models, request) end
settings()
click to toggle source
Access the module settings
# File lib/elasticsearch/model.rb, line 177 def settings @settings ||= {} end