Module: Elasticsearch::Rails2::Client::InstanceMethods

Defined in:
lib/elasticsearch/rails2/client.rb

Instance Method Summary collapse

Instance Method Details

#clientObject

Get or set the client for a specific model instance

Examples:

Get the client for a specific record and perform API request


@building = Building.first
@building.client.info
# => { "name" => "Node-1", ... }


41
42
43
# File 'lib/elasticsearch/rails2/client.rb', line 41

def client
  @client ||= self.class.client
end

#client=(client) ⇒ Object

Set the client for a specific model instance

Examples:

Set the client for a specific record


@building = Building.first
@building.client = Elasticsearch::Client.new host: 'http://api.server:8080'


52
53
54
# File 'lib/elasticsearch/rails2/client.rb', line 52

def client=(client)
  @client = client
end