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" ... }


34
35
36
# File 'lib/elasticsearch/model/client.rb', line 34

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 ...


45
46
47
# File 'lib/elasticsearch/model/client.rb', line 45

def client=(client)
  @client = client
end