elasticsearch-api 7.3.0 → 7.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +16 -23
  3. data/elasticsearch-api.gemspec +1 -1
  4. data/lib/elasticsearch/api/actions/abort_benchmark.rb +1 -2
  5. data/lib/elasticsearch/api/actions/benchmark.rb +2 -3
  6. data/lib/elasticsearch/api/actions/bulk.rb +35 -68
  7. data/lib/elasticsearch/api/actions/cat/aliases.rb +30 -52
  8. data/lib/elasticsearch/api/actions/cat/allocation.rb +36 -50
  9. data/lib/elasticsearch/api/actions/cat/count.rb +25 -46
  10. data/lib/elasticsearch/api/actions/cat/fielddata.rb +31 -33
  11. data/lib/elasticsearch/api/actions/cat/health.rb +27 -37
  12. data/lib/elasticsearch/api/actions/cat/help.rb +14 -10
  13. data/lib/elasticsearch/api/actions/cat/indices.rb +45 -62
  14. data/lib/elasticsearch/api/actions/cat/master.rb +24 -34
  15. data/lib/elasticsearch/api/actions/cat/nodeattrs.rb +20 -16
  16. data/lib/elasticsearch/api/actions/cat/nodes.rb +34 -46
  17. data/lib/elasticsearch/api/actions/cat/params_registry.rb +0 -1
  18. data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +29 -35
  19. data/lib/elasticsearch/api/actions/cat/plugins.rb +21 -18
  20. data/lib/elasticsearch/api/actions/cat/recovery.rb +40 -56
  21. data/lib/elasticsearch/api/actions/cat/repositories.rb +21 -24
  22. data/lib/elasticsearch/api/actions/cat/segments.rb +29 -22
  23. data/lib/elasticsearch/api/actions/cat/shards.rb +38 -59
  24. data/lib/elasticsearch/api/actions/cat/snapshots.rb +32 -27
  25. data/lib/elasticsearch/api/actions/cat/tasks.rb +25 -19
  26. data/lib/elasticsearch/api/actions/cat/templates.rb +26 -18
  27. data/lib/elasticsearch/api/actions/cat/thread_pool.rb +36 -46
  28. data/lib/elasticsearch/api/actions/clear_scroll.rb +21 -8
  29. data/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +15 -13
  30. data/lib/elasticsearch/api/actions/cluster/get_settings.rb +18 -18
  31. data/lib/elasticsearch/api/actions/cluster/health.rb +42 -44
  32. data/lib/elasticsearch/api/actions/cluster/params_registry.rb +0 -1
  33. data/lib/elasticsearch/api/actions/cluster/pending_tasks.rb +15 -17
  34. data/lib/elasticsearch/api/actions/cluster/put_settings.rb +20 -17
  35. data/lib/elasticsearch/api/actions/cluster/remote_info.rb +8 -6
  36. data/lib/elasticsearch/api/actions/cluster/reroute.rb +25 -37
  37. data/lib/elasticsearch/api/actions/cluster/state.rb +37 -41
  38. data/lib/elasticsearch/api/actions/cluster/stats.rb +20 -12
  39. data/lib/elasticsearch/api/actions/count.rb +52 -39
  40. data/lib/elasticsearch/api/actions/create.rb +25 -26
  41. data/lib/elasticsearch/api/actions/delete.rb +43 -36
  42. data/lib/elasticsearch/api/actions/delete_by_query.rb +74 -62
  43. data/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb +39 -0
  44. data/lib/elasticsearch/api/actions/delete_by_rethrottle.rb +4 -3
  45. data/lib/elasticsearch/api/actions/delete_script.rb +19 -13
  46. data/lib/elasticsearch/api/actions/exists.rb +44 -34
  47. data/lib/elasticsearch/api/actions/exists_source.rb +43 -25
  48. data/lib/elasticsearch/api/actions/explain.rb +46 -51
  49. data/lib/elasticsearch/api/actions/field_caps.rb +27 -20
  50. data/lib/elasticsearch/api/actions/get.rb +42 -41
  51. data/lib/elasticsearch/api/actions/get_script.rb +19 -14
  52. data/lib/elasticsearch/api/actions/get_source.rb +38 -44
  53. data/lib/elasticsearch/api/actions/index.rb +60 -89
  54. data/lib/elasticsearch/api/actions/indices/analyze.rb +19 -48
  55. data/lib/elasticsearch/api/actions/indices/clear_cache.rb +29 -41
  56. data/lib/elasticsearch/api/actions/indices/clone.rb +50 -0
  57. data/lib/elasticsearch/api/actions/indices/close.rb +28 -32
  58. data/lib/elasticsearch/api/actions/indices/create.rb +22 -70
  59. data/lib/elasticsearch/api/actions/indices/delete.rb +23 -35
  60. data/lib/elasticsearch/api/actions/indices/delete_alias.rb +24 -20
  61. data/lib/elasticsearch/api/actions/indices/delete_template.rb +18 -20
  62. data/lib/elasticsearch/api/actions/indices/exists.rb +32 -34
  63. data/lib/elasticsearch/api/actions/indices/exists_alias.rb +33 -29
  64. data/lib/elasticsearch/api/actions/indices/exists_template.rb +21 -16
  65. data/lib/elasticsearch/api/actions/indices/exists_type.rb +29 -29
  66. data/lib/elasticsearch/api/actions/indices/flush.rb +28 -28
  67. data/lib/elasticsearch/api/actions/indices/flush_synced.rb +23 -12
  68. data/lib/elasticsearch/api/actions/indices/forcemerge.rb +26 -41
  69. data/lib/elasticsearch/api/actions/indices/freeze.rb +7 -8
  70. data/lib/elasticsearch/api/actions/indices/get.rb +25 -19
  71. data/lib/elasticsearch/api/actions/indices/get_alias.rb +31 -23
  72. data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +42 -38
  73. data/lib/elasticsearch/api/actions/indices/get_mapping.rb +39 -31
  74. data/lib/elasticsearch/api/actions/indices/get_settings.rb +34 -37
  75. data/lib/elasticsearch/api/actions/indices/get_template.rb +21 -23
  76. data/lib/elasticsearch/api/actions/indices/get_upgrade.rb +48 -0
  77. data/lib/elasticsearch/api/actions/indices/open.rb +24 -21
  78. data/lib/elasticsearch/api/actions/indices/params_registry.rb +0 -1
  79. data/lib/elasticsearch/api/actions/indices/put_alias.rb +25 -27
  80. data/lib/elasticsearch/api/actions/indices/put_mapping.rb +40 -39
  81. data/lib/elasticsearch/api/actions/indices/put_settings.rb +30 -37
  82. data/lib/elasticsearch/api/actions/indices/put_template.rb +23 -23
  83. data/lib/elasticsearch/api/actions/indices/recovery.rb +20 -23
  84. data/lib/elasticsearch/api/actions/indices/refresh.rb +22 -26
  85. data/lib/elasticsearch/api/actions/indices/rollover.rb +28 -19
  86. data/lib/elasticsearch/api/actions/indices/segments.rb +24 -17
  87. data/lib/elasticsearch/api/actions/indices/shard_stores.rb +27 -15
  88. data/lib/elasticsearch/api/actions/indices/shrink.rb +23 -17
  89. data/lib/elasticsearch/api/actions/indices/split.rb +23 -17
  90. data/lib/elasticsearch/api/actions/indices/stats.rb +53 -104
  91. data/lib/elasticsearch/api/actions/indices/unfreeze.rb +7 -7
  92. data/lib/elasticsearch/api/actions/indices/update_aliases.rb +15 -32
  93. data/lib/elasticsearch/api/actions/indices/upgrade.rb +26 -16
  94. data/lib/elasticsearch/api/actions/indices/validate_query.rb +46 -59
  95. data/lib/elasticsearch/api/actions/info.rb +9 -6
  96. data/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb +18 -12
  97. data/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +21 -11
  98. data/lib/elasticsearch/api/actions/ingest/params_registry.rb +0 -1
  99. data/lib/elasticsearch/api/actions/ingest/processor_grok.rb +12 -13
  100. data/lib/elasticsearch/api/actions/ingest/put_pipeline.rb +19 -14
  101. data/lib/elasticsearch/api/actions/ingest/simulate.rb +23 -13
  102. data/lib/elasticsearch/api/actions/mget.rb +37 -44
  103. data/lib/elasticsearch/api/actions/msearch.rb +54 -54
  104. data/lib/elasticsearch/api/actions/msearch_template.rb +46 -35
  105. data/lib/elasticsearch/api/actions/mtermvectors.rb +39 -35
  106. data/lib/elasticsearch/api/actions/nodes/hot_threads.rb +30 -25
  107. data/lib/elasticsearch/api/actions/nodes/info.rb +29 -63
  108. data/lib/elasticsearch/api/actions/nodes/params_registry.rb +0 -1
  109. data/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb +24 -22
  110. data/lib/elasticsearch/api/actions/nodes/shutdown.rb +4 -4
  111. data/lib/elasticsearch/api/actions/nodes/stats.rb +43 -36
  112. data/lib/elasticsearch/api/actions/nodes/usage.rb +31 -10
  113. data/lib/elasticsearch/api/actions/params_registry.rb +0 -1
  114. data/lib/elasticsearch/api/actions/ping.rb +12 -13
  115. data/lib/elasticsearch/api/actions/put_script.rb +26 -30
  116. data/lib/elasticsearch/api/actions/rank_eval.rb +24 -15
  117. data/lib/elasticsearch/api/actions/reindex.rb +25 -48
  118. data/lib/elasticsearch/api/actions/reindex_rethrottle.rb +18 -12
  119. data/lib/elasticsearch/api/actions/remote/info.rb +1 -2
  120. data/lib/elasticsearch/api/actions/render_search_template.rb +17 -15
  121. data/lib/elasticsearch/api/actions/scripts_painless_execute.rb +8 -6
  122. data/lib/elasticsearch/api/actions/scroll.rb +28 -51
  123. data/lib/elasticsearch/api/actions/search.rb +104 -165
  124. data/lib/elasticsearch/api/actions/search_shards.rb +31 -28
  125. data/lib/elasticsearch/api/actions/search_template.rb +48 -40
  126. data/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb +44 -0
  127. data/lib/elasticsearch/api/actions/snapshot/create.rb +22 -29
  128. data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +19 -24
  129. data/lib/elasticsearch/api/actions/snapshot/delete.rb +20 -22
  130. data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +16 -18
  131. data/lib/elasticsearch/api/actions/snapshot/get.rb +22 -31
  132. data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +21 -25
  133. data/lib/elasticsearch/api/actions/snapshot/params_registry.rb +0 -1
  134. data/lib/elasticsearch/api/actions/snapshot/restore.rb +21 -32
  135. data/lib/elasticsearch/api/actions/snapshot/status.rb +23 -24
  136. data/lib/elasticsearch/api/actions/snapshot/verify_repository.rb +18 -13
  137. data/lib/elasticsearch/api/actions/tasks/cancel.rb +19 -13
  138. data/lib/elasticsearch/api/actions/tasks/get.rb +16 -13
  139. data/lib/elasticsearch/api/actions/tasks/list.rb +20 -18
  140. data/lib/elasticsearch/api/actions/tasks/params_registry.rb +0 -1
  141. data/lib/elasticsearch/api/actions/termvectors.rb +52 -70
  142. data/lib/elasticsearch/api/actions/update.rb +53 -98
  143. data/lib/elasticsearch/api/actions/update_by_query.rb +77 -66
  144. data/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb +17 -11
  145. data/lib/elasticsearch/api/version.rb +1 -1
  146. data/spec/elasticsearch/api/actions/cat/segments_spec.rb +9 -11
  147. data/spec/elasticsearch/api/actions/cluster/put_settings_spec.rb +1 -1
  148. data/spec/elasticsearch/api/actions/count_spec.rb +8 -8
  149. data/spec/elasticsearch/api/actions/delete_by_query_spec.rb +12 -7
  150. data/spec/elasticsearch/api/actions/delete_script_spec.rb +0 -14
  151. data/spec/elasticsearch/api/actions/exists_document_spec.rb +1 -1
  152. data/spec/elasticsearch/api/actions/get_document_source_spec.rb +1 -1
  153. data/spec/elasticsearch/api/actions/index_document_spec.rb +6 -15
  154. data/spec/elasticsearch/api/actions/indices/analyze_spec.rb +0 -4
  155. data/spec/elasticsearch/api/actions/indices/clear_cache_spec.rb +1 -5
  156. data/spec/elasticsearch/api/actions/indices/clone_spec.rb +109 -0
  157. data/spec/elasticsearch/api/actions/indices/delete_alias_spec.rb +2 -2
  158. data/spec/elasticsearch/api/actions/indices/get_spec.rb +0 -11
  159. data/spec/elasticsearch/api/actions/indices/put_alias_spec.rb +3 -3
  160. data/spec/elasticsearch/api/actions/indices/put_mapping_spec.rb +3 -3
  161. data/spec/elasticsearch/api/actions/indices/stats_spec.rb +0 -1
  162. data/spec/elasticsearch/api/actions/nodes/hot_threads_spec.rb +3 -3
  163. data/spec/elasticsearch/api/actions/put_script_spec.rb +20 -15
  164. data/spec/elasticsearch/api/actions/render_search_template_spec.rb +23 -7
  165. data/spec/elasticsearch/api/actions/scroll_spec.rb +37 -0
  166. data/spec/elasticsearch/api/actions/search_spec.rb +0 -15
  167. data/spec/elasticsearch/api/actions/tasks/list_spec.rb +0 -11
  168. data/spec/elasticsearch/api/actions/update_document_spec.rb +3 -7
  169. data/spec/elasticsearch/api/rest_api_yaml_spec.rb +1 -1
  170. data/spec/rest_yaml_tests_helper.rb +12 -0
  171. data/utils/Gemfile +1 -0
  172. data/utils/Thorfile +0 -1
  173. data/utils/thor/generate_source.rb +192 -85
  174. data/utils/thor/generator/endpoint_specifics.rb +157 -0
  175. data/utils/thor/generator/files_helper.rb +37 -0
  176. data/utils/thor/lister.rb +3 -4
  177. data/utils/thor/templates/_documentation_top.erb +27 -0
  178. data/utils/thor/templates/_method_setup.erb +35 -0
  179. data/utils/thor/templates/_params_registry.erb +12 -0
  180. data/utils/thor/templates/_perform_request.erb +37 -0
  181. data/utils/thor/templates/method.erb +59 -0
  182. data/utils/thor/templates/{ruby/test.erb → test.erb} +0 -0
  183. data/utils/thor/templates/{ruby/test_helper.rb → test_helper.rb} +0 -0
  184. metadata +31 -14
  185. data/spec/elasticsearch/api/actions/scoll_spec.rb +0 -21
  186. data/utils/thor/generate_api.rb +0 -193
  187. data/utils/thor/templates/ruby/method.erb +0 -62
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 554bf3603ac9c6be5fa3555e017babe35f101f15e2417013ed56f953afc865e3
4
- data.tar.gz: c478ddfc93e1229bffb91bbe0cb9997e74becde2c5105ed497780e7e4f7a2f59
3
+ metadata.gz: 6b881e7cb1f40511b850a1ef10fe4f39047ca62fadb6de31f7d47bb9b9975d5d
4
+ data.tar.gz: 7c285a20100e694ad7b5d3806d3b62cbc58341a6b9eaf2f4c88294fc0367692e
5
5
  SHA512:
6
- metadata.gz: 55e7282d4325fb747e51aec041f4e7aa86d20f5760ade1a060825db225500810f8ede807b94329ec1980bf5f7e938c233134f56361fc683378cde0bfdf8fe09d
7
- data.tar.gz: 773db2bfcf05d36b4e8a042f70a0e269c41a13bef8d785e90d38c8db3a3e96e8d8cf6aa40094d15ac97486fc0a24a74353e38c54fa6da6705935de5b153c694c
6
+ metadata.gz: 4e6ada0c6484d228af0ea67e66e5ae209ae90b7a4c6e4342c4f6616f206417add4dd03c435854df5d3e3b7d0b14c1af14dfc43cfa8026b6779e1c62933467064
7
+ data.tar.gz: 95b8072f025a5b9963bad07951190d9b4123d87f523dcd9e62b7fbb0553740ada93bd02aac89784c672dd62a8584717f3eec1b4f5c54026766193255b403de4c
data/Rakefile CHANGED
@@ -2,7 +2,7 @@
2
2
  # Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
3
  # See the LICENSE file in the project root for more information
4
4
 
5
- require "bundler/gem_tasks"
5
+ require 'bundler/gem_tasks'
6
6
 
7
7
  def __current__
8
8
  Pathname( File.expand_path('..', __FILE__) )
@@ -12,8 +12,8 @@ def git_specs(command, options={})
12
12
  sh "git --git-dir=#{__current__.join('../tmp/elasticsearch/.git')} --work-tree=#{__current__.join('../tmp/elasticsearch')} #{command}", options
13
13
  end
14
14
 
15
- task(:default) { system "rake --tasks" }
16
- task :test => 'test:unit'
15
+ task(:default) { system 'rake --tasks' }
16
+ task test: 'test:unit'
17
17
 
18
18
  # ----- Test tasks ------------------------------------------------------------
19
19
 
@@ -21,35 +21,30 @@ require 'rake/testtask'
21
21
  require 'rspec/core/rake_task'
22
22
 
23
23
  namespace :test do
24
-
25
- desc "Wait for Elasticsearch to be in a green state"
24
+ desc 'Wait for Elasticsearch to be in a green state'
26
25
  task :wait_for_green do
27
26
  sh '../scripts/wait-cluster.sh'
28
27
  end
29
28
 
29
+ # Unit tests - rake test:unit
30
+ #
31
+ task unit: :spec
30
32
  RSpec::Core::RakeTask.new(:spec) do |t|
31
33
  t.exclude_pattern = 'spec/**{,/*/**}/rest_api_yaml_spec.rb'
32
34
  end
33
35
 
36
+ # Rest API Spec tests - rake test:rest_api
34
37
  RSpec::Core::RakeTask.new(:rest_api) do |t|
35
38
  t.pattern = 'spec/**{,/*/**}/rest_api_yaml_spec.rb'
36
39
  end
37
40
 
38
- desc "Update the repository with YAML tests"
41
+ desc 'Update the repository with YAML tests'
39
42
  task :update do
40
- git_specs "fetch origin", :verbose => true
41
- end
42
-
43
- Rake::TestTask.new(:unit) do |test|
44
- test.libs << 'lib' << 'test'
45
- test.test_files = FileList["test/unit/**/*_test.rb"]
46
- test.deps = [ :spec ]
47
- # test.verbose = true
48
- # test.warning = true
43
+ git_specs 'fetch origin', verbose: true
49
44
  end
50
45
 
51
46
  desc "Run integration tests"
52
- task :integration => :update do
47
+ task integration: :update do
53
48
  require 'elasticsearch'
54
49
 
55
50
  branches = `git --git-dir=#{__current__.join('../tmp/elasticsearch/.git')} --work-tree=#{__current__.join('../tmp/elasticsearch')} branch --no-color`
@@ -107,7 +102,7 @@ namespace :test do
107
102
  end
108
103
  end
109
104
 
110
- desc "Run unit and integration tests"
105
+ desc 'Run unit and integration tests'
111
106
  task :all do
112
107
  Rake::Task['test:unit'].invoke
113
108
  Rake::Task['test:integration'].invoke
@@ -139,10 +134,8 @@ end
139
134
 
140
135
  # ----- Code analysis tasks ---------------------------------------------------
141
136
 
142
- if defined?(RUBY_VERSION) && RUBY_VERSION > '1.9'
143
- require 'cane/rake_task'
144
- Cane::RakeTask.new(:quality) do |cane|
145
- cane.abc_max = 15
146
- cane.no_style = true
147
- end
137
+ require 'cane/rake_task'
138
+ Cane::RakeTask.new(:quality) do |cane|
139
+ cane.abc_max = 15
140
+ cane.no_style = true
148
141
  end
@@ -65,7 +65,7 @@ Gem::Specification.new do |s|
65
65
  s.add_development_dependency "ruby-prof" unless defined?(JRUBY_VERSION) || defined?(Rubinius)
66
66
  s.add_development_dependency "jbuilder"
67
67
  s.add_development_dependency "escape_utils" unless defined? JRUBY_VERSION
68
- s.add_development_dependency "simplecov"
68
+ s.add_development_dependency "simplecov", '~> 0.17', '< 0.18'
69
69
  s.add_development_dependency "simplecov-rcov"
70
70
  s.add_development_dependency "cane"
71
71
  s.add_development_dependency "require-prof" unless defined?(JRUBY_VERSION) || defined?(Rubinius)
@@ -5,7 +5,6 @@
5
5
  module Elasticsearch
6
6
  module API
7
7
  module Actions
8
-
9
8
  # Abort a running benchmark
10
9
  #
11
10
  # @example
@@ -16,7 +15,7 @@ module Elasticsearch
16
15
  #
17
16
  # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-benchmark.html
18
17
  #
19
- def abort_benchmark(arguments={})
18
+ def abort_benchmark(arguments = {})
20
19
  method = HTTP_POST
21
20
  path = "_bench/abort/#{arguments[:name]}"
22
21
  params = {}
@@ -5,7 +5,6 @@
5
5
  module Elasticsearch
6
6
  module API
7
7
  module Actions
8
-
9
8
  # Run a single query, or a set of queries, and return statistics on their performance
10
9
  #
11
10
  # @example Return statistics for a single query
@@ -51,7 +50,7 @@ module Elasticsearch
51
50
  #
52
51
  # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-benchmark.html
53
52
  #
54
- def benchmark(arguments={})
53
+ def benchmark(arguments = {})
55
54
  method = HTTP_PUT
56
55
  path = "_bench"
57
56
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
@@ -63,7 +62,7 @@ module Elasticsearch
63
62
  # Register this action with its valid params when the module is loaded.
64
63
  #
65
64
  # @since 6.1.1
66
- ParamsRegistry.register(:benchmark, [ :verbose ].freeze)
65
+ ParamsRegistry.register(:benchmark, [:verbose].freeze)
67
66
  end
68
67
  end
69
68
  end
@@ -5,57 +5,14 @@
5
5
  module Elasticsearch
6
6
  module API
7
7
  module Actions
8
-
9
- # Perform multiple index, delete or update operations in a single request.
10
- #
11
- # Supports various different formats of the payload: Array of Strings, Header/Data pairs,
12
- # or the conveniency "combined" format where data is passed along with the header
13
- # in a single item in a custom `:data` key.
14
- #
15
- # @note The body argument is required and cannot be empty.
16
- #
17
- # @example Perform three operations in a single request, passing actions and data as an array of hashes
18
- #
19
- # client.bulk body: [
20
- # { index: { _index: 'myindex', _type: 'mytype', _id: 1 } },
21
- # { title: 'foo' },
22
- #
23
- # { index: { _index: 'myindex', _type: 'mytype', _id: 2 } },
24
- # { title: 'foo' },
25
- #
26
- # { delete: { _index: 'myindex', _type: 'mytype', _id: 3 } }
27
- # ]
28
- # @example Perform three operations in a single request, passing data in the `:data` option
29
- #
30
- # client.bulk body: [
31
- # { index: { _index: 'myindex', _type: 'mytype', _id: 1, data: { title: 'foo' } } },
32
- # { update: { _index: 'myindex', _type: 'mytype', _id: 2, data: { doc: { title: 'foo' } } } },
33
- # { delete: { _index: 'myindex', _type: 'mytype', _id: 3 } }
34
- # ]
35
- #
36
- # @example Perform a script-based bulk update, passing scripts in the `:data` option
37
- #
38
- # client.bulk body: [
39
- # { update: { _index: 'myindex', _type: 'mytype', _id: 1,
40
- # data: {
41
- # script: "ctx._source.counter += value",
42
- # lang: 'js',
43
- # params: { value: 1 }, upsert: { counter: 0 } }
44
- # }},
45
- # { update: { _index: 'myindex', _type: 'mytype', _id: 2,
46
- # data: {
47
- # script: "ctx._source.counter += value",
48
- # lang: 'js',
49
- # params: { value: 42 }, upsert: { counter: 0 } }
50
- # }}
51
- #
52
- # ]
8
+ # Allows to perform multiple index/update/delete operations in a single request.
53
9
  #
54
10
  # @option arguments [String] :index Default index for items which don't provide one
55
11
  # @option arguments [String] :type Default document type for items which don't provide one
56
- # @option arguments [Hash] :body The operation definition and data (action-data pairs), separated by newlines (*Required*)
57
12
  # @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the bulk operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
58
- # @option arguments [String] :refresh If `true` then refresh the effected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes. (options: true, false, wait_for)
13
+ # @option arguments [String] :refresh If `true` then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` (the default) then do nothing with refreshes.
14
+ # (options: true,false,wait_for)
15
+
59
16
  # @option arguments [String] :routing Specific routing value
60
17
  # @option arguments [Time] :timeout Explicit operation timeout
61
18
  # @option arguments [String] :type Default document type for items which don't provide one
@@ -63,44 +20,54 @@ module Elasticsearch
63
20
  # @option arguments [List] :_source_excludes Default list of fields to exclude from the returned _source field, can be overridden on each sub-request
64
21
  # @option arguments [List] :_source_includes Default list of fields to extract and return from the _source field, can be overridden on each sub-request
65
22
  # @option arguments [String] :pipeline The pipeline id to preprocess incoming documents with
23
+
24
+ # @option arguments [Hash] :body The operation definition and data (action-data pairs), separated by newlines (*Required*)
66
25
  #
67
- # @return [Hash] Deserialized Elasticsearch response
68
- #
69
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
26
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-bulk.html
70
27
  #
71
- def bulk(arguments={})
28
+ def bulk(arguments = {})
29
+ raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
30
+
72
31
  arguments = arguments.clone
73
32
 
74
- type = arguments.delete(:type)
33
+ _index = arguments.delete(:index)
75
34
 
76
- method = HTTP_POST
77
- path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(type), '_bulk'
35
+ _type = arguments.delete(:type)
78
36
 
37
+ method = Elasticsearch::API::HTTP_POST
38
+ path = if _index && _type
39
+ "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_bulk"
40
+ elsif _index
41
+ "#{Utils.__listify(_index)}/_bulk"
42
+ else
43
+ "_bulk"
44
+ end
79
45
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
80
- body = arguments[:body]
81
46
 
47
+ body = arguments[:body]
82
48
  if body.is_a? Array
83
49
  payload = Utils.__bulkify(body)
84
50
  else
85
51
  payload = body
86
- end
52
+ end
87
53
 
88
- perform_request(method, path, params, payload, {"Content-Type" => "application/x-ndjson"}).body
54
+ perform_request(method, path, params, payload, { "Content-Type" => "application/x-ndjson" }).body
89
55
  end
90
56
 
91
57
  # Register this action with its valid params when the module is loaded.
92
58
  #
93
- # @since 6.1.1
59
+ # @since 6.2.0
94
60
  ParamsRegistry.register(:bulk, [
95
- :wait_for_active_shards,
96
- :refresh,
97
- :routing,
98
- :timeout,
99
- :type,
100
- :_source,
101
- :_source_excludes,
102
- :_source_includes,
103
- :pipeline ].freeze)
61
+ :wait_for_active_shards,
62
+ :refresh,
63
+ :routing,
64
+ :timeout,
65
+ :type,
66
+ :_source,
67
+ :_source_excludes,
68
+ :_source_includes,
69
+ :pipeline
70
+ ].freeze)
71
+ end
104
72
  end
105
- end
106
73
  end
@@ -6,71 +6,49 @@ module Elasticsearch
6
6
  module API
7
7
  module Cat
8
8
  module Actions
9
-
10
- # Returns information about aliases, including associated routing values and filters.
11
- #
12
- # @example Display all aliases in the cluster
13
- #
14
- # puts client.cat.aliases
15
- #
16
- # @example Display indices for the 'year-2013' alias
17
- #
18
- # puts client.cat.aliases name: 'year-2013'
19
- #
20
- # @example Display header names in the output
21
- #
22
- # puts client.cat.aliases v: true
23
- #
24
- # @example Return only the 'alias' and 'index' columns
25
- #
26
- # puts client.cat.aliases h: ['alias', 'index']
27
- #
28
- # @example Return only the 'alias' and 'index' columns, using short names
29
- #
30
- # puts client.cat.aliases h: 'a,i'
31
- #
32
- # @example Return the output sorted by the alias name
33
- #
34
- # puts client.cat.aliases s: 'alias'
35
- #
36
- # @example Return the information as Ruby objects
37
- #
38
- # client.cat.aliases format: 'json'
9
+ # Shows information about currently configured aliases to indices including filter and routing infos.
39
10
  #
40
11
  # @option arguments [List] :name A comma-separated list of alias names to return
41
- # @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
42
- # @option arguments [Boolean] :v Display column headers as part of the output
12
+ # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml
13
+ # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false)
14
+ # @option arguments [List] :h Comma-separated list of column names to display
15
+ # @option arguments [Boolean] :help Return help information
43
16
  # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
44
- # @option arguments [String] :format The output format. Options: 'text', 'json'; default: 'text'
45
- # @option arguments [Boolean] :help Return information about headers
46
- # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
47
- # (default: false)
48
- # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
17
+ # @option arguments [Boolean] :v Verbose mode. Display column headers
18
+
49
19
  #
50
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-aliases.html
20
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/cat-alias.html
51
21
  #
52
- def aliases(arguments={})
53
- name = arguments.delete(:name)
54
- method = HTTP_GET
55
- path = Utils.__pathify '_cat/aliases', Utils.__listify(name)
22
+ def aliases(arguments = {})
23
+ arguments = arguments.clone
24
+
25
+ _name = arguments.delete(:name)
26
+
27
+ method = Elasticsearch::API::HTTP_GET
28
+ path = if _name
29
+ "_cat/aliases/#{Utils.__listify(_name)}"
30
+ else
31
+ "_cat/aliases"
32
+ end
56
33
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
57
34
  params[:h] = Utils.__listify(params[:h]) if params[:h]
58
- body = nil
35
+
36
+ body = nil
59
37
  perform_request(method, path, params, body).body
60
38
  end
61
39
 
62
40
  # Register this action with its valid params when the module is loaded.
63
41
  #
64
- # @since 6.1.1
42
+ # @since 6.2.0
65
43
  ParamsRegistry.register(:aliases, [
66
- :format,
67
- :local,
68
- :master_timeout,
69
- :h,
70
- :help,
71
- :s,
72
- :v ].freeze)
44
+ :format,
45
+ :local,
46
+ :h,
47
+ :help,
48
+ :s,
49
+ :v
50
+ ].freeze)
51
+ end
73
52
  end
74
- end
75
53
  end
76
54
  end
@@ -6,69 +6,55 @@ module Elasticsearch
6
6
  module API
7
7
  module Cat
8
8
  module Actions
9
-
10
- # Return shard allocation information
11
- #
12
- # @example Display allocation for all nodes in the cluster
13
- #
14
- # puts client.cat.allocation
15
- #
16
- # @example Display allocation for node with name 'node-1'
17
- #
18
- # puts client.cat.allocation node_id: 'node-1'
19
- #
20
- # @example Display header names in the output
21
- #
22
- # puts client.cat.allocation v: true
23
- #
24
- # @example Display only specific columns in the output (see the `help` parameter)
25
- #
26
- # puts client.cat.allocation h: ['node', 'shards', 'disk.percent']
27
- #
28
- # @example Display only specific columns in the output, using the short names
29
- #
30
- # puts client.cat.allocation h: 'n,s,dp'
31
- #
32
- # @example Return the information as Ruby objects
33
- #
34
- # client.cat.allocation format: 'json'
9
+ # Provides a snapshot of how many shards are allocated to each data node and how much disk space they are using.
35
10
  #
36
11
  # @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information
37
- # @option arguments [String] :bytes The unit in which to display byte values (options: b, k, m, g)
38
- # @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
39
- # @option arguments [Boolean] :v Display column headers as part of the output
40
- # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
41
- # @option arguments [String] :format The output format. Options: 'text', 'json'; default: 'text'
42
- # @option arguments [Boolean] :help Return information about headers
43
- # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
44
- # (default: false)
12
+ # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml
13
+ # @option arguments [String] :bytes The unit in which to display byte values
14
+ # (options: b,k,kb,m,mb,g,gb,t,tb,p,pb)
15
+
16
+ # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false)
45
17
  # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
18
+ # @option arguments [List] :h Comma-separated list of column names to display
19
+ # @option arguments [Boolean] :help Return help information
20
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
21
+ # @option arguments [Boolean] :v Verbose mode. Display column headers
22
+
46
23
  #
47
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-allocation.html
24
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/cat-allocation.html
48
25
  #
49
- def allocation(arguments={})
50
- node_id = arguments.delete(:node_id)
51
- method = HTTP_GET
52
- path = Utils.__pathify '_cat/allocation', Utils.__listify(node_id)
26
+ def allocation(arguments = {})
27
+ arguments = arguments.clone
28
+
29
+ _node_id = arguments.delete(:node_id)
30
+
31
+ method = Elasticsearch::API::HTTP_GET
32
+ path = if _node_id
33
+ "_cat/allocation/#{Utils.__listify(_node_id)}"
34
+ else
35
+ "_cat/allocation"
36
+ end
53
37
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
54
38
  params[:h] = Utils.__listify(params[:h]) if params[:h]
55
- body = nil
39
+
40
+ body = nil
56
41
  perform_request(method, path, params, body).body
57
42
  end
58
43
 
59
44
  # Register this action with its valid params when the module is loaded.
60
45
  #
61
- # @since 6.1.1
46
+ # @since 6.2.0
62
47
  ParamsRegistry.register(:allocation, [
63
- :format,
64
- :bytes,
65
- :local,
66
- :master_timeout,
67
- :h,
68
- :help,
69
- :s,
70
- :v ].freeze)
48
+ :format,
49
+ :bytes,
50
+ :local,
51
+ :master_timeout,
52
+ :h,
53
+ :help,
54
+ :s,
55
+ :v
56
+ ].freeze)
57
+ end
71
58
  end
72
- end
73
59
  end
74
60
  end
@@ -6,68 +6,47 @@ module Elasticsearch
6
6
  module API
7
7
  module Cat
8
8
  module Actions
9
-
10
- # Return document counts for the entire cluster or specific indices
11
- #
12
- # @example Display number of documents in the cluster
13
- #
14
- # puts client.cat.count
15
- #
16
- # @example Display number of documents in an index
17
- #
18
- # puts client.cat.count index: 'index-a'
19
- #
20
- # @example Display number of documents in a list of indices
21
- #
22
- # puts client.cat.count index: ['index-a', 'index-b']
23
- #
24
- # @example Display header names in the output
25
- #
26
- # puts client.cat.count v: true
27
- #
28
- # @example Return the information as Ruby objects
29
- #
30
- # client.cat.count format: 'json'
9
+ # Provides quick access to the document count of the entire cluster, or individual indices.
31
10
  #
32
11
  # @option arguments [List] :index A comma-separated list of index names to limit the returned information
33
- # @option arguments [List] :h Comma-separated list of column names to display -- see the `help` argument
34
- # @option arguments [Boolean] :v Display column headers as part of the output
12
+ # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml
13
+ # @option arguments [List] :h Comma-separated list of column names to display
14
+ # @option arguments [Boolean] :help Return help information
35
15
  # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
36
- # @option arguments [String] :format The output format. Options: 'text', 'json'; default: 'text'
37
- # @option arguments [Boolean] :help Return information about headers
38
- # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node
39
- # (default: false)
40
- # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
16
+ # @option arguments [Boolean] :v Verbose mode. Display column headers
17
+
41
18
  #
42
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/cat-count.html
19
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/cat-count.html
43
20
  #
44
- def count(arguments={})
45
- index = arguments.delete(:index)
21
+ def count(arguments = {})
22
+ arguments = arguments.clone
46
23
 
47
- method = HTTP_GET
48
-
49
- path = Utils.__pathify '_cat/count', Utils.__listify(index)
24
+ _index = arguments.delete(:index)
50
25
 
26
+ method = Elasticsearch::API::HTTP_GET
27
+ path = if _index
28
+ "_cat/count/#{Utils.__listify(_index)}"
29
+ else
30
+ "_cat/count"
31
+ end
51
32
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
52
33
  params[:h] = Utils.__listify(params[:h]) if params[:h]
53
34
 
54
- body = nil
55
-
35
+ body = nil
56
36
  perform_request(method, path, params, body).body
57
37
  end
58
38
 
59
39
  # Register this action with its valid params when the module is loaded.
60
40
  #
61
- # @since 6.1.1
41
+ # @since 6.2.0
62
42
  ParamsRegistry.register(:count, [
63
- :format,
64
- :local,
65
- :master_timeout,
66
- :h,
67
- :help,
68
- :s,
69
- :v ].freeze)
43
+ :format,
44
+ :h,
45
+ :help,
46
+ :s,
47
+ :v
48
+ ].freeze)
49
+ end
70
50
  end
71
- end
72
51
  end
73
52
  end