elasticsearch-api 7.9.0 → 7.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -4
  3. data/README.md +27 -13
  4. data/Rakefile +46 -62
  5. data/elasticsearch-api.gemspec +2 -4
  6. data/lib/elasticsearch/api/actions/bulk.rb +4 -3
  7. data/lib/elasticsearch/api/actions/cat/aliases.rb +1 -1
  8. data/lib/elasticsearch/api/actions/cat/allocation.rb +1 -1
  9. data/lib/elasticsearch/api/actions/cat/count.rb +1 -1
  10. data/lib/elasticsearch/api/actions/cat/fielddata.rb +1 -2
  11. data/lib/elasticsearch/api/actions/cat/health.rb +1 -1
  12. data/lib/elasticsearch/api/actions/cat/help.rb +1 -1
  13. data/lib/elasticsearch/api/actions/cat/indices.rb +2 -2
  14. data/lib/elasticsearch/api/actions/cat/master.rb +1 -1
  15. data/lib/elasticsearch/api/actions/cat/nodeattrs.rb +1 -1
  16. data/lib/elasticsearch/api/actions/cat/nodes.rb +4 -2
  17. data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +1 -1
  18. data/lib/elasticsearch/api/actions/cat/plugins.rb +3 -1
  19. data/lib/elasticsearch/api/actions/cat/recovery.rb +1 -2
  20. data/lib/elasticsearch/api/actions/cat/repositories.rb +1 -1
  21. data/lib/elasticsearch/api/actions/cat/segments.rb +1 -1
  22. data/lib/elasticsearch/api/actions/cat/shards.rb +2 -2
  23. data/lib/elasticsearch/api/actions/cat/snapshots.rb +1 -1
  24. data/lib/elasticsearch/api/actions/cat/tasks.rb +5 -5
  25. data/lib/elasticsearch/api/actions/cat/templates.rb +1 -1
  26. data/lib/elasticsearch/api/actions/cat/thread_pool.rb +1 -1
  27. data/lib/elasticsearch/api/actions/clear_scroll.rb +1 -1
  28. data/lib/elasticsearch/api/actions/close_point_in_time.rb +42 -0
  29. data/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +1 -1
  30. data/lib/elasticsearch/api/actions/cluster/delete_component_template.rb +1 -5
  31. data/lib/elasticsearch/api/actions/cluster/delete_voting_config_exclusions.rb +1 -1
  32. data/lib/elasticsearch/api/actions/cluster/exists_component_template.rb +2 -5
  33. data/lib/elasticsearch/api/actions/cluster/get_component_template.rb +1 -5
  34. data/lib/elasticsearch/api/actions/cluster/get_settings.rb +1 -1
  35. data/lib/elasticsearch/api/actions/cluster/health.rb +1 -1
  36. data/lib/elasticsearch/api/actions/cluster/pending_tasks.rb +1 -1
  37. data/lib/elasticsearch/api/actions/cluster/post_voting_config_exclusions.rb +1 -1
  38. data/lib/elasticsearch/api/actions/cluster/put_component_template.rb +1 -5
  39. data/lib/elasticsearch/api/actions/cluster/put_settings.rb +1 -1
  40. data/lib/elasticsearch/api/actions/cluster/remote_info.rb +1 -1
  41. data/lib/elasticsearch/api/actions/cluster/reroute.rb +1 -1
  42. data/lib/elasticsearch/api/actions/cluster/state.rb +1 -1
  43. data/lib/elasticsearch/api/actions/cluster/stats.rb +1 -1
  44. data/lib/elasticsearch/api/actions/count.rb +1 -1
  45. data/lib/elasticsearch/api/actions/create.rb +1 -1
  46. data/lib/elasticsearch/api/actions/dangling_indices/delete_dangling_index.rb +1 -1
  47. data/lib/elasticsearch/api/actions/dangling_indices/import_dangling_index.rb +1 -1
  48. data/lib/elasticsearch/api/actions/dangling_indices/list_dangling_indices.rb +1 -1
  49. data/lib/elasticsearch/api/actions/delete.rb +1 -1
  50. data/lib/elasticsearch/api/actions/delete_by_query.rb +1 -1
  51. data/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb +1 -1
  52. data/lib/elasticsearch/api/actions/delete_script.rb +1 -1
  53. data/lib/elasticsearch/api/actions/exists.rb +2 -1
  54. data/lib/elasticsearch/api/actions/exists_source.rb +2 -1
  55. data/lib/elasticsearch/api/actions/explain.rb +6 -6
  56. data/lib/elasticsearch/api/actions/features/get_features.rb +51 -0
  57. data/lib/elasticsearch/api/actions/features/params_registry.rb +60 -0
  58. data/lib/elasticsearch/api/actions/features/reset_features.rb +47 -0
  59. data/lib/elasticsearch/api/actions/field_caps.rb +6 -6
  60. data/lib/elasticsearch/api/actions/get.rb +1 -1
  61. data/lib/elasticsearch/api/actions/get_script.rb +1 -1
  62. data/lib/elasticsearch/api/actions/get_script_context.rb +1 -1
  63. data/lib/elasticsearch/api/actions/get_script_languages.rb +1 -1
  64. data/lib/elasticsearch/api/actions/get_source.rb +1 -1
  65. data/lib/elasticsearch/api/actions/index.rb +4 -2
  66. data/lib/elasticsearch/api/actions/indices/add_block.rb +1 -1
  67. data/lib/elasticsearch/api/actions/indices/analyze.rb +6 -7
  68. data/lib/elasticsearch/api/actions/indices/clear_cache.rb +1 -2
  69. data/lib/elasticsearch/api/actions/indices/clone.rb +1 -1
  70. data/lib/elasticsearch/api/actions/indices/close.rb +2 -2
  71. data/lib/elasticsearch/api/actions/indices/create.rb +1 -1
  72. data/lib/elasticsearch/api/actions/indices/delete.rb +1 -1
  73. data/lib/elasticsearch/api/actions/indices/delete_alias.rb +1 -1
  74. data/lib/elasticsearch/api/actions/indices/delete_index_template.rb +1 -5
  75. data/lib/elasticsearch/api/actions/indices/delete_template.rb +1 -1
  76. data/lib/elasticsearch/api/actions/indices/exists.rb +2 -1
  77. data/lib/elasticsearch/api/actions/indices/exists_alias.rb +2 -1
  78. data/lib/elasticsearch/api/actions/indices/exists_index_template.rb +2 -5
  79. data/lib/elasticsearch/api/actions/indices/exists_template.rb +2 -1
  80. data/lib/elasticsearch/api/actions/indices/exists_type.rb +2 -1
  81. data/lib/elasticsearch/api/actions/indices/flush.rb +1 -1
  82. data/lib/elasticsearch/api/actions/indices/flush_synced.rb +6 -1
  83. data/lib/elasticsearch/api/actions/indices/forcemerge.rb +1 -1
  84. data/lib/elasticsearch/api/actions/indices/get.rb +1 -1
  85. data/lib/elasticsearch/api/actions/indices/get_alias.rb +1 -1
  86. data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +1 -1
  87. data/lib/elasticsearch/api/actions/indices/get_index_template.rb +1 -5
  88. data/lib/elasticsearch/api/actions/indices/get_mapping.rb +1 -1
  89. data/lib/elasticsearch/api/actions/indices/get_settings.rb +1 -1
  90. data/lib/elasticsearch/api/actions/indices/get_template.rb +1 -1
  91. data/lib/elasticsearch/api/actions/indices/get_upgrade.rb +7 -2
  92. data/lib/elasticsearch/api/actions/indices/open.rb +1 -1
  93. data/lib/elasticsearch/api/actions/indices/put_alias.rb +1 -1
  94. data/lib/elasticsearch/api/actions/indices/put_index_template.rb +1 -5
  95. data/lib/elasticsearch/api/actions/indices/put_mapping.rb +1 -1
  96. data/lib/elasticsearch/api/actions/indices/put_settings.rb +1 -1
  97. data/lib/elasticsearch/api/actions/indices/put_template.rb +1 -1
  98. data/lib/elasticsearch/api/actions/indices/recovery.rb +1 -1
  99. data/lib/elasticsearch/api/actions/indices/refresh.rb +1 -1
  100. data/lib/elasticsearch/api/actions/indices/resolve_index.rb +1 -1
  101. data/lib/elasticsearch/api/actions/indices/rollover.rb +1 -1
  102. data/lib/elasticsearch/api/actions/indices/segments.rb +1 -1
  103. data/lib/elasticsearch/api/actions/indices/shard_stores.rb +1 -1
  104. data/lib/elasticsearch/api/actions/indices/shrink.rb +1 -1
  105. data/lib/elasticsearch/api/actions/indices/simulate_index_template.rb +1 -5
  106. data/lib/elasticsearch/api/actions/indices/simulate_template.rb +1 -5
  107. data/lib/elasticsearch/api/actions/indices/split.rb +1 -1
  108. data/lib/elasticsearch/api/actions/indices/stats.rb +1 -1
  109. data/lib/elasticsearch/api/actions/indices/update_aliases.rb +1 -1
  110. data/lib/elasticsearch/api/actions/indices/upgrade.rb +7 -2
  111. data/lib/elasticsearch/api/actions/indices/validate_query.rb +8 -8
  112. data/lib/elasticsearch/api/actions/info.rb +1 -1
  113. data/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb +1 -1
  114. data/lib/elasticsearch/api/actions/ingest/geo_ip_stats.rb +43 -0
  115. data/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +3 -1
  116. data/lib/elasticsearch/api/actions/ingest/processor_grok.rb +1 -1
  117. data/lib/elasticsearch/api/actions/ingest/put_pipeline.rb +1 -1
  118. data/lib/elasticsearch/api/actions/ingest/simulate.rb +1 -1
  119. data/lib/elasticsearch/api/actions/mget.rb +1 -1
  120. data/lib/elasticsearch/api/actions/msearch.rb +4 -6
  121. data/lib/elasticsearch/api/actions/msearch_template.rb +2 -2
  122. data/lib/elasticsearch/api/actions/mtermvectors.rb +8 -8
  123. data/lib/elasticsearch/api/actions/nodes/hot_threads.rb +1 -1
  124. data/lib/elasticsearch/api/actions/nodes/info.rb +1 -1
  125. data/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb +1 -1
  126. data/lib/elasticsearch/api/actions/nodes/stats.rb +4 -2
  127. data/lib/elasticsearch/api/actions/nodes/usage.rb +1 -1
  128. data/lib/elasticsearch/api/actions/open_point_in_time.rb +64 -0
  129. data/lib/elasticsearch/api/actions/ping.rb +3 -3
  130. data/lib/elasticsearch/api/actions/put_script.rb +1 -2
  131. data/lib/elasticsearch/api/actions/rank_eval.rb +1 -1
  132. data/lib/elasticsearch/api/actions/reindex.rb +1 -1
  133. data/lib/elasticsearch/api/actions/reindex_rethrottle.rb +1 -1
  134. data/lib/elasticsearch/api/actions/render_search_template.rb +6 -6
  135. data/lib/elasticsearch/api/actions/scripts_painless_execute.rb +2 -2
  136. data/lib/elasticsearch/api/actions/scroll.rb +6 -7
  137. data/lib/elasticsearch/api/actions/search.rb +11 -9
  138. data/lib/elasticsearch/api/actions/search_shards.rb +1 -1
  139. data/lib/elasticsearch/api/actions/search_template.rb +2 -2
  140. data/lib/elasticsearch/api/actions/shutdown/delete_node.rb +52 -0
  141. data/lib/elasticsearch/api/actions/shutdown/get_node.rb +54 -0
  142. data/lib/elasticsearch/api/actions/shutdown/params_registry.rb +60 -0
  143. data/lib/elasticsearch/api/actions/shutdown/put_node.rb +54 -0
  144. data/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb +1 -1
  145. data/lib/elasticsearch/api/actions/snapshot/clone.rb +66 -0
  146. data/lib/elasticsearch/api/actions/snapshot/create.rb +1 -1
  147. data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +1 -1
  148. data/lib/elasticsearch/api/actions/snapshot/delete.rb +1 -1
  149. data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +1 -1
  150. data/lib/elasticsearch/api/actions/snapshot/get.rb +5 -1
  151. data/lib/elasticsearch/api/actions/snapshot/get_features.rb +51 -0
  152. data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +1 -1
  153. data/lib/elasticsearch/api/actions/snapshot/repository_analyze.rb +76 -0
  154. data/lib/elasticsearch/api/actions/snapshot/restore.rb +1 -1
  155. data/lib/elasticsearch/api/actions/snapshot/status.rb +1 -1
  156. data/lib/elasticsearch/api/actions/snapshot/verify_repository.rb +1 -1
  157. data/lib/elasticsearch/api/actions/tasks/cancel.rb +5 -1
  158. data/lib/elasticsearch/api/actions/tasks/get.rb +5 -1
  159. data/lib/elasticsearch/api/actions/tasks/list.rb +5 -1
  160. data/lib/elasticsearch/api/actions/termvectors.rb +11 -10
  161. data/lib/elasticsearch/api/actions/update.rb +4 -2
  162. data/lib/elasticsearch/api/actions/update_by_query.rb +1 -1
  163. data/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb +1 -1
  164. data/lib/elasticsearch/api/namespace/features.rb +36 -0
  165. data/lib/elasticsearch/api/namespace/security.rb +36 -0
  166. data/lib/elasticsearch/api/namespace/shutdown.rb +37 -0
  167. data/lib/elasticsearch/api/version.rb +1 -1
  168. data/lib/elasticsearch/api.rb +3 -1
  169. data/spec/elasticsearch/api/actions/close_point_in_time_spec.rb +34 -0
  170. data/spec/elasticsearch/api/actions/features/get_features_spec.rb +34 -0
  171. data/spec/elasticsearch/api/actions/features/reset_features_spec.rb +34 -0
  172. data/spec/elasticsearch/api/actions/indices/clear_cache_spec.rb +16 -3
  173. data/spec/elasticsearch/api/actions/ingest/geo_ip_stats_spec.rb +34 -0
  174. data/spec/elasticsearch/api/actions/msearch_spec.rb +16 -33
  175. data/spec/elasticsearch/api/actions/open_point_in_time_spec.rb +44 -0
  176. data/spec/elasticsearch/api/actions/shutdown/delete_node_spec.rb +44 -0
  177. data/spec/elasticsearch/api/actions/{indices/freeze_spec.rb → shutdown/get_node_spec.rb} +12 -51
  178. data/spec/elasticsearch/api/actions/shutdown/put_node_spec.rb +50 -0
  179. data/spec/elasticsearch/api/actions/snapshot/clone_spec.rb +67 -0
  180. data/spec/elasticsearch/api/actions/snapshot/get_features_spec.rb +38 -0
  181. data/spec/elasticsearch/api/actions/snapshot/repository_analize_spec.rb +48 -0
  182. data/spec/elasticsearch/api/rest_api_yaml_spec.rb +36 -9
  183. data/spec/rest_yaml_tests_helper.rb +25 -52
  184. data/spec/skipped_tests.yml +29 -0
  185. data/spec/spec_helper.rb +4 -1
  186. data/utils/Gemfile +4 -3
  187. data/utils/README.md +6 -1
  188. data/utils/thor/generate_source.rb +1 -2
  189. data/utils/thor/generator/endpoint_specifics.rb +6 -2
  190. data/utils/thor/generator/files_helper.rb +38 -20
  191. data/utils/thor/templates/_documentation_top.erb +20 -1
  192. data/utils/thor/templates/_method_setup.erb +18 -0
  193. data/utils/thor/templates/_params_registry.erb +19 -0
  194. data/utils/thor/templates/_perform_request.erb +19 -1
  195. data/utils/thor/templates/test.erb +16 -3
  196. data/utils/thor/templates/test_helper.rb +0 -4
  197. metadata +46 -46
  198. data/lib/elasticsearch/api/actions/indices/freeze.rb +0 -56
  199. data/lib/elasticsearch/api/actions/indices/unfreeze.rb +0 -56
  200. data/spec/elasticsearch/api/actions/indices/unfreeze_spec.rb +0 -85
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9b4c908b611c1f11f33677f31e23ab069a27a53e7b7c8765e05371c0a3b45f4e
4
- data.tar.gz: 4ce4bb9d09c4a5010390a768a1c3c1d493c69891f4ede0e45ebebae5dc087e1d
3
+ metadata.gz: f73d95469f7d334ef8293085aee0d220b42666ca60d0cc26a5d47fea6eb7ad4c
4
+ data.tar.gz: 39ffe6b84ef28a675f92332840d56fda4a568eab8d65b450ac14c0eb7a34b2c2
5
5
  SHA512:
6
- metadata.gz: 1b55dff1575e13a0d591276fc46ba2b5a1ab2d280cd234f67d4c6751d943043594de70831cd264beb9072b3c6a0fde26646bd7175d77486ef0906450463b474c
7
- data.tar.gz: 8a69c31d352a5de8186394cf79b1fc608f80d915bdddffeffac039eaf2aaefe6ab36e4ad315723cfb19a31f4a7201c3ac30ae13a66feaa0ebb7ef1d6b39f6ed5
6
+ metadata.gz: 81452e679f37809e048ec484144bc9665e63a66593637c718e1c0eaebd855710710254df91e47cf9adc4e4f2ee0200fa7bf50d682546c87c80b0f76e92222f05
7
+ data.tar.gz: 044f100c6178945025e5579f4ac7c65c31533bd55bb8b2dd55caf86e183ce388de39f0136665ccaffcb66d7506eccbce87e596a790e3beabe96c870f76712715
data/Gemfile CHANGED
@@ -20,14 +20,14 @@ source 'https://rubygems.org'
20
20
  # Specify your gem's dependencies in elasticsearch-api.gemspec
21
21
  gemspec
22
22
 
23
- if File.exist? File.expand_path("../../elasticsearch/elasticsearch.gemspec", __FILE__)
24
- gem 'elasticsearch', path: File.expand_path("../../elasticsearch", __FILE__), require: false
25
- end
26
-
27
23
  if File.exist? File.expand_path("../../elasticsearch-transport", __FILE__)
28
24
  gem 'elasticsearch-transport', path: File.expand_path("../../elasticsearch-transport", __FILE__), require: true
29
25
  end
30
26
 
27
+ if File.exist? File.expand_path("../../elasticsearch/elasticsearch.gemspec", __FILE__)
28
+ gem 'elasticsearch', path: File.expand_path("../../elasticsearch", __FILE__), require: false
29
+ end
30
+
31
31
  if File.exist? File.expand_path("../../elasticsearch-extensions", __FILE__)
32
32
  gem 'elasticsearch-extensions', path: File.expand_path("../../elasticsearch-extensions", __FILE__), require: false
33
33
  end
data/README.md CHANGED
@@ -13,8 +13,7 @@ It does not provide an Elasticsearch client; see the
13
13
 
14
14
  The library is compatible with Ruby 1.9 and higher.
15
15
 
16
- It is compatible with Elasticsearch's API versions from 0.90 till current,
17
- just use a release matching major version of Elasticsearch.
16
+ It is compatible with Elasticsearch's API versions from 0.90 till current, just use a release matching major version of Elasticsearch.
18
17
 
19
18
  | Ruby | | Elasticsearch |
20
19
  |:-------------:|:-:| :-----------: |
@@ -56,12 +55,12 @@ the library modules have been already included**, so you just call the API metho
56
55
  ```ruby
57
56
  require 'elasticsearch'
58
57
 
59
- client = Elasticsearch::Client.new log: true
58
+ client = Elasticsearch::Client.new(log: true)
60
59
 
61
- client.index index: 'myindex', type: 'mytype', id: 1, body: { title: 'Test' }
60
+ client.index(index: 'myindex', type: 'mytype', id: 1, body: { title: 'Test' })
62
61
  # => {"_index"=>"myindex", ... "created"=>true}
63
62
 
64
- client.search index: 'myindex', body: { query: { match: { title: 'test' } } }
63
+ client.search(index: 'myindex', body: { query: { match: { title: 'test' } } })
65
64
  # => {"took"=>2, ..., "hits"=>{"total":5, ...}}
66
65
  ```
67
66
 
@@ -75,12 +74,13 @@ When you want to mix the library into your own client, it must conform to a foll
75
74
  * It responds to a `perform_request(method, path, params, body, headers)` method,
76
75
  * the method returns an object with `status`, `body` and `headers` methods.
77
76
 
78
- A simple client could look like this:
77
+ A simple client could look like this (_with a dependency on `active_support` to parse the query params_):
79
78
 
80
79
  ```ruby
81
80
  require 'multi_json'
82
81
  require 'faraday'
83
82
  require 'elasticsearch/api'
83
+ require 'active_support'
84
84
 
85
85
  class MySimpleClient
86
86
  include Elasticsearch::API
@@ -92,10 +92,25 @@ class MySimpleClient
92
92
 
93
93
  CONNECTION.run_request \
94
94
  method.downcase.to_sym,
95
- path,
95
+ path_with_params(path, params),
96
96
  ( body ? MultiJson.dump(body): nil ),
97
97
  {'Content-Type' => 'application/json'}
98
98
  end
99
+
100
+ private
101
+
102
+ def path_with_params(path, params)
103
+ return path if params.blank?
104
+
105
+ case params
106
+ when String
107
+ "#{path}?#{params}"
108
+ when Hash
109
+ "#{path}?#{params.to_query}"
110
+ else
111
+ raise ArgumentError, "Cannot parse params: '#{params}'"
112
+ end
113
+ end
99
114
  end
100
115
 
101
116
  client = MySimpleClient.new
@@ -174,19 +189,18 @@ Elasticsearch::API.serializer.dump({foo: 'bar'})
174
189
 
175
190
  ## Development
176
191
 
177
- To work on the code, clone and bootstrap the main repository first --
178
- please see instructions in the main [README](../README.md#development).
192
+ To work on the code, clone and bootstrap the main repository first -- please see instructions in the main [README](../README.md#development).
179
193
 
180
- To run tests, launch a testing cluster -- again, see instructions
181
- in the main [README](../README.md#development) -- and use the Rake tasks:
194
+ To run tests, launch a testing cluster -- again, see instructions in the main [README](../README.md#development) -- and use the Rake tasks:
182
195
 
183
196
  ```
184
197
  time rake test:unit
185
198
  time rake test:integration
186
199
  ```
187
200
 
188
- Unit tests have to use Ruby 1.8 compatible syntax, integration tests
189
- can use Ruby 2.x syntax and features.
201
+ We run the test suite for Elasticsearch's Rest API tests. You can read more about this in [the test runner README](https://github.com/elastic/elasticsearch-ruby/tree/master/api-spec-testing#rest-api-yaml-test-runner).
202
+
203
+ The `rest_api` needs the test files from Elasticsearch. You can run the rake task to download the test artifacts in the root folder of the project. This task needs a running cluster to determine which version and build hash of Elasticsearch to use and test against. `TEST_ES_SERVER=http://localhost:9200 rake elasticsearch:download_artifacts`. This will download the necessary files used for the integration tests to `./tmp`.
190
204
 
191
205
  ## License
192
206
 
data/Rakefile CHANGED
@@ -16,14 +16,7 @@
16
16
  # under the License.
17
17
 
18
18
  require 'bundler/gem_tasks'
19
-
20
- def __current__
21
- Pathname( File.expand_path('..', __FILE__) )
22
- end
23
-
24
- def git_specs(command, options={})
25
- sh "git --git-dir=#{__current__.join('../tmp/elasticsearch/.git')} --work-tree=#{__current__.join('../tmp/elasticsearch')} #{command}", options
26
- end
19
+ require 'json'
27
20
 
28
21
  task(:default) { system 'rake --tasks' }
29
22
  task test: 'test:unit'
@@ -46,73 +39,28 @@ namespace :test do
46
39
  t.exclude_pattern = 'spec/**{,/*/**}/rest_api_yaml_spec.rb'
47
40
  end
48
41
 
49
- # Rest API Spec tests - rake test:rest_api
42
+ desc "Run Rest API Spec tests"
50
43
  RSpec::Core::RakeTask.new(:rest_api) do |t|
51
- t.pattern = 'spec/**{,/*/**}/rest_api_yaml_spec.rb'
52
- end
53
-
54
- desc 'Update the repository with YAML tests'
55
- task :update do
56
- git_specs 'fetch origin', verbose: true
57
- end
58
-
59
- desc "Run integration tests"
60
- task integration: :update do
61
44
  require 'elasticsearch'
62
-
63
- branches = `git --git-dir=#{__current__.join('../tmp/elasticsearch/.git')} --work-tree=#{__current__.join('../tmp/elasticsearch')} branch --no-color`
64
-
65
- current_branch = branches.
66
- split("\n").
67
- select { |b| b =~ /^\*/ }.
68
- reject { |b| b =~ /no branch|detached/ }.
69
- map { |b| b.gsub(/^\*\s*/, '') }.
70
- first
71
-
72
- unless current_branch
73
- STDERR.puts "[!] Unable to determine current branch, defaulting to 'master'"
74
- current_branch = 'master'
75
- end
76
-
77
45
  # Check if a test cluster is running
78
46
  begin
79
47
  url = ENV['TEST_CLUSTER_URL'] || ENV['TEST_ES_SERVER']
80
- url = "http://localhost:#{ENV['TEST_CLUSTER_PORT'] || 9250}" unless url
48
+ url = "http://localhost:#{ENV['TEST_CLUSTER_PORT'] || 9200}" unless url
81
49
  client = Elasticsearch::Client.new :url => url
82
50
  es_version_info = client.info['version']
51
+ version_number = es_version_info['number']
83
52
  build_hash = es_version_info['build_hash']
84
- cluster_running = true
85
53
  rescue Faraday::ConnectionFailed
86
54
  STDERR.puts "[!] Test cluster not running?"
87
- cluster_running = false
55
+ exit 1
88
56
  end
89
57
 
90
- checkout_specs_version = ENV['TEST_NO_CHECKOUT'].nil? ? true : false
91
- checkout_build_hash = ENV['TEST_BUILD_REF'] || build_hash
92
- ENV['TEST_BUILD_REF'] = checkout_build_hash
58
+ t.pattern = 'spec/**{,/*/**}/rest_api_yaml_spec.rb'
59
+ end
93
60
 
94
- begin
95
- unless checkout_specs_version
96
- STDERR.puts '-'*80, "YAML tests: Not switching, TEST_NO_CHECKOUT=y", '-'*80
97
- end
98
-
99
- if checkout_specs_version && !checkout_build_hash
100
- STDERR.puts "[!] Cannot determine checkout build hash -- server not running or TEST_BUILD_REF not specified"
101
- exit(1)
102
- end
103
-
104
- if checkout_specs_version && checkout_build_hash
105
- # Checkout the commit corresponding to the running server build, or passed TEST_BUILD_REF
106
- name = ENV['CI'] ? checkout_build_hash : "[\e[1m#{checkout_build_hash}\e[0m]"
107
- STDERR.puts '-'*80, "YAML tests: Switching to #{name} from #{current_branch}", '-'*80
108
- git_specs "checkout #{checkout_build_hash} --force --quiet"
109
- end
110
-
111
- Rake::Task['test:rest_api'].invoke
112
-
113
- ensure
114
- git_specs "checkout #{current_branch} --force --quiet" if checkout_specs_version && current_branch
115
- end
61
+ desc "Run integration tests"
62
+ task :integration do
63
+ Rake::Task['test:rest_api'].invoke
116
64
  end
117
65
 
118
66
  desc 'Run unit and integration tests'
@@ -121,6 +69,42 @@ namespace :test do
121
69
  Rake::Task['test:integration'].invoke
122
70
  end
123
71
 
72
+ def refresh_artifacts(build_hash, version_number)
73
+ unless build_hash
74
+ STDERR.puts "[!] Cannot determine checkout build hash -- server not running"
75
+ exit(1)
76
+ end
77
+
78
+ puts 'Downloading artifacts file...'
79
+ filename = 'tmp/artifacts.json'
80
+ `curl -s https://artifacts-api.elastic.co/v1/versions/#{version_number} -o #{filename}`
81
+
82
+ unless File.exists?("./#{filename}")
83
+ STDERR.puts '[!] Couldn\'t download artifacts file'
84
+ exit 1
85
+ end
86
+
87
+ artifacts = JSON.parse(File.read('./tmp/artifacts.json'))
88
+
89
+ build_hash_artifact = artifacts['version']['builds'].select do |a|
90
+ a.dig('projects', 'elasticsearch', 'commit_hash') == build_hash
91
+ end.first
92
+ # Dig into the elasticsearch packages, search for the rest-resources-zip package and catch the URL:
93
+ zip_url = build_hash_artifact.dig('projects', 'elasticsearch', 'packages').select { |k,v| k =~ /rest-resources-zip/ }.map { | _, v| v['url'] }.first
94
+
95
+ filename = zip_url.split('/').last
96
+ puts 'Downloading zip file:'
97
+ `curl -s #{zip_url} -o tmp/#{filename}`
98
+
99
+ unless File.exists?("./tmp/#{filename}")
100
+ STDERR.puts '[!] Couldn\'t download artifact'
101
+ exit 1
102
+ end
103
+
104
+ puts "Unzipping file #{filename}"
105
+ `unzip -o tmp/#{filename} -d tmp/`
106
+ end
107
+
124
108
  namespace :cluster do
125
109
  desc "Start Elasticsearch nodes for tests"
126
110
  task :start do
@@ -49,13 +49,12 @@ Gem::Specification.new do |s|
49
49
  s.add_development_dependency 'ansi'
50
50
  s.add_development_dependency 'bundler'
51
51
  s.add_development_dependency 'elasticsearch'
52
- s.add_development_dependency 'elasticsearch-extensions'
53
52
  s.add_development_dependency 'elasticsearch-transport'
54
53
  s.add_development_dependency 'minitest'
55
54
  s.add_development_dependency 'minitest-reporters'
56
55
  s.add_development_dependency 'mocha'
57
56
  s.add_development_dependency 'pry'
58
- s.add_development_dependency 'rake', '~> 11.1'
57
+ s.add_development_dependency 'rake', '~> 13'
59
58
  s.add_development_dependency 'shoulda-context'
60
59
  s.add_development_dependency 'yard'
61
60
 
@@ -67,8 +66,7 @@ Gem::Specification.new do |s|
67
66
  s.add_development_dependency 'escape_utils' unless defined? JRUBY_VERSION
68
67
  s.add_development_dependency 'jbuilder'
69
68
  s.add_development_dependency 'require-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
70
- s.add_development_dependency 'simplecov', '~> 0.17', '< 0.18'
71
- s.add_development_dependency 'simplecov-rcov'
69
+ s.add_development_dependency 'simplecov'
72
70
  s.add_development_dependency 'test-unit', '~> 2'
73
71
  s.add_development_dependency 'ruby-prof' unless defined?(JRUBY_VERSION) || defined?(Rubinius)
74
72
 
@@ -26,16 +26,16 @@ module Elasticsearch
26
26
  # @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. (options: true, false, wait_for)
27
27
  # @option arguments [String] :routing Specific routing value
28
28
  # @option arguments [Time] :timeout Explicit operation timeout
29
- # @option arguments [String] :type Default document type for items which don't provide one
30
29
  # @option arguments [List] :_source True or false to return the _source field or not, or default list of fields to return, can be overridden on each sub-request
31
30
  # @option arguments [List] :_source_excludes Default list of fields to exclude from the returned _source field, can be overridden on each sub-request
32
31
  # @option arguments [List] :_source_includes Default list of fields to extract and return from the _source field, can be overridden on each sub-request
33
32
  # @option arguments [String] :pipeline The pipeline id to preprocess incoming documents with
33
+ # @option arguments [Boolean] :require_alias Sets require_alias for all incoming documents. Defaults to unset (false)
34
34
  # @option arguments [Hash] :headers Custom HTTP headers
35
35
  # @option arguments [String|Array] :body The operation definition and data (action-data pairs), separated by newlines. Array of Strings, Header/Data pairs,
36
36
  # or the conveniency "combined" format can be passed, refer to Elasticsearch::API::Utils.__bulkify documentation.
37
37
  #
38
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.9/docs-bulk.html
38
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.14/docs-bulk.html
39
39
  #
40
40
  def bulk(arguments = {})
41
41
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
@@ -81,7 +81,8 @@ module Elasticsearch
81
81
  :_source,
82
82
  :_source_excludes,
83
83
  :_source_includes,
84
- :pipeline
84
+ :pipeline,
85
+ :require_alias
85
86
  ].freeze)
86
87
  end
87
88
  end
@@ -31,7 +31,7 @@ module Elasticsearch
31
31
  # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
32
32
  # @option arguments [Hash] :headers Custom HTTP headers
33
33
  #
34
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.9/cat-alias.html
34
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.14/cat-alias.html
35
35
  #
36
36
  def aliases(arguments = {})
37
37
  headers = arguments.delete(:headers) || {}
@@ -32,7 +32,7 @@ module Elasticsearch
32
32
  # @option arguments [Boolean] :v Verbose mode. Display column headers
33
33
  # @option arguments [Hash] :headers Custom HTTP headers
34
34
  #
35
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.9/cat-allocation.html
35
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.14/cat-allocation.html
36
36
  #
37
37
  def allocation(arguments = {})
38
38
  headers = arguments.delete(:headers) || {}
@@ -29,7 +29,7 @@ module Elasticsearch
29
29
  # @option arguments [Boolean] :v Verbose mode. Display column headers
30
30
  # @option arguments [Hash] :headers Custom HTTP headers
31
31
  #
32
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.9/cat-count.html
32
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.14/cat-count.html
33
33
  #
34
34
  def count(arguments = {})
35
35
  headers = arguments.delete(:headers) || {}
@@ -28,10 +28,9 @@ module Elasticsearch
28
28
  # @option arguments [Boolean] :help Return help information
29
29
  # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
30
30
  # @option arguments [Boolean] :v Verbose mode. Display column headers
31
- # @option arguments [List] :fields A comma-separated list of fields to return in the output
32
31
  # @option arguments [Hash] :headers Custom HTTP headers
33
32
  #
34
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.9/cat-fielddata.html
33
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.14/cat-fielddata.html
35
34
  #
36
35
  def fielddata(arguments = {})
37
36
  headers = arguments.delete(:headers) || {}
@@ -30,7 +30,7 @@ module Elasticsearch
30
30
  # @option arguments [Boolean] :v Verbose mode. Display column headers
31
31
  # @option arguments [Hash] :headers Custom HTTP headers
32
32
  #
33
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.9/cat-health.html
33
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.14/cat-health.html
34
34
  #
35
35
  def health(arguments = {})
36
36
  headers = arguments.delete(:headers) || {}
@@ -25,7 +25,7 @@ module Elasticsearch
25
25
  # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
26
26
  # @option arguments [Hash] :headers Custom HTTP headers
27
27
  #
28
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.9/cat.html
28
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.14/cat.html
29
29
  #
30
30
  def help(arguments = {})
31
31
  headers = arguments.delete(:headers) || {}
@@ -24,7 +24,7 @@ module Elasticsearch
24
24
  # @option arguments [List] :index A comma-separated list of index names to limit the returned information
25
25
  # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml
26
26
  # @option arguments [String] :bytes The unit in which to display byte values (options: b, k, kb, m, mb, g, gb, t, tb, p, pb)
27
- # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false)
27
+ # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false) *Deprecated*
28
28
  # @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
29
29
  # @option arguments [List] :h Comma-separated list of column names to display
30
30
  # @option arguments [String] :health A health status ("green", "yellow", or "red" to filter only indices matching the specified health status (options: green, yellow, red)
@@ -37,7 +37,7 @@ module Elasticsearch
37
37
  # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
38
38
  # @option arguments [Hash] :headers Custom HTTP headers
39
39
  #
40
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.9/cat-indices.html
40
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.14/cat-indices.html
41
41
  #
42
42
  def indices(arguments = {})
43
43
  headers = arguments.delete(:headers) || {}
@@ -30,7 +30,7 @@ module Elasticsearch
30
30
  # @option arguments [Boolean] :v Verbose mode. Display column headers
31
31
  # @option arguments [Hash] :headers Custom HTTP headers
32
32
  #
33
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.9/cat-master.html
33
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.14/cat-master.html
34
34
  #
35
35
  def master(arguments = {})
36
36
  headers = arguments.delete(:headers) || {}
@@ -30,7 +30,7 @@ module Elasticsearch
30
30
  # @option arguments [Boolean] :v Verbose mode. Display column headers
31
31
  # @option arguments [Hash] :headers Custom HTTP headers
32
32
  #
33
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.9/cat-nodeattrs.html
33
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.14/cat-nodeattrs.html
34
34
  #
35
35
  def nodeattrs(arguments = {})
36
36
  headers = arguments.delete(:headers) || {}
@@ -31,9 +31,10 @@ module Elasticsearch
31
31
  # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
32
32
  # @option arguments [String] :time The unit in which to display time values (options: d, h, m, s, ms, micros, nanos)
33
33
  # @option arguments [Boolean] :v Verbose mode. Display column headers
34
+ # @option arguments [Boolean] :include_unloaded_segments If set to true segment stats will include stats for segments that are not currently loaded into memory
34
35
  # @option arguments [Hash] :headers Custom HTTP headers
35
36
  #
36
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.9/cat-nodes.html
37
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.14/cat-nodes.html
37
38
  #
38
39
  def nodes(arguments = {})
39
40
  headers = arguments.delete(:headers) || {}
@@ -62,7 +63,8 @@ module Elasticsearch
62
63
  :help,
63
64
  :s,
64
65
  :time,
65
- :v
66
+ :v,
67
+ :include_unloaded_segments
66
68
  ].freeze)
67
69
  end
68
70
  end
@@ -31,7 +31,7 @@ module Elasticsearch
31
31
  # @option arguments [Boolean] :v Verbose mode. Display column headers
32
32
  # @option arguments [Hash] :headers Custom HTTP headers
33
33
  #
34
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.9/cat-pending-tasks.html
34
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.14/cat-pending-tasks.html
35
35
  #
36
36
  def pending_tasks(arguments = {})
37
37
  headers = arguments.delete(:headers) || {}