Class: ElasticSearch::PutIndexTemplateRequest

Inherits:
Request
  • Object
show all
Defined in:
lib/jruby-elasticsearch/templaterequest.rb

Overview

class ElasticSearch::GetIndexTemplateRequest

Instance Method Summary collapse

Methods inherited from Request

#on, #use_callback

Constructor Details

#initialize(client, template_name, mapping_json) ⇒ PutIndexTemplateRequest

Returns a new instance of PutIndexTemplateRequest.



82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/jruby-elasticsearch/templaterequest.rb', line 82

def initialize(client, template_name, mapping_json)
  @client = client
  @template_name = template_name
  @mapping_json = mapping_json
  begin
    @prep = org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequestBuilder.new(@client.admin().indices(), @template_name)
  rescue NameError
    puts "Could not create PutIndexTemplateRequestBuilder", NameError.to_s
  end
  super()
  # Assign the template
  @prep.setSource(@mapping_json)
end

Instance Method Details

#execute(&block) ⇒ Object



110
111
112
113
114
# File 'lib/jruby-elasticsearch/templaterequest.rb', line 110

def execute(&block)
  use_callback(&block) if block_given?
  action = @prep.get
  return action
end

#with(&block) ⇒ Object



97
98
99
100
# File 'lib/jruby-elasticsearch/templaterequest.rb', line 97

def with(&block)
  instance_eval(&block)
  return self
end