module Elasticsearch::Rails2::ClassMethods

Public Instance Methods

client() click to toggle source

Get the client common for all models

@example Get the client

Elasticsearch::Model.client
=> #<Elasticsearch::Transport::Client:0x007f96a7d0d000 @transport=... >
# File lib/elasticsearch/rails2.rb, line 37
def client
  @client ||= Elasticsearch::Client.new
end
client=(client) click to toggle source

Set the client for all models

@example Configure (set) the client for all models

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

@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}
# File lib/elasticsearch/rails2.rb, line 51
def client=(client)
  @client = client
end
options=(options={}) click to toggle source
# File lib/elasticsearch/rails2.rb, line 55
def options=(options={})
  Configuration::VALID_OPTIONS_KEYS.each do |key|
    send("#{key}=", options[key])
  end
end