elasticsearch-api 7.3.0 → 7.5.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 (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
@@ -8,16 +8,16 @@ describe 'client.cat#segments' do
8
8
 
9
9
  let(:expected_args) do
10
10
  [
11
- 'GET',
12
- '_cat/segments',
13
- params,
14
- nil,
15
- nil
11
+ 'GET',
12
+ url,
13
+ {},
14
+ nil,
15
+ nil
16
16
  ]
17
17
  end
18
18
 
19
- let(:params) do
20
- {}
19
+ let(:url) do
20
+ '_cat/segments'
21
21
  end
22
22
 
23
23
  it 'performs the request' do
@@ -25,10 +25,8 @@ describe 'client.cat#segments' do
25
25
  end
26
26
 
27
27
  context 'when index is specified' do
28
-
29
-
30
- let(:params) do
31
- { index: 'foo' }
28
+ let(:url) do
29
+ '_cat/segments/foo'
32
30
  end
33
31
 
34
32
  it 'performs the request' do
@@ -17,6 +17,6 @@ describe 'client.cluster#put_settings' do
17
17
  end
18
18
 
19
19
  it 'performs the request' do
20
- expect(client_double.cluster.put_settings).to eq({})
20
+ expect(client_double.cluster.put_settings(body: {})).to eq({})
21
21
  end
22
22
  end
@@ -23,10 +23,10 @@ describe 'client#count' do
23
23
 
24
24
  let(:expected_args) do
25
25
  [
26
- 'GET',
27
- 'foo,bar/t1,t2/_count',
28
- {},
29
- nil
26
+ 'GET',
27
+ 'foo,bar/t1,t2/_count',
28
+ {},
29
+ nil
30
30
  ]
31
31
  end
32
32
 
@@ -39,10 +39,10 @@ describe 'client#count' do
39
39
 
40
40
  let(:expected_args) do
41
41
  [
42
- 'GET',
43
- '_count',
44
- {},
45
- { match: { foo: 'bar' } }
42
+ 'POST',
43
+ '_count',
44
+ {},
45
+ { match: { foo: 'bar' } }
46
46
  ]
47
47
  end
48
48
 
@@ -8,10 +8,10 @@ describe 'client#delete_by_query' do
8
8
 
9
9
  let(:expected_args) do
10
10
  [
11
- 'POST',
12
- 'foo/_delete_by_query',
13
- {},
14
- { term: {} }
11
+ 'POST',
12
+ 'foo/_delete_by_query',
13
+ {},
14
+ { term: {} }
15
15
  ]
16
16
  end
17
17
 
@@ -42,18 +42,23 @@ describe 'client#delete_by_query' do
42
42
  end
43
43
 
44
44
  context 'when a query is provided' do
45
-
46
45
  let(:expected_args) do
47
46
  [
48
47
  'POST',
49
48
  'foo/_delete_by_query',
50
49
  { q: 'foo:bar' },
51
- nil
50
+ { query: 'query' }
52
51
  ]
53
52
  end
54
53
 
55
54
  it 'performs the request' do
56
- expect(client_double.delete_by_query(index: 'foo', q: 'foo:bar')).to eq({})
55
+ expect(
56
+ client_double.delete_by_query(
57
+ index: 'foo',
58
+ q: 'foo:bar',
59
+ body: { query: 'query' }
60
+ )
61
+ ).to eq({})
57
62
  end
58
63
  end
59
64
  end
@@ -5,20 +5,6 @@
5
5
  require 'spec_helper'
6
6
 
7
7
  describe 'client#delete_script' do
8
-
9
- let(:expected_args) do
10
- [
11
- 'DELETE',
12
- '_scripts/groovy/foo',
13
- {},
14
- nil
15
- ]
16
- end
17
-
18
- it 'performs the request' do
19
- expect(client_double.delete_script(lang: 'groovy', id: 'foo')).to eq({})
20
- end
21
-
22
8
  context 'when lang parameter is not provided' do
23
9
 
24
10
  let(:expected_args) do
@@ -42,7 +42,7 @@ describe 'client#exists' do
42
42
  context 'when the type parameter is not provided' do
43
43
 
44
44
  let(:url) do
45
- 'foo/_all/1'
45
+ 'foo/_doc/1'
46
46
  end
47
47
 
48
48
  it 'performs the request' do
@@ -42,7 +42,7 @@ describe 'client#get_source' do
42
42
  context 'when the type parameter is not provided' do
43
43
 
44
44
  let(:url) do
45
- 'foo/_doc/1/_source'
45
+ 'foo/_source/1'
46
46
  end
47
47
 
48
48
  it 'performs the request' do
@@ -28,7 +28,7 @@ describe 'client#index' do
28
28
  end
29
29
 
30
30
  let(:body) do
31
- { :foo => 'bar' }
31
+ { foo: 'bar' }
32
32
  end
33
33
 
34
34
  let(:client) do
@@ -42,7 +42,7 @@ describe 'client#index' do
42
42
  end
43
43
 
44
44
  it 'performs the request' do
45
- expect(client_double.index(index: 'foo', type: 'bar', body: { foo: 'bar' })).to eq({})
45
+ expect(client_double.index(index: 'foo', type: 'bar', body: body)).to eq({})
46
46
  end
47
47
 
48
48
  context 'when a specific id is provided' do
@@ -56,7 +56,7 @@ describe 'client#index' do
56
56
  end
57
57
 
58
58
  it 'performs the request' do
59
- expect(client_double.index(index: 'foo', type: 'bar', id: '1', body: { foo: 'bar' })).to eq({})
59
+ expect(client_double.index(index: 'foo', type: 'bar', id: '1', body: body)).to eq({})
60
60
  end
61
61
  end
62
62
 
@@ -74,12 +74,8 @@ describe 'client#index' do
74
74
  { op_type: 'create' }
75
75
  end
76
76
 
77
- let(:body) do
78
- nil
79
- end
80
-
81
77
  it 'passes the URL params' do
82
- expect(client_double.index(index: 'foo', type: 'bar', op_type: 'create')).to eq({})
78
+ expect(client_double.index(index: 'foo', type: 'bar', op_type: 'create', body: body)).to eq({})
83
79
  end
84
80
 
85
81
  context 'when a specific id is provided' do
@@ -97,13 +93,12 @@ describe 'client#index' do
97
93
  end
98
94
 
99
95
  it 'passes the URL params' do
100
- expect(client_double.index(index: 'foo', type: 'bar', id: '1', op_type: 'create')).to eq({})
96
+ expect(client_double.index(index: 'foo', type: 'bar', id: '1', op_type: 'create', body: body)).to eq({})
101
97
  end
102
98
  end
103
99
  end
104
100
 
105
101
  context 'when the request needs to be URL-escaped' do
106
-
107
102
  let(:request_type) do
108
103
  'PUT'
109
104
  end
@@ -112,12 +107,8 @@ describe 'client#index' do
112
107
  'foo/bar%2Fbam/123'
113
108
  end
114
109
 
115
- let(:body) do
116
- nil
117
- end
118
-
119
110
  it 'URL-escapes the parts' do
120
- expect(client_double.index(index: 'foo', type: 'bar/bam', id: '123')).to eq({})
111
+ expect(client_double.index(index: 'foo', type: 'bar/bam', id: '123', body: body)).to eq({})
121
112
  end
122
113
  end
123
114
 
@@ -38,10 +38,6 @@ describe 'client.indices#analyze' do
38
38
  'foo/_analyze'
39
39
  end
40
40
 
41
- let(:params) do
42
- { index: 'foo' }
43
- end
44
-
45
41
  it 'performs the request' do
46
42
  expect(client_double.indices.analyze(index: 'foo')).to eq({})
47
43
  end
@@ -34,10 +34,6 @@ describe 'client.indices#clear_cache' do
34
34
  'foo/_cache/clear'
35
35
  end
36
36
 
37
- let(:params) do
38
- { index: 'foo' }
39
- end
40
-
41
37
  it 'performs the request' do
42
38
  expect(client_double.indices.clear_cache(index: 'foo')).to eq({})
43
39
  end
@@ -61,7 +57,7 @@ describe 'client.indices#clear_cache' do
61
57
  end
62
58
 
63
59
  let(:params) do
64
- { index: 'foo^bar' }
60
+ { }
65
61
  end
66
62
 
67
63
  it 'performs the request' do
@@ -0,0 +1,109 @@
1
+ # Licensed to Elasticsearch B.V under one or more agreements.
2
+ # Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
+ # See the LICENSE file in the project root for more information
4
+
5
+ require 'spec_helper'
6
+
7
+ describe 'client.indices#clone' do
8
+
9
+ let(:expected_args) do
10
+ [
11
+ 'PUT',
12
+ url,
13
+ params,
14
+ body,
15
+ nil
16
+ ]
17
+ end
18
+
19
+ let(:params) do
20
+ {}
21
+ end
22
+
23
+ let(:body) do
24
+ nil
25
+ end
26
+
27
+ let(:url) do
28
+ 'my_source_index/_clone/my_target_index'
29
+ end
30
+
31
+ context 'when there is no index specified' do
32
+
33
+ let(:client) do
34
+ Class.new { include Elasticsearch::API }.new
35
+ end
36
+
37
+ it 'raises an exception' do
38
+ expect {
39
+ client.indices.clone(target: 'my_target_index')
40
+ }.to raise_exception(ArgumentError)
41
+ end
42
+ end
43
+
44
+ context 'when there is no index specified' do
45
+
46
+ let(:client) do
47
+ Class.new { include Elasticsearch::API }.new
48
+ end
49
+
50
+ it 'raises an exception' do
51
+ expect {
52
+ client.indices.clone(index: 'my_source_index')
53
+ }.to raise_exception(ArgumentError)
54
+ end
55
+ end
56
+
57
+ context 'when an index and target are specified' do
58
+
59
+ it 'performs the request' do
60
+ expect(client_double.indices.clone(index: 'my_source_index', target: 'my_target_index')).to eq({})
61
+ end
62
+ end
63
+
64
+ context 'when params are provided' do
65
+
66
+ let(:params) do
67
+ {
68
+ timeout: '1s',
69
+ master_timeout: '10s',
70
+ wait_for_active_shards: 1
71
+ }
72
+ end
73
+
74
+ it 'performs the request' do
75
+ expect(client_double.indices.clone(index: 'my_source_index',
76
+ target: 'my_target_index',
77
+ timeout: '1s',
78
+ master_timeout: '10s',
79
+ wait_for_active_shards: 1)).to eq({})
80
+ end
81
+ end
82
+
83
+ context 'when a body is specified' do
84
+
85
+ let(:body) do
86
+ {
87
+ settings: {
88
+ 'index.number_of_shards' => 5
89
+ },
90
+ aliases: {
91
+ my_search_indices: {}
92
+ }
93
+ }
94
+ end
95
+
96
+ it 'performs the request' do
97
+ expect(client_double.indices.clone(index: 'my_source_index',
98
+ target: 'my_target_index',
99
+ body: {
100
+ settings: {
101
+ 'index.number_of_shards' => 5
102
+ },
103
+ aliases: {
104
+ my_search_indices: {}
105
+ }
106
+ })).to eq({})
107
+ end
108
+ end
109
+ end
@@ -49,7 +49,7 @@ describe 'client.indices#delete_alias' do
49
49
  context 'when an index and name are specified' do
50
50
 
51
51
  let(:url) do
52
- 'foo/_alias/bar'
52
+ 'foo/_aliases/bar'
53
53
  end
54
54
 
55
55
  it 'performs the request' do
@@ -60,7 +60,7 @@ describe 'client.indices#delete_alias' do
60
60
  context 'when the path must be URL-escaped' do
61
61
 
62
62
  let(:url) do
63
- 'foo%5Ebar/_alias/bar%2Fbam'
63
+ 'foo%5Ebar/_aliases/bar%2Fbam'
64
64
  end
65
65
 
66
66
  it 'performs the request' do
@@ -38,15 +38,4 @@ describe 'client.indices#get' do
38
38
  expect(client_double.indices.get(index: 'foo', ignore_unavailable: 1)).to eq({})
39
39
  end
40
40
  end
41
-
42
- context 'when features are specified' do
43
-
44
- let(:url) do
45
- 'foo/_settings'
46
- end
47
-
48
- it 'includes them in the URL' do
49
- expect(client_double.indices.get(index: 'foo', feature: '_settings')).to eq({})
50
- end
51
- end
52
41
  end
@@ -17,7 +17,7 @@ describe 'client.cluster#put_alias' do
17
17
  end
18
18
 
19
19
  let(:url) do
20
- 'foo/_alias/bar'
20
+ 'foo/_aliases/bar'
21
21
  end
22
22
 
23
23
  let(:body) do
@@ -55,7 +55,7 @@ describe 'client.cluster#put_alias' do
55
55
  context 'when multiple indices are specified' do
56
56
 
57
57
  let(:url) do
58
- 'foo,bar/_alias/bam'
58
+ 'foo,bar/_aliases/bam'
59
59
  end
60
60
 
61
61
  it 'performs the request' do
@@ -66,7 +66,7 @@ describe 'client.cluster#put_alias' do
66
66
  context 'when the path needs to be URL-escaped' do
67
67
 
68
68
  let(:url) do
69
- 'foo%5Ebar/_alias/bar%2Fbam'
69
+ 'foo%5Ebar/_aliases/bar%2Fbam'
70
70
  end
71
71
 
72
72
  it 'performs the request' do
@@ -17,7 +17,7 @@ describe 'client.cluster#put_mapping' do
17
17
  end
18
18
 
19
19
  let(:url) do
20
- 'foo/_mapping/bar'
20
+ 'foo/bar/_mappings'
21
21
  end
22
22
 
23
23
  let(:body) do
@@ -68,7 +68,7 @@ describe 'client.cluster#put_mapping' do
68
68
  context 'when multiple indices are specified' do
69
69
 
70
70
  let(:url) do
71
- 'foo,bar/_mapping/bam'
71
+ 'foo,bar/bam/_mappings'
72
72
  end
73
73
 
74
74
  it 'performs the request' do
@@ -79,7 +79,7 @@ describe 'client.cluster#put_mapping' do
79
79
  context 'when the path needs to be URL-escaped' do
80
80
 
81
81
  let(:url) do
82
- 'foo%5Ebar/_mapping/bar%2Fbam'
82
+ 'foo%5Ebar/bar%2Fbam/_mappings'
83
83
  end
84
84
 
85
85
  it 'performs the request' do
@@ -66,7 +66,6 @@ describe 'client.cluster#stats' do
66
66
  end
67
67
 
68
68
  context 'when parameters are specified' do
69
-
70
69
  let(:params) do
71
70
  { expand_wildcards: true }
72
71
  end
@@ -17,7 +17,7 @@ describe 'client.nodes#hot_threads' do
17
17
  end
18
18
 
19
19
  let(:url) do
20
- '_nodes/hot_threads'
20
+ '_cluster/nodes/hot_threads'
21
21
  end
22
22
 
23
23
  it 'performs the request' do
@@ -27,7 +27,7 @@ describe 'client.nodes#hot_threads' do
27
27
  context 'when the node id is specified' do
28
28
 
29
29
  let(:url) do
30
- '_nodes/foo/hot_threads'
30
+ '_cluster/nodes/foo/hot_threads'
31
31
  end
32
32
 
33
33
  it 'performs the request' do
@@ -38,7 +38,7 @@ describe 'client.nodes#hot_threads' do
38
38
  context 'when the path must be URL-escaped' do
39
39
 
40
40
  let(:url) do
41
- '_nodes/foo%5Ebar/hot_threads'
41
+ '_cluster/nodes/foo%5Ebar/hot_threads'
42
42
  end
43
43
 
44
44
  it 'performs the request' do
@@ -5,28 +5,33 @@
5
5
  require 'spec_helper'
6
6
 
7
7
  describe 'client#put_script' do
8
+ let(:url) do
9
+ '_scripts/foo'
10
+ end
8
11
 
9
- let(:expected_args) do
10
- [
12
+ context 'when the lang parameter is provided' do
13
+ let(:expected_args) do
14
+ [
11
15
  'PUT',
12
16
  url,
13
- { },
14
- { script: 'bar' }
15
- ]
16
- end
17
-
18
- let(:url) do
19
- '_scripts/groovy/foo'
20
- end
17
+ {},
18
+ { script: 'bar', lang: 'groovy' }
19
+ ]
20
+ end
21
21
 
22
- it 'performs the request' do
23
- expect(client_double.put_script(lang: 'groovy', id: 'foo', body: { script: 'bar' })).to eq({})
22
+ it 'performs the request' do
23
+ expect(client_double.put_script(id: 'foo', body: { script: 'bar', lang: 'groovy' })).to eq({})
24
+ end
24
25
  end
25
26
 
26
27
  context 'when the lang parameter is not provided' do
27
-
28
- let(:url) do
29
- '_scripts/foo'
28
+ let(:expected_args) do
29
+ [
30
+ 'PUT',
31
+ url,
32
+ {},
33
+ { script: 'bar' }
34
+ ]
30
35
  end
31
36
 
32
37
  it 'performs the request' do
@@ -5,17 +5,33 @@
5
5
  require 'spec_helper'
6
6
 
7
7
  describe 'client#render_search_template' do
8
-
9
- let(:expected_args) do
10
- [
8
+ context 'when no id is specified' do
9
+ let(:expected_args) do
10
+ [
11
11
  'GET',
12
12
  '_render/template',
13
- { id: 'foo' },
13
+ {},
14
14
  { foo: 'bar' }
15
- ]
15
+ ]
16
+ end
17
+
18
+ it 'performs the request' do
19
+ expect(client_double.render_search_template(body: { foo: 'bar' })).to eq({})
20
+ end
16
21
  end
17
22
 
18
- it 'performs the request' do
19
- expect(client_double.render_search_template(id: 'foo', body: { foo: 'bar' })).to eq({})
23
+ context 'when id is specified' do
24
+ let(:expected_args) do
25
+ [
26
+ 'GET',
27
+ '_render/template/foo',
28
+ {},
29
+ { foo: 'bar' }
30
+ ]
31
+ end
32
+
33
+ it 'performs the request' do
34
+ expect(client_double.render_search_template(id: 'foo', body: { foo: 'bar' })).to eq({})
35
+ end
20
36
  end
21
37
  end
@@ -0,0 +1,37 @@
1
+ # Licensed to Elasticsearch B.V under one or more agreements.
2
+ # Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
+ # See the LICENSE file in the project root for more information
4
+
5
+ require 'spec_helper'
6
+
7
+ describe 'client#scroll' do
8
+ context 'with scroll_id as a param' do
9
+ let(:expected_args) do
10
+ [
11
+ 'GET',
12
+ '_search/scroll/cXVlcn...',
13
+ {},
14
+ nil
15
+ ]
16
+ end
17
+
18
+ it 'performs the request' do
19
+ expect(client_double.scroll(scroll_id: 'cXVlcn...')).to eq({})
20
+ end
21
+ end
22
+
23
+ context 'with scroll_id in the body' do
24
+ let(:expected_args) do
25
+ [
26
+ 'GET',
27
+ '_search/scroll',
28
+ {},
29
+ { scroll_id: 'cXVlcn...' }
30
+ ]
31
+ end
32
+
33
+ it 'performs the request' do
34
+ expect(client_double.scroll(body: { scroll_id: 'cXVlcn...' })).to eq({})
35
+ end
36
+ end
37
+ end
@@ -117,19 +117,4 @@ describe 'client#search' do
117
117
  }.to raise_exception(ArgumentError)
118
118
  end
119
119
  end
120
-
121
- context 'when the request field params are not URL-encoded' do
122
-
123
- let(:params) do
124
- { fields: 'foo^bar'}
125
- end
126
-
127
- let(:url) do
128
- 'foo/bar/_search'
129
- end
130
-
131
- it 'does not encode the field params' do
132
- expect(client_double.search(index: 'foo', type: 'bar', fields: 'foo^bar'))
133
- end
134
- end
135
120
  end
@@ -23,15 +23,4 @@ describe 'client.tasks#list' do
23
23
  it 'performs the request' do
24
24
  expect(client_double.tasks.list).to eq({})
25
25
  end
26
-
27
- context 'when a task id is specified' do
28
-
29
- let(:url) do
30
- '_tasks/foo'
31
- end
32
-
33
- it 'performs the request' do
34
- expect(client_double.tasks.list(task_id: 'foo')).to eq({})
35
- end
36
- end
37
26
  end