module Elasticsearch::Model::Client::ClassMethods

Public Instance Methods

client(client=nil) click to toggle source

Get the client for a specific model class

@example Get the client for ‘Article` and perform API request

Article.client.cluster.health
# => { "cluster_name" => "elasticsearch" ... }
# File lib/elasticsearch/model/client.rb, line 17
def client client=nil
  @client ||= Elasticsearch::Model.client
end
client=(client) click to toggle source

Set the client for a specific model class

@example Configure the client for the ‘Article` model

Article.client = Elasticsearch::Client.new host: 'http://api.server:8080'
Article.search ...
# File lib/elasticsearch/model/client.rb, line 28
def client=(client)
  @client = client
end