Module: Elasticsearch::Rails2::ClassMethods

Included in:
Elasticsearch::Rails2
Defined in:
lib/elasticsearch/rails2.rb

Instance Method Summary collapse

Instance Method Details

#clientObject

Get the client common for all models

Examples:

Get the client


Elasticsearch::Model.client
=> #<Elasticsearch::Transport::Client:0x007f96a7d0d000 @transport=... >


37
38
39
# File 'lib/elasticsearch/rails2.rb', line 37

def client
  @client ||= Elasticsearch::Client.new
end

#client=(client) ⇒ Object

Note:

You have to set the client before you call Elasticsearch methods on the model, or set it directly on the model; see Model::Client::ClassMethods#client

Set the client for all models

Examples:

Configure (set) the client for all models


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


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

def client=(client)
  @client = client
end

#options=(options = {}) ⇒ Object



55
56
57
58
59
# File 'lib/elasticsearch/rails2.rb', line 55

def options=(options={})
  Configuration::VALID_OPTIONS_KEYS.each do |key|
    send("#{key}=", options[key])
  end
end