eson-core 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. data/Rakefile +2 -2
  2. data/eson-core.gemspec +2 -1
  3. data/lib/eson-core.rb +5 -0
  4. data/lib/eson/api.rb +61 -12
  5. data/lib/eson/chainable.rb +3 -3
  6. data/lib/eson/client.rb +699 -180
  7. data/lib/eson/error.rb +10 -2
  8. data/lib/eson/request.rb +57 -16
  9. data/lib/eson/shared/cluster/health.rb +9 -2
  10. data/lib/eson/shared/cluster/nodes.rb +9 -1
  11. data/lib/eson/shared/cluster/shutdown.rb +9 -1
  12. data/lib/eson/shared/cluster/state.rb +9 -1
  13. data/lib/eson/shared/cluster/stats.rb +9 -1
  14. data/lib/eson/shared/core/bulk.rb +9 -1
  15. data/lib/eson/shared/core/count.rb +10 -1
  16. data/lib/eson/shared/core/delete.rb +10 -1
  17. data/lib/eson/shared/core/delete_by_query.rb +10 -1
  18. data/lib/eson/shared/core/explain.rb +44 -0
  19. data/lib/eson/shared/core/get.rb +9 -1
  20. data/lib/eson/shared/core/index.rb +13 -2
  21. data/lib/eson/shared/core/mget.rb +12 -3
  22. data/lib/eson/shared/core/more_like_this.rb +10 -1
  23. data/lib/eson/shared/core/msearch.rb +10 -1
  24. data/lib/eson/shared/core/percolate.rb +10 -1
  25. data/lib/eson/shared/core/scroll.rb +17 -0
  26. data/lib/eson/shared/core/search.rb +15 -3
  27. data/lib/eson/shared/core/simple_search.rb +9 -1
  28. data/lib/eson/shared/core/update.rb +33 -0
  29. data/lib/eson/shared/core/validate.rb +50 -0
  30. data/lib/eson/shared/indices/aliases.rb +37 -9
  31. data/lib/eson/shared/indices/analyze.rb +9 -2
  32. data/lib/eson/shared/indices/clear_cache.rb +9 -1
  33. data/lib/eson/shared/indices/close_index.rb +8 -1
  34. data/lib/eson/shared/indices/create_index.rb +10 -1
  35. data/lib/eson/shared/indices/delete_index.rb +8 -1
  36. data/lib/eson/shared/indices/delete_mapping.rb +9 -1
  37. data/lib/eson/shared/indices/delete_template.rb +8 -1
  38. data/lib/eson/shared/indices/exists.rb +8 -1
  39. data/lib/eson/shared/indices/flush.rb +9 -1
  40. data/lib/eson/shared/indices/get_aliases.rb +16 -0
  41. data/lib/eson/shared/indices/get_mapping.rb +9 -1
  42. data/lib/eson/shared/indices/get_settings.rb +8 -1
  43. data/lib/eson/shared/indices/get_template.rb +8 -1
  44. data/lib/eson/shared/indices/open_index.rb +8 -1
  45. data/lib/eson/shared/indices/optimize.rb +9 -1
  46. data/lib/eson/shared/indices/put_mapping.rb +10 -1
  47. data/lib/eson/shared/indices/put_template.rb +9 -1
  48. data/lib/eson/shared/indices/refresh.rb +9 -1
  49. data/lib/eson/shared/indices/segments.rb +8 -1
  50. data/lib/eson/shared/indices/snapshot.rb +8 -1
  51. data/lib/eson/shared/indices/stats.rb +9 -1
  52. data/lib/eson/shared/indices/status.rb +8 -1
  53. data/lib/eson/shared/indices/update_settings.rb +10 -1
  54. metadata +7 -8
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'rake/testtask'
2
- require 'rake/gempackagetask'
2
+ require 'rubygems/package_task'
3
3
  require 'rake/testtask'
4
4
 
5
5
  def gemspec
@@ -14,7 +14,7 @@ task :gemspec do
14
14
  gemspec.validate
15
15
  end
16
16
 
17
- Rake::GemPackageTask.new(gemspec) do |pkg|
17
+ Gem::PackageTask.new(gemspec) do |pkg|
18
18
  pkg.gem_spec = gemspec
19
19
  end
20
20
 
@@ -3,7 +3,8 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "eson-core"
6
- s.version = "0.7.0" #Echolon::VERSION
6
+ s.version = "0.8.0"
7
+
7
8
  s.platform = Gem::Platform::RUBY
8
9
  s.authors = ["Florian Gilcher"]
9
10
  s.email = ["florian.gilcher@asquera.de"]
@@ -14,9 +14,13 @@ require 'eson/shared/core/bulk'
14
14
  require 'eson/shared/core/percolate'
15
15
  require 'eson/shared/core/simple_search'
16
16
  require 'eson/shared/core/more_like_this'
17
+ require 'eson/shared/core/update'
17
18
  require 'eson/shared/core/msearch'
18
19
  require 'eson/shared/core/mget'
19
20
  require 'eson/shared/core/delete_by_query'
21
+ require 'eson/shared/core/scroll'
22
+ require 'eson/shared/core/validate'
23
+ require 'eson/shared/core/explain'
20
24
 
21
25
  require 'eson/shared/cluster/health'
22
26
  require 'eson/shared/cluster/state'
@@ -25,6 +29,7 @@ require 'eson/shared/cluster/stats'
25
29
  require 'eson/shared/cluster/shutdown'
26
30
 
27
31
  require 'eson/shared/indices/aliases'
32
+ require 'eson/shared/indices/get_aliases'
28
33
  require 'eson/shared/indices/analyze'
29
34
  require 'eson/shared/indices/clear_cache'
30
35
  require 'eson/shared/indices/close_index'
@@ -1,7 +1,18 @@
1
1
  module Eson
2
+ # Objects including API act as API descriptions. They mostly act as a
3
+ # description of parameter names and roles to use in protocol implementations.
4
+ # Parameters are split in 2 sets: all parameters (params) and parameters
5
+ # that are transmitted in the body of a request (if the protocol has a
6
+ # notion of "body"). These descriptions are intended to be refined by
7
+ # protocol implementations.
8
+ #
9
+ # For examples of this strategy, see {Eson::Shared::Index} and
10
+ # {Eson::HTTP::Index}.
2
11
  module API
3
12
  include Chainable
4
-
13
+
14
+ # Designates the names of all parameters supported by this request, including
15
+ # those used in the source later on.
5
16
  def parameters(*params)
6
17
  chainable do
7
18
  define_method :parameters do
@@ -13,21 +24,25 @@ module Eson
13
24
  end
14
25
  end
15
26
  end
16
-
27
+
17
28
  # Designates the name of the parameter that will be used as the
18
29
  # body of the request. Use only if the API has such a parameter (e.g. Search).
19
- # You still have to list this parameter.
20
- #
30
+ # You still have to list the parameter.
31
+ #
21
32
  # If multiple parameters are given, they will act as the keys in the sent
22
33
  # JSON object.
23
34
  #
35
+ # If the transport has no concept of a "source", this should be ignored.
36
+ #
24
37
  # @example source_param call
38
+ # parameters :settings, :mappings
25
39
  # source_param :settings, :mappings
26
40
  # @example result
27
41
  # {
28
42
  # "settings" : {...},
29
43
  # "mappings" : {...}
30
44
  # }
45
+ #
31
46
  def source_param(*params)
32
47
  if params.length == 1
33
48
  params = params.first
@@ -37,27 +52,61 @@ module Eson
37
52
  params
38
53
  end
39
54
  end
40
-
55
+
56
+ # Indicates whether the api accepts multiple indices like `["index1", "index2"]
41
57
  def multi_index(bool)
42
58
  define_method :multi_index do
43
59
  bool
44
60
  end
45
61
  end
46
-
62
+
63
+ # Indicates whether the api accepts multiple types like `["type1", "type2"]
47
64
  def multi_types(bool)
48
65
  define_method :multi_types do
49
66
  bool
50
67
  end
51
68
  end
52
-
69
+
70
+ # Indicates whether the api does not operate on an index at all.
53
71
  def no_indices(bool)
54
72
  define_method :no_indices do
55
73
  bool
56
74
  end
57
75
  end
58
-
59
- def register(mod)
60
- include(mod)
61
- end
62
76
  end
63
- end
77
+ end
78
+
79
+ # @!macro parameters
80
+ # The request supports the following parameters: ${1--1}
81
+ #
82
+ # @method parameters
83
+ # @return [Array<String>] The parameters
84
+
85
+ # @!macro source_param
86
+ # The request declares the following parameters as source parameters: ${1--1}
87
+ #
88
+ # @method source_param
89
+ # @return [Array<String>] The source parameters
90
+
91
+ # @!macro multi_index
92
+ # The request can operate on multiple indices.
93
+ #
94
+ # @method multi_index
95
+ # @return [true]
96
+
97
+ # @!macro no_multi_index
98
+ # The request does not operate on multiple indices.
99
+ #
100
+ # @method multi_index
101
+ # @return [false]
102
+
103
+ # @!macro multi_types
104
+ # The request can operate on multiple types.
105
+ #
106
+ # @method multi_types
107
+ # @return [true]
108
+
109
+ # @!macro no_multi_types
110
+ # The request cannot operate on multiple types.
111
+ # @method multi_types
112
+ # @return [false]
@@ -1,16 +1,16 @@
1
1
  # code from the datamapper project. See http://datamapper.org
2
2
 
3
3
  module Eson
4
+ # @api internal
4
5
  module Chainable
5
-
6
- # @api private
6
+ # @api internal
7
7
  def chainable(&block)
8
8
  mod = Module.new(&block)
9
9
  include mod
10
10
  mod
11
11
  end
12
12
 
13
- # @api private
13
+ # @api internal
14
14
  def extendable(&block)
15
15
  mod = Module.new(&block)
16
16
  extend mod
@@ -1,100 +1,288 @@
1
+ # @!macro request
2
+ # Creates a $0 request.
3
+ # @api requests
4
+
5
+ # @!macro immediate
6
+ # @overload
7
+ # With a block given, this will return a result.
8
+ # @return [Object] result
9
+ # @overload
10
+ # Without immediate, this will method returns an request object.
11
+ # @return [Eson::API] the request
12
+ # @param [true,false] immediate Whether to immediately call the request or not.
13
+
1
14
  module Eson
15
+ # Eson::Client is a protocol-agnostic client to elasticsearch. For an example
16
+ # of a protocol implementation, see {Eson::HTTP}. The client primarily
17
+ # constructs {Eson::Request} objects. In default mode, it also calls the
18
+ # backend immediately. This behaviour can be controlled using the parameter
19
+ # `auto_call`.
20
+ #
21
+ # The client (like most parts of Eson) holds no state and can be reused. All
22
+ # operations that change parameters return a new Client object.
23
+ #
24
+ # By default, the client returns the backend response as a raw
25
+ # backend response, unless a set of plugins is specified.
26
+ #
27
+ # It is recommendable to use protocol-specific subclasses like
28
+ # {Eson::HTTP::Client} because they set sane defaults for the plugin-set and
29
+ # return better consumable data.
30
+ #
31
+ # @example Constructing an HTTP client
32
+ # c = Eson::Client.new(:server => "http://127.0.0.1:9200",
33
+ # :protocol => Eson::HTTP,
34
+ # :plugins => [Eson::ResponseParser],
35
+ # :logger => 'test/test.log')
36
+ #
37
+ #
2
38
  class Client
3
39
  attr_accessor :server
4
40
  attr_accessor :index_name
5
- attr_accessor :default_index
41
+ attr_accessor :default_parameters
6
42
  attr_accessor :protocol
7
43
  attr_accessor :plugins
8
44
  attr_accessor :opts
9
45
  attr_accessor :auto_call
10
-
46
+ attr_accessor :logger
47
+
48
+ alias :node :server
49
+
50
+ # Default settings
11
51
  DEFAULT_OPTS = {
12
52
  :server => 'http://127.0.0.1:9200',
13
53
  :plugins => [],
14
54
  :logger => nil,
15
- :default_index => "default"
55
+ :default_parameters => { :index => "default" }
16
56
  }
17
-
18
- # TODO: allow multiple servers and pick them at random
57
+
58
+ # Create a new client. The client object is protocol-independent, but uses
59
+ # Eson::HTTP by default.
60
+ #
61
+ # @param [Hash] opts the options to create the client with.
62
+ # @option opts [String] :server ('http://127.0.0.1:9200') The base url of the server to connect to.
63
+ # @option opts [Module] :protocol (Eson::HTTP) The module providing the protocol implementation.
64
+ # @option opts [Array<Module>] :plugins ([]) An array of plugin modules
65
+ # @option opts [String, #<<] :logger (nil) A logger object or a String pointing to a log file.
66
+ # @option opts [true,false] :auto_call (true) Whether to immeditately run the request or return the
67
+ # request object instead.
68
+ # @option opts [Hash] :auth (nil) Authentication information depending on protocol
19
69
  def initialize(opts = {})
20
70
  opts = DEFAULT_OPTS.merge(opts)
21
-
22
- self.server = opts[:server]
23
- self.default_index = opts[:default_index]
24
- self.protocol = opts[:protocol] || Eson::HTTP
25
- self.plugins = opts[:plugins]
26
- self.logger = opts[:logger]
27
- if opts[:auto_call].nil?
71
+ self.opts = opts
72
+ opts = opts.clone
73
+
74
+ self.server = opts.delete(:server)
75
+ default_index = opts.delete(:default_index)
76
+ self.protocol = opts.delete(:protocol) || Eson::HTTP
77
+ self.plugins = opts.delete(:plugins)
78
+ self.logger = opts.delete(:logger)
79
+ self.auto_call = opts.delete(:auto_call)
80
+
81
+ self.default_parameters = opts.delete(:default_parameters) || {}
82
+
83
+ if default_index
84
+ default_parameters[:index] ||= default_index
85
+ end
86
+
87
+ if self.auto_call.nil?
28
88
  self.auto_call = true
29
- else
30
- self.auto_call = opts[:auto_call]
31
89
  end
32
- self.opts = opts
33
90
  end
34
91
 
35
- def node
36
- self.server
37
- end
38
-
39
- def logger=(logger)
40
- protocol.logger = logger
41
- end
42
-
43
- def logger(logger)
44
- protocol.logger
92
+ # @deprecated
93
+ def default_index=(index_name)
94
+ default_index[:index] = index_name
95
+ end
96
+
97
+ # Returns a clone of this client with new {#default_parameters}. The
98
+ # old parameters are merged with the new ones.
99
+ #
100
+ # @param [Hash] params The new parameters
101
+ #
102
+ # @return [Eson::Client] a clone of the client with the new parameters set.
103
+ def with(params = {})
104
+ client = self.clone
105
+ client.default_parameters = default_parameters.merge(params)
106
+
107
+ if block_given?
108
+ yield client
109
+ else
110
+ client
111
+ end
45
112
  end
46
-
113
+
114
+ # Check whether the client has auth options set at all.
115
+ #
116
+ # @return [true,false] Whether auth parameters are set.
117
+ # @api internal
47
118
  def auth?
48
119
  !!opts[:auth]
49
120
  end
50
-
121
+
122
+ # Returns the auth parameters
123
+ #
124
+ # @api interal
125
+ # @return [Hash] The auth parameters
51
126
  def auth
52
127
  opts[:auth]
53
128
  end
54
-
55
- def index_name
56
- @index_name || default_index
57
- end
58
-
59
- def [](index_name)
60
- c = self.clone
61
- c.index_name = index_name
62
- c
129
+
130
+ # Set the logger.
131
+ #
132
+ # @overload
133
+ # @param [Logger, #<<] The logger object
134
+ # @overload
135
+ # @param [String] A filepath to log to
136
+ def logger=(logger)
137
+ if String === logger
138
+ require 'logger'
139
+ @logger = Logger.new(logger)
140
+ else
141
+ @logger = logger
142
+ end
63
143
  end
64
-
144
+
145
+ # @!group Requests
146
+
147
+ # @!macro request
148
+ # @!macro immediate
149
+ #
150
+ # {include:Index#parameters}
151
+ # {include:Index#source_param}
152
+ # {include:Index#multi_index}
153
+ # {include:Index#multi_types}
154
+ #
155
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Index}.
65
156
  def index(args = {}, immediate = auto_call)
66
157
  request(protocol::Index, args, immediate)
67
158
  end
68
159
 
160
+ # @!macro request
161
+ # @!macro immediate
162
+ #
163
+ # {include:Delete#parameters}
164
+ # {include:Delete#source_param}
165
+ # {include:Delete#multi_index}
166
+ # {include:Delete#multi_types}
167
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Delete}.
69
168
  def delete(args = {}, immediate = auto_call)
70
169
  request(protocol::Delete, args, immediate)
71
170
  end
72
-
73
- def get(args = {})
74
- request(protocol::Get, args)
75
- end
76
-
77
- def mget(args = {})
78
- request(protocol::MultiGet, args)
79
- end
80
-
171
+
172
+ # @!macro request
173
+ # @!macro immediate
174
+ #
175
+ # {include:Get#parameters}
176
+ # {include:Get#source_param}
177
+ # {include:Get#multi_index}
178
+ # {include:Get#multi_types}
179
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Get}.
180
+ def get(args = {}, immediate = auto_call)
181
+ request(protocol::Get, args, immediate)
182
+ end
183
+
184
+ # @!macro request
185
+ # @!macro immediate
186
+ #
187
+ # {include:MGet#parameters}
188
+ # {include:MGet#source_param}
189
+ # {include:MGet#multi_index}
190
+ # {include:MGet#multi_types}
191
+ # @param [Hash] args The arguments, as given in {Eson::Shared::MGet}.
192
+ def mget(args = {}, immediate = auto_call)
193
+ request(protocol::MultiGet, args, immediate)
194
+ end
195
+
196
+ # @!macro request
197
+ # @!macro immediate
198
+ #
199
+ # {include:Search#parameters}
200
+ # {include:Search#source_param}
201
+ # {include:Search#multi_index}
202
+ # {include:Search#multi_types}
203
+ #
204
+ # @yield If eson-dsl is used, the given block will be used as DSL defintion.
205
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Search}.
81
206
  def search(args = {}, immediate = auto_call, &block)
82
207
  request(protocol::Search, args, immediate, &block)
83
208
  end
84
209
  alias :query :search
85
-
86
- def simple_search(args = {})
87
- request(protocol::SimpleSearch, args)
88
- end
89
-
90
- def count(args = {})
91
- request(protocol::Count, args)
92
- end
93
-
94
- def percolate(args = {}, &block)
95
- request(protocol::Percolate, args, &block)
96
- end
97
-
210
+
211
+ # @!macro request
212
+ # @!macro immediate
213
+ #
214
+ # {include:Scroll#parameters}
215
+ # {include:Scroll#source_param}
216
+ # {include:Scroll#multi_index}
217
+ # {include:Scroll#multi_types}
218
+ #
219
+ # @yield If eson-dsl is used, the given block will be used as DSL defintion.
220
+ def scroll(args = {}, immediate = auto_call, &block)
221
+ request(protocol::Scroll, args, immediate, &block)
222
+ end
223
+
224
+ # @!macro request
225
+ # @!macro immediate
226
+ #
227
+ # {include:SimpleSearch#parameters}
228
+ # {include:SimpleSearch#source_param}
229
+ # {include:SimpleSearch#multi_index}
230
+ # {include:SimpleSearch#multi_types}
231
+ #
232
+ # @param [Hash] args The arguments, as given in {Eson::Shared::SimpleSearch}.
233
+ def simple_search(args = {}, immediate = auto_call)
234
+ request(protocol::SimpleSearch, args, immediate)
235
+ end
236
+
237
+ # @!macro request
238
+ # @!macro immediate
239
+ #
240
+ # {include:Count#parameters}
241
+ # {include:Count#source_param}
242
+ # {include:Count#multi_index}
243
+ # {include:Count#multi_types}
244
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Count}.
245
+ def count(args = {}, immediate = auto_call)
246
+ request(protocol::Count, args, immediate)
247
+ end
248
+
249
+ # @!macro request
250
+ # @!macro immediate
251
+ #
252
+ # {include:Update#parameters}
253
+ # {include:Update#source_param}
254
+ # {include:Update#multi_index}
255
+ # {include:Update#multi_types}
256
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Update}.
257
+ def update(args = {}, immediate = auto_call)
258
+ request(protocol::Update, args, immediate)
259
+ end
260
+
261
+ # @!macro request
262
+ # @!macro immediate
263
+ #
264
+ # {include:Percolate#parameters}
265
+ # {include:Percolate#source_param}
266
+ # {include:Percolate#multi_index}
267
+ # {include:Percolate#multi_types}
268
+ #
269
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Percolate}.
270
+ def percolate(args = {}, immediate = auto_call, &block)
271
+ request(protocol::Percolate, args, immediate, &block)
272
+ end
273
+
274
+ # @!macro request
275
+ #
276
+ # {include:Bulk#parameters}
277
+ # {include:Bulk#source_param}
278
+ # {include:Bulk#multi_index}
279
+ # {include:Bulk#multi_types}
280
+ #
281
+ # If this method is called with a block, the request is immediately called.
282
+ # With no block given, the request will be returned.
283
+ #
284
+ # @yield The block is evaluated to create the subrequests.
285
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Bulk}.
98
286
  def bulk(args = {}, &block)
99
287
  if block_given?
100
288
  request(protocol::Bulk, args, &block)
@@ -102,7 +290,19 @@ module Eson
102
290
  request(protocol::Bulk, args, false)
103
291
  end
104
292
  end
105
-
293
+
294
+ # @!macro request
295
+ #
296
+ # {include:MultiSearch#parameters}
297
+ # {include:MultiSearch#source_param}
298
+ # {include:MultiSearch#multi_index}
299
+ # {include:MultiSearch#multi_types}
300
+ #
301
+ # If this method is called with a block, the request is immediately called.
302
+ # With no block given, the request will be returned.
303
+ #
304
+ # @yield The block is evaluated to create the subrequests.
305
+ # @param [Hash] args The arguments, as given in {Eson::Shared::MultiSearch}.
106
306
  def msearch(args = {}, &block)
107
307
  if block_given?
108
308
  request(protocol::MultiSearch, args, &block)
@@ -110,134 +310,453 @@ module Eson
110
310
  request(protocol::MultiSearch, args, false)
111
311
  end
112
312
  end
113
-
114
- def delete_by_query(args = {}, &block)
115
- request(protocol::DeleteByQuery, args, &block)
116
- end
117
-
118
- def more_like_this(args = {})
119
- request(protocol::MoreLikeThis, args)
120
- end
121
-
122
- def health(args = {})
123
- request(protocol::Health, args)
124
- end
125
-
126
- def state(args = {})
127
- request(protocol::State, args)
128
- end
129
-
130
- def stats(args = {})
131
- request(protocol::Stats, args)
132
- end
133
-
134
- def nodes(args = {})
135
- request(protocol::Nodes, args)
136
- end
137
-
138
- def shutdown(args = {})
139
- request(protocol::Shutdown, args)
140
- end
141
-
142
- def aliases(args = {}, &block)
143
- request(protocol::Aliases, args, &block)
144
- end
145
-
146
- def analyze(args = {})
147
- request(protocol::Analyze, args)
148
- end
149
-
150
- def clear_cache(args = {})
151
- request(protocol::ClearCache, args)
152
- end
153
-
154
- def close_index(args = {})
155
- request(protocol::CloseIndex, args)
156
- end
157
-
158
- def open_index(args = {})
159
- request(protocol::OpenIndex, args)
160
- end
161
-
162
- def create_index(args = {})
163
- request(protocol::CreateIndex, args)
164
- end
165
-
166
- def delete_index(args = {})
167
- request(protocol::DeleteIndex, args)
168
- end
169
-
170
- def delete_mapping(args = {})
171
- request(protocol::DeleteMapping, args)
172
- end
173
-
174
- def get_mapping(args = {})
175
- request(protocol::GetMapping, args)
176
- end
177
-
178
- def put_mapping(args = {})
179
- request(protocol::PutMapping, args)
180
- end
181
-
182
- def put_template(args = {})
183
- request(protocol::PutTemplate, args)
184
- end
185
-
186
- def get_template(args = {})
187
- request(protocol::GetTemplate, args)
188
- end
189
-
190
- def delete_template(args = {})
191
- request(protocol::DeleteTemplate, args)
192
- end
193
-
194
- def get_settings(args = {})
195
- request(protocol::GetSettings, args)
196
- end
197
-
198
- def update_settings(args = {})
199
- request(protocol::UpdateSettings, args)
200
- end
201
-
202
- def flush(args = {})
203
- request(protocol::Flush, args)
204
- end
205
-
206
- def optimize(args = {})
207
- request(protocol::Optimize, args)
208
- end
209
-
210
- def refresh(args = {})
211
- request(protocol::Refresh, args)
212
- end
213
-
214
- def snapshot(args = {})
215
- request(protocol::Snapshot, args)
216
- end
217
-
218
- def status(args = {})
219
- request(protocol::Status, args)
220
- end
221
-
222
- def index_stats(args = {})
223
- request(protocol::IndexStats, args)
224
- end
225
-
226
- def segments(args = {})
227
- request(protocol::Segments, args)
228
- end
229
-
230
- def exists?(args = {})
313
+
314
+ # @!macro request
315
+ # @!macro immediate
316
+ #
317
+ # {include:DeleteByQuery#parameters}
318
+ # {include:DeleteByQuery#source_param}
319
+ # {include:DeleteByQuery#multi_index}
320
+ # {include:DeleteByQuery#multi_types}
321
+ #
322
+ # @yield If eson-dsl is used, the given block will be used as DSL defintion.
323
+ # # @param [Hash] args The arguments, as given in {Eson::Shared::DeleteByQuery}.
324
+ def delete_by_query(args = {}, immediate = auto_call, &block)
325
+ request(protocol::DeleteByQuery, args, immediate, &block)
326
+ end
327
+
328
+ # @!macro request
329
+ # @!macro immediate
330
+ #
331
+ # {include:MoreLikeThis#parameters}
332
+ # {include:MoreLikeThis#source_param}
333
+ # {include:MoreLikeThis#multi_index}
334
+ # {include:MoreLikeThis#multi_types}
335
+ #
336
+ # @yield If eson-dsl is used, the given block will be used as DSL defintion.
337
+ # # @param [Hash] args The arguments, as given in {Eson::Shared::MoreLikeThis}.
338
+ def more_like_this(args = {}, immediate = auto_call)
339
+ request(protocol::MoreLikeThis, args, immediate)
340
+ end
341
+
342
+ # @!macro request
343
+ # @!macro immediate
344
+ #
345
+ # {include:Health#parameters}
346
+ # {include:Health#source_param}
347
+ # {include:Health#multi_index}
348
+ # {include:Health#multi_types}
349
+ #
350
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Health}.
351
+ def health(args = {}, immediate = auto_call)
352
+ request(protocol::Health, args, immediate)
353
+ end
354
+
355
+ # @!macro request
356
+ # @!macro immediate
357
+ #
358
+ # {include:State#parameters}
359
+ # {include:State#source_param}
360
+ # {include:State#multi_index}
361
+ # {include:State#multi_types}
362
+ #
363
+ # @param [Hash] args The arguments, as given in {Eson::Shared::State}.
364
+ def state(args = {}, immediate = auto_call)
365
+ request(protocol::State, args, immediate)
366
+ end
367
+
368
+ # @!macro request
369
+ # @!macro immediate
370
+ #
371
+ # {include:Stats#parameters}
372
+ # {include:Stats#source_param}
373
+ # {include:Stats#multi_index}
374
+ # {include:Stats#multi_types}
375
+ #
376
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Stats}.
377
+ def stats(args = {}, immediate = auto_call)
378
+ request(protocol::Stats, args, immediate)
379
+ end
380
+
381
+ # @!macro request
382
+ # @!macro immediate
383
+ #
384
+ # {include:Nodes#parameters}
385
+ # {include:Nodes#source_param}
386
+ # {include:Nodes#multi_index}
387
+ # {include:Nodes#multi_types}
388
+ #
389
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Nodes}.
390
+ def nodes(args = {}, immediate = auto_call)
391
+ request(protocol::Nodes, args, immediate)
392
+ end
393
+
394
+ # @!macro request
395
+ # @!macro immediate
396
+ #
397
+ # {include:Shutdown#parameters}
398
+ # {include:Shutdown#source_param}
399
+ # {include:Shutdown#multi_index}
400
+ # {include:Shutdown#multi_types}
401
+ #
402
+ # Please be aware that external node shutdown does not seem to be
403
+ # supported by ElasticSearch at the moment.
404
+ #
405
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Shutdown}.
406
+ def shutdown(args = {}, immediate = auto_call)
407
+ request(protocol::Shutdown, args, immediate)
408
+ end
409
+
410
+ # @!macro request
411
+ # @!macro immediate
412
+ #
413
+ # {include:Aliases#parameters}
414
+ # {include:Aliases#source_param}
415
+ # {include:Aliases#multi_index}
416
+ # {include:Aliases#multi_types}
417
+ #
418
+ # @yield The block is evaluated in the context of the request
419
+ # to define the aliases
420
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Aliases}.
421
+ def aliases(args = {}, immediate = auto_call, &block)
422
+ request(protocol::Aliases, args, immediate, &block)
423
+ end
424
+
425
+ # @!macro request
426
+ # @!macro immediate
427
+ #
428
+ # {include:GetAliases#parameters}
429
+ # {include:GetAliases#source_param}
430
+ # {include:GetAliases#multi_index}
431
+ # {include:GetAliases#multi_types}
432
+ #
433
+ # @param [Hash] args The arguments, as given in {Eson::Shared::GetAliases}.
434
+ def get_aliases(args = {}, immediate = auto_call, &block)
435
+ request(protocol::GetAliases, args, immediate, &block)
436
+ end
437
+
438
+ # @!macro request
439
+ # @!macro immediate
440
+ #
441
+ # {include:Analyze#parameters}
442
+ # {include:Analyze#source_param}
443
+ # {include:Analyze#multi_index}
444
+ # {include:Analyze#multi_types}
445
+ #
446
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Analyze}.
447
+ def analyze(args = {}, immediate = auto_call)
448
+ request(protocol::Analyze, args, immediate)
449
+ end
450
+
451
+ # @!macro request
452
+ # @!macro immediate
453
+ #
454
+ # {include:ClearCache#parameters}
455
+ # {include:ClearCache#source_param}
456
+ # {include:ClearCache#multi_index}
457
+ # {include:ClearCache#multi_types}
458
+ #
459
+ # @param [Hash] args The arguments, as given in {Eson::Shared::ClearCache}.
460
+ def clear_cache(args = {}, immediate = auto_call)
461
+ request(protocol::ClearCache, args, immediate)
462
+ end
463
+
464
+ # @!macro request
465
+ # @!macro immediate
466
+ #
467
+ # {include:CloseIndex#parameters}
468
+ # {include:CloseIndex#source_param}
469
+ # {include:CloseIndex#multi_index}
470
+ # {include:CloseIndex#multi_types}
471
+ #
472
+ # @param [Hash] args The arguments, as given in {Eson::Shared::CloseIndex}.
473
+ def close_index(args = {}, immediate = auto_call)
474
+ request(protocol::CloseIndex, args, immediate)
475
+ end
476
+
477
+ # @!macro request
478
+ # @!macro immediate
479
+ #
480
+ # {include:OpenIndex#parameters}
481
+ # {include:OpenIndex#source_param}
482
+ # {include:OpenIndex#multi_index}
483
+ # {include:OpenIndex#multi_types}
484
+ #
485
+ # @param [Hash] args The arguments, as given in {Eson::Shared::OpenIndex}.
486
+ def open_index(args = {}, immediate = auto_call)
487
+ request(protocol::OpenIndex, args, immediate)
488
+ end
489
+
490
+ # @!macro request
491
+ # @!macro immediate
492
+ #
493
+ # {include:CreateIndex#parameters}
494
+ # {include:CreateIndex#source_param}
495
+ # {include:CreateIndex#multi_index}
496
+ # {include:CreateIndex#multi_types}
497
+ #
498
+ # @param [Hash] args The arguments, as given in {Eson::Shared::CreateIndex}.
499
+ def create_index(args = {}, immediate = auto_call)
500
+ request(protocol::CreateIndex, args, immediate)
501
+ end
502
+
503
+ # @!macro request
504
+ # @!macro immediate
505
+ #
506
+ # {include:DeleteIndex#parameters}
507
+ # {include:DeleteIndex#source_param}
508
+ # {include:DeleteIndex#multi_index}
509
+ # {include:DeleteIndex#multi_types}
510
+ #
511
+ # @param [Hash] args The arguments, as given in {Eson::Shared::DeleteIndex}.
512
+ def delete_index(args = {}, immediate = auto_call)
513
+ request(protocol::DeleteIndex, args, immediate)
514
+ end
515
+
516
+ # @!macro request
517
+ # @!macro immediate
518
+ #
519
+ # {include:DeleteMapping#parameters}
520
+ # {include:DeleteMapping#source_param}
521
+ # {include:DeleteMapping#multi_index}
522
+ # {include:DeleteMapping#multi_types}
523
+ #
524
+ # @param [Hash] args The arguments, as given in {Eson::Shared::DeleteMapping}.
525
+ def delete_mapping(args = {}, immediate = auto_call)
526
+ request(protocol::DeleteMapping, args, immediate)
527
+ end
528
+
529
+ # @!macro request
530
+ # @!macro immediate
531
+ #
532
+ # {include:GetMapping#parameters}
533
+ # {include:GetMapping#source_param}
534
+ # {include:GetMapping#multi_index}
535
+ # {include:GetMapping#multi_types}
536
+ #
537
+ # @param [Hash] args The arguments, as given in {Eson::Shared::GetMapping}.
538
+ def get_mapping(args = {}, immediate = auto_call)
539
+ request(protocol::GetMapping, args, immediate)
540
+ end
541
+
542
+ # @!macro request
543
+ # @!macro immediate
544
+ #
545
+ # {include:PutMapping#parameters}
546
+ # {include:PutMapping#source_param}
547
+ # {include:PutMapping#multi_index}
548
+ # {include:PutMapping#multi_types}
549
+ #
550
+ # @param [Hash] args The arguments, as given in {Eson::Shared::PutMapping}.
551
+ def put_mapping(args = {}, immediate = auto_call)
552
+ request(protocol::PutMapping, args, immediate)
553
+ end
554
+
555
+ # @!macro request
556
+ # @!macro immediate
557
+ #
558
+ # {include:PutTemplate#parameters}
559
+ # {include:PutTemplate#source_param}
560
+ # {include:PutTemplate#multi_index}
561
+ # {include:PutTemplate#multi_types}
562
+ #
563
+ # @param [Hash] args The arguments, as given in {Eson::Shared::PutTemplate}.
564
+ def put_template(args = {}, immediate = auto_call)
565
+ request(protocol::PutTemplate, args, immediate)
566
+ end
567
+
568
+ # @!macro request
569
+ # @!macro immediate
570
+ #
571
+ # {include:GetTemplate#parameters}
572
+ # {include:GetTemplate#source_param}
573
+ # {include:GetTemplate#multi_index}
574
+ # {include:GetTemplate#multi_types}
575
+ #
576
+ # @param [Hash] args The arguments, as given in {Eson::Shared::GetTemplate}.
577
+ def get_template(args = {}, immediate = auto_call)
578
+ request(protocol::GetTemplate, args, immediate)
579
+ end
580
+
581
+ # @!macro request
582
+ # @!macro immediate
583
+ #
584
+ # {include:DeleteTemplate#parameters}
585
+ # {include:DeleteTemplate#source_param}
586
+ # {include:DeleteTemplate#multi_index}
587
+ # {include:DeleteTemplate#multi_types}
588
+ #
589
+ # @param [Hash] args The arguments, as given in {Eson::Shared::DeleteTemplate}.
590
+ def delete_template(args = {}, immediate = auto_call)
591
+ request(protocol::DeleteTemplate, args, immediate)
592
+ end
593
+
594
+ # @!macro request
595
+ # @!macro immediate
596
+ #
597
+ # {include:GetSettings#parameters}
598
+ # {include:GetSettings#source_param}
599
+ # {include:GetSettings#multi_index}
600
+ # {include:GetSettings#multi_types}
601
+ #
602
+ # @param [Hash] args The arguments, as given in {Eson::Shared::GetSettings}.
603
+ def get_settings(args = {}, immediate = auto_call)
604
+ request(protocol::GetSettings, args, immediate)
605
+ end
606
+
607
+ # @!macro request
608
+ # @!macro immediate
609
+ #
610
+ # {include:UpdateSettings#parameters}
611
+ # {include:UpdateSettings#source_param}
612
+ # {include:UpdateSettings#multi_index}
613
+ # {include:UpdateSettings#multi_types}
614
+ #
615
+ # @param [Hash] args The arguments, as given in {Eson::Shared::UpdateSettings}.
616
+ def update_settings(args = {}, immediate = auto_call)
617
+ request(protocol::UpdateSettings, args, immediate)
618
+ end
619
+
620
+ # @!macro request
621
+ # @!macro immediate
622
+ #
623
+ # {include:Flush#parameters}
624
+ # {include:Flush#source_param}
625
+ # {include:Flush#multi_index}
626
+ # {include:Flush#multi_types}
627
+ #
628
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Flush}.
629
+ def flush(args = {}, immediate = auto_call)
630
+ request(protocol::Flush, args, immediate)
631
+ end
632
+
633
+ # @!macro request
634
+ # @!macro immediate
635
+ #
636
+ # {include:Optimize#parameters}
637
+ # {include:Optimize#source_param}
638
+ # {include:Optimize#multi_index}
639
+ # {include:Optimize#multi_types}
640
+ #
641
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Optimize}.
642
+ def optimize(args = {}, immediate = auto_call)
643
+ request(protocol::Optimize, args, immediate)
644
+ end
645
+
646
+ # @!macro request
647
+ # @!macro immediate
648
+ #
649
+ # {include:Refresh#parameters}
650
+ # {include:Refresh#source_param}
651
+ # {include:Refresh#multi_index}
652
+ # {include:Refresh#multi_types}
653
+ #
654
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Refresh}.
655
+ def refresh(args = {}, immediate = auto_call)
656
+ request(protocol::Refresh, args, immediate)
657
+ end
658
+
659
+ # @!macro request
660
+ # @!macro immediate
661
+ #
662
+ # {include:Snapshot#parameters}
663
+ # {include:Snapshot#source_param}
664
+ # {include:Snapshot#multi_index}
665
+ # {include:Snapshot#multi_types}
666
+ #
667
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Snapshot}.
668
+ def snapshot(args = {}, immediate = auto_call)
669
+ request(protocol::Snapshot, args, immediate)
670
+ end
671
+
672
+ # @!macro request
673
+ # @!macro immediate
674
+ #
675
+ # {include:Status#parameters}
676
+ # {include:Status#source_param}
677
+ # {include:Status#multi_index}
678
+ # {include:Status#multi_types}
679
+ #
680
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Status}.
681
+ def status(args = {}, immediate = auto_call)
682
+ request(protocol::Status, args, immediate)
683
+ end
684
+
685
+ # @!macro request
686
+ # @!macro immediate
687
+ #
688
+ # {include:IndexStats#parameters}
689
+ # {include:IndexStats#source_param}
690
+ # {include:IndexStats#multi_index}
691
+ # {include:IndexStats#multi_types}
692
+ #
693
+ # @param [Hash] args The arguments, as given in {Eson::Shared::IndexStats}.
694
+ def index_stats(args = {}, immediate = auto_call)
695
+ request(protocol::IndexStats, args, immediate)
696
+ end
697
+
698
+ # @!macro request
699
+ # @!macro immediate
700
+ #
701
+ # {include:Segments#parameters}
702
+ # {include:Segments#source_param}
703
+ # {include:Segments#multi_index}
704
+ # {include:Segments#multi_types}
705
+ #
706
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Segments}.
707
+ def segments(args = {}, immediate = auto_call)
708
+ request(protocol::Segments, args, immediate)
709
+ end
710
+
711
+ # @!macro request
712
+ # @!macro immediate
713
+ #
714
+ # {include:IndexExists#parameters}
715
+ # {include:IndexExists#source_param}
716
+ # {include:IndexExists#multi_index}
717
+ # {include:IndexExists#multi_types}
718
+ #
719
+ # @param [Hash] args The arguments, as given in {Eson::Shared::IndexExists}.
720
+ def exists?(args = {}, immediate = auto_call)
231
721
  request(protocol::IndexExists, args)
232
722
  rescue Eson::NotFoundError
233
723
  false
234
724
  end
235
-
725
+
726
+ # @!macro request
727
+ # @!macro immediate
728
+ #
729
+ # {include:Explain#parameters}
730
+ # {include:Explain#source_param}
731
+ # {include:Explain#multi_index}
732
+ # {include:Explain#multi_types}
733
+ #
734
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Explain}.
735
+ def explain(args = {}, immediate = auto_call)
736
+ request(protocol::Explain, args)
737
+ end
738
+
739
+ # @!macro request
740
+ # @!macro immediate
741
+ #
742
+ # {include:Validate#parameters}
743
+ # {include:Validate#source_param}
744
+ # {include:Validate#multi_index}
745
+ # {include:Validate#multi_types}
746
+ #
747
+ # @param [Hash] args The arguments, as given in {Eson::Shared::Validate}.
748
+ def validate(args = {}, immediate = auto_call)
749
+ request(protocol::Validate, args)
750
+ end
751
+ # @!endgroup
752
+
236
753
  private
754
+ # @api internal
237
755
  def request(endpoint, args, auto_call = auto_call)
238
756
  r = protocol::Request.new(endpoint, plugins, self)
239
757
 
240
- r.params = args
758
+ r.set_parameters_without_exceptions(default_parameters)
759
+ r.parameters = args
241
760
 
242
761
  if block_given?
243
762
  r.handle_block(&Proc.new)