class Elastomer::Client::Warmer

DEPRECATED: Warmers have been removed from Elasticsearch as of 5.0. See www.elastic.co/guide/en/elasticsearch/reference/5.0/indices-warmers.html

Attributes

client[R]
index_name[R]
name[R]

Public Class Methods

new(client, index_name, name) click to toggle source

Create a new Warmer helper for making warmer API requests.

client - Elastomer::Client used for HTTP requests to the server index_name - The name of the index as a String name - The name of the warmer as a String

# File lib/elastomer/client/warmer.rb, line 13
def initialize(client, index_name, name)
  unless client.version_support.supports_warmers?
    raise IncompatibleVersionException, "ES #{client.version} does not support warmers"
  end

  @client     = client
  @index_name = @client.assert_param_presence(index_name, "index name")
  @name       = @client.assert_param_presence(name, "warmer name")
end

Public Instance Methods

create(query, params = {}) click to toggle source

Create a warmer. See www.elastic.co/guide/en/elasticsearch/reference/current/indices-warmers.html

query - The query the warmer should run params - Parameters Hash

Examples

warmer.create(:query => {:match_all => {}})

Returns the response body as a Hash

# File lib/elastomer/client/warmer.rb, line 36
def create(query, params = {})
  response = client.put "/{index}{/type}/_warmer/{warmer}", update_params(params, body: query, action: "warmer.create", rest_api: "indices.put_warmer")
  response.body
end
defaults() click to toggle source

Internal: Returns a Hash containing default parameters.

# File lib/elastomer/client/warmer.rb, line 93
def defaults
  {index: index_name, warmer: name}
end
delete(params = {}) click to toggle source

Delete a warmer. See www.elastic.co/guide/en/elasticsearch/reference/current/indices-warmers.html#removing

params - Parameters Hash

Returns the response body as a Hash

# File lib/elastomer/client/warmer.rb, line 47
def delete(params = {})
  response = client.delete "/{index}{/type}/_warmer/{warmer}", update_params(params, action: "warmer.delete", rest_api: "indices.delete_warmer")
  response.body
end
exist?()
Alias for: exists?
exists?() click to toggle source
Check whether a warmer exists. Also aliased as exist?

Since there is no native warmer exists api, this method executes
a get and watches for an IndexWarmerMissingException error.

Returns true if the warmer exists, false if not.

COMPATIBILITY warmer response differs in ES 1.0

ES 1.0: missing warmer returns {} with 200 status
ES 0.90: missing warmer returns IndexWarmerMissingException error
See https://github.com/elasticsearch/elasticsearch/issues/5155
# File lib/elastomer/client/warmer.rb, line 73
def exists?
  response = get
  response != {}
rescue Elastomer::Client::Error => exception
  if exception.message =~ /IndexWarmerMissingException/
    false
  else
    raise exception
  end
end
Also aliased as: exist?
get(params = {}) click to toggle source

Get a warmer. See www.elastic.co/guide/en/elasticsearch/reference/current/indices-warmers.html#warmer-retrieving

params - Parameters Hash

Returns the response body as a Hash

# File lib/elastomer/client/warmer.rb, line 58
def get(params = {})
  response = client.get "/{index}{/type}/_warmer/{warmer}", update_params(params, action: "warmer.get", rest_api: "indices.get_warmer")
  response.body
end
update_params(params, overrides = nil) click to toggle source

Internal:

# File lib/elastomer/client/warmer.rb, line 86
def update_params(params, overrides = nil)
  h = defaults.update params
  h.update overrides unless overrides.nil?
  h
end