Module: Elasticsearch::Model::ClassMethods

Included in:
Elasticsearch::Model
Defined in:
lib/elasticsearch/model.rb

Instance Method Summary collapse

Instance Method Details

#clientObject

Get the client common for all models

Examples:

Get the client


Elasticsearch::Model.client
=> #<Elasticsearch::Transport::Client:0x007f96a7d0d000 @transport=... >


134
135
136
# File 'lib/elasticsearch/model.rb', line 134

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

Examples:

Configure (set) the client for all models


Elasticsearch::Model.client Elasticsearch::Client.new host: 'http://localhost:9200', tracer: true
=> #<Elasticsearch::Transport::Client:0x007f96a6dd0d80 @transport=... >


148
149
150
# File 'lib/elasticsearch/model.rb', line 148

def client=(client)
  @client = client
end