Module: Elasticsearch::Model::Client::ClassMethods

Included in:
Proxy::ClassMethodsProxy
Defined in:
lib/elasticsearch/model/client.rb

Instance Method Summary collapse

Instance Method Details

#client(client = nil) ⇒ Object

Get the client for a specific model class

Examples:

Get the client for ‘Article` and perform API request


Article.client.cluster.health
# => { "cluster_name" => "elasticsearch" ... }


31
32
33
# File 'lib/elasticsearch/model/client.rb', line 31

def client client=nil
  @client ||= Elasticsearch::Model.client
end

#client=(client) ⇒ Object

Set the client for a specific model class

Examples:

Configure the client for the ‘Article` model


Article.client = Elasticsearch::Client.new host: 'http://api.server:8080'
Article.search ...


42
43
44
# File 'lib/elasticsearch/model/client.rb', line 42

def client=(client)
  @client = client
end