Class: Elastomer::Client::Warmer
- Inherits:
-
Object
- Object
- Elastomer::Client::Warmer
- Defined in:
- lib/elastomer/client/warmer.rb
Overview
DEPRECATED: Warmers have been removed from Elasticsearch as of 5.0. See www.elastic.co/guide/en/elasticsearch/reference/5.0/indices-warmers.html
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#index_name ⇒ Object
readonly
Returns the value of attribute index_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#create(query, params = {}) ⇒ Object
Create a warmer.
-
#defaults ⇒ Object
Internal: Returns a Hash containing default parameters.
-
#delete(params = {}) ⇒ Object
Delete a warmer.
-
#exists? ⇒ Boolean
(also: #exist?)
Check whether a warmer exists.
-
#get(params = {}) ⇒ Object
Get a warmer.
-
#initialize(client, index_name, name) ⇒ Warmer
constructor
Create a new Warmer helper for making warmer API requests.
-
#update_params(params, overrides = nil) ⇒ Object
Internal:.
Constructor Details
#initialize(client, index_name, name) ⇒ Warmer
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
13 14 15 16 17 18 19 20 21 |
# 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 |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
23 24 25 |
# File 'lib/elastomer/client/warmer.rb', line 23 def client @client end |
#index_name ⇒ Object (readonly)
Returns the value of attribute index_name.
23 24 25 |
# File 'lib/elastomer/client/warmer.rb', line 23 def index_name @index_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
23 24 25 |
# File 'lib/elastomer/client/warmer.rb', line 23 def name @name end |
Instance Method Details
#create(query, params = {}) ⇒ Object
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
36 37 38 39 |
# 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 ⇒ Object
Internal: Returns a Hash containing default parameters.
93 94 95 |
# File 'lib/elastomer/client/warmer.rb', line 93 def defaults {index: index_name, warmer: name} end |
#delete(params = {}) ⇒ Object
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
47 48 49 50 |
# 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 |
#exists? ⇒ Boolean Also known as: exist?
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 github.com/elasticsearch/elasticsearch/issues/5155
73 74 75 76 77 78 79 80 81 82 |
# File 'lib/elastomer/client/warmer.rb', line 73 def exists? response = get response != {} rescue Elastomer::Client::Error => exception if exception. =~ /IndexWarmerMissingException/ false else raise exception end end |
#get(params = {}) ⇒ Object
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
58 59 60 61 |
# 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) ⇒ Object
Internal:
86 87 88 89 90 |
# 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 |