opensearch-api 1.0.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (155) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/.gitignore +1 -0
  4. data/CHANGELOG.md +28 -0
  5. data/Gemfile +2 -2
  6. data/README.md +12 -182
  7. data/Rakefile +5 -5
  8. data/USER_GUIDE.md +155 -0
  9. data/lib/opensearch/api/actions/benchmark.rb +0 -1
  10. data/lib/opensearch/api/actions/bulk.rb +1 -7
  11. data/lib/opensearch/api/actions/cat/all_pit_segments.rb +46 -0
  12. data/lib/opensearch/api/actions/cat/allocation.rb +4 -2
  13. data/lib/opensearch/api/actions/cat/cluster_manager.rb +54 -0
  14. data/lib/opensearch/api/actions/cat/indices.rb +4 -2
  15. data/lib/opensearch/api/actions/cat/master.rb +3 -1
  16. data/lib/opensearch/api/actions/cat/nodeattrs.rb +4 -2
  17. data/lib/opensearch/api/actions/cat/nodes.rb +4 -2
  18. data/lib/opensearch/api/actions/cat/pending_tasks.rb +4 -2
  19. data/lib/opensearch/api/actions/cat/pit_segments.rb +49 -0
  20. data/lib/opensearch/api/actions/cat/plugins.rb +4 -2
  21. data/lib/opensearch/api/actions/cat/repositories.rb +4 -2
  22. data/lib/opensearch/api/actions/cat/shards.rb +4 -2
  23. data/lib/opensearch/api/actions/cat/snapshots.rb +3 -1
  24. data/lib/opensearch/api/actions/cat/templates.rb +4 -2
  25. data/lib/opensearch/api/actions/cat/thread_pool.rb +4 -2
  26. data/lib/opensearch/api/actions/cluster/delete_component_template.rb +4 -2
  27. data/lib/opensearch/api/actions/cluster/exists_component_template.rb +4 -2
  28. data/lib/opensearch/api/actions/cluster/get_component_template.rb +4 -2
  29. data/lib/opensearch/api/actions/cluster/get_settings.rb +3 -1
  30. data/lib/opensearch/api/actions/cluster/health.rb +4 -2
  31. data/lib/opensearch/api/actions/cluster/pending_tasks.rb +5 -3
  32. data/lib/opensearch/api/actions/cluster/put_component_template.rb +4 -2
  33. data/lib/opensearch/api/actions/cluster/put_settings.rb +3 -1
  34. data/lib/opensearch/api/actions/cluster/reroute.rb +4 -2
  35. data/lib/opensearch/api/actions/cluster/state.rb +4 -2
  36. data/lib/opensearch/api/actions/count.rb +1 -6
  37. data/lib/opensearch/api/actions/create.rb +0 -1
  38. data/lib/opensearch/api/actions/create_pit.rb +45 -0
  39. data/lib/opensearch/api/actions/dangling_indices/delete_dangling_index.rb +4 -2
  40. data/lib/opensearch/api/actions/dangling_indices/import_dangling_index.rb +4 -2
  41. data/lib/opensearch/api/actions/delete.rb +1 -8
  42. data/lib/opensearch/api/actions/delete_all_pits.rb +26 -0
  43. data/lib/opensearch/api/actions/delete_by_query.rb +1 -8
  44. data/lib/opensearch/api/actions/delete_pit.rb +30 -0
  45. data/lib/opensearch/api/actions/delete_script.rb +4 -2
  46. data/lib/opensearch/api/actions/exists.rb +1 -8
  47. data/lib/opensearch/api/actions/exists_source.rb +1 -8
  48. data/lib/opensearch/api/actions/explain.rb +1 -8
  49. data/lib/opensearch/api/actions/features/get_features.rb +4 -2
  50. data/lib/opensearch/api/actions/get.rb +1 -8
  51. data/lib/opensearch/api/actions/get_all_pits.rb +26 -0
  52. data/lib/opensearch/api/actions/get_script.rb +4 -2
  53. data/lib/opensearch/api/actions/get_source.rb +1 -8
  54. data/lib/opensearch/api/actions/index.rb +1 -8
  55. data/lib/opensearch/api/actions/indices/add_block.rb +3 -1
  56. data/lib/opensearch/api/actions/indices/clone.rb +3 -1
  57. data/lib/opensearch/api/actions/indices/close.rb +3 -1
  58. data/lib/opensearch/api/actions/indices/create.rb +4 -4
  59. data/lib/opensearch/api/actions/indices/delete.rb +3 -1
  60. data/lib/opensearch/api/actions/indices/delete_alias.rb +4 -2
  61. data/lib/opensearch/api/actions/indices/delete_index_template.rb +4 -2
  62. data/lib/opensearch/api/actions/indices/delete_template.rb +4 -2
  63. data/lib/opensearch/api/actions/indices/exists_index_template.rb +4 -2
  64. data/lib/opensearch/api/actions/indices/exists_template.rb +4 -2
  65. data/lib/opensearch/api/actions/indices/get.rb +4 -4
  66. data/lib/opensearch/api/actions/indices/get_field_mapping.rb +1 -10
  67. data/lib/opensearch/api/actions/indices/get_index_template.rb +4 -2
  68. data/lib/opensearch/api/actions/indices/get_mapping.rb +5 -12
  69. data/lib/opensearch/api/actions/indices/get_settings.rb +3 -1
  70. data/lib/opensearch/api/actions/indices/get_template.rb +4 -4
  71. data/lib/opensearch/api/actions/indices/open.rb +3 -1
  72. data/lib/opensearch/api/actions/indices/put_alias.rb +4 -2
  73. data/lib/opensearch/api/actions/indices/put_index_template.rb +4 -2
  74. data/lib/opensearch/api/actions/indices/put_mapping.rb +4 -13
  75. data/lib/opensearch/api/actions/indices/put_settings.rb +3 -1
  76. data/lib/opensearch/api/actions/indices/put_template.rb +4 -4
  77. data/lib/opensearch/api/actions/indices/rollover.rb +3 -3
  78. data/lib/opensearch/api/actions/indices/shrink.rb +3 -1
  79. data/lib/opensearch/api/actions/indices/simulate_index_template.rb +4 -2
  80. data/lib/opensearch/api/actions/indices/simulate_template.rb +4 -2
  81. data/lib/opensearch/api/actions/indices/split.rb +3 -1
  82. data/lib/opensearch/api/actions/indices/update_aliases.rb +4 -2
  83. data/lib/opensearch/api/actions/indices/validate_query.rb +1 -6
  84. data/lib/opensearch/api/actions/ingest/delete_pipeline.rb +3 -1
  85. data/lib/opensearch/api/actions/ingest/get_pipeline.rb +4 -2
  86. data/lib/opensearch/api/actions/ingest/put_pipeline.rb +3 -1
  87. data/lib/opensearch/api/actions/mget.rb +2 -7
  88. data/lib/opensearch/api/actions/msearch.rb +1 -6
  89. data/lib/opensearch/api/actions/msearch_template.rb +1 -6
  90. data/lib/opensearch/api/actions/mtermvectors.rb +1 -6
  91. data/lib/opensearch/api/actions/put_script.rb +3 -1
  92. data/lib/opensearch/api/actions/search.rb +1 -7
  93. data/lib/opensearch/api/actions/search_shards.rb +1 -1
  94. data/lib/opensearch/api/actions/search_template.rb +1 -6
  95. data/lib/opensearch/api/actions/snapshot/cleanup_repository.rb +3 -1
  96. data/lib/opensearch/api/actions/snapshot/clone.rb +4 -2
  97. data/lib/opensearch/api/actions/snapshot/create.rb +3 -1
  98. data/lib/opensearch/api/actions/snapshot/create_repository.rb +3 -1
  99. data/lib/opensearch/api/actions/snapshot/delete.rb +4 -2
  100. data/lib/opensearch/api/actions/snapshot/delete_repository.rb +3 -1
  101. data/lib/opensearch/api/actions/snapshot/get.rb +3 -1
  102. data/lib/opensearch/api/actions/snapshot/get_features.rb +4 -2
  103. data/lib/opensearch/api/actions/snapshot/get_repository.rb +3 -2
  104. data/lib/opensearch/api/actions/snapshot/restore.rb +3 -1
  105. data/lib/opensearch/api/actions/snapshot/status.rb +3 -1
  106. data/lib/opensearch/api/actions/snapshot/verify_repository.rb +3 -1
  107. data/lib/opensearch/api/actions/termvectors.rb +1 -8
  108. data/lib/opensearch/api/actions/update.rb +1 -8
  109. data/lib/opensearch/api/actions/update_by_query.rb +1 -8
  110. data/lib/opensearch/api/utils.rb +5 -5
  111. data/lib/opensearch/api/version.rb +1 -1
  112. data/lib/opensearch/api.rb +1 -1
  113. data/opensearch-api.gemspec +2 -3
  114. data/spec/opensearch/api/actions/bulk_spec.rb +10 -21
  115. data/spec/opensearch/api/actions/cat/all_pit_segments_spec.rb +36 -0
  116. data/spec/opensearch/api/actions/cat/allocation_spec.rb +6 -7
  117. data/spec/opensearch/api/actions/cat/cluster_manager_spec.rb +26 -0
  118. data/spec/opensearch/api/actions/cat/pit_segments_spec.rb +43 -0
  119. data/spec/opensearch/api/actions/count_spec.rb +3 -3
  120. data/spec/opensearch/api/actions/create_document_spec.rb +8 -8
  121. data/spec/opensearch/api/actions/create_pit_spec.rb +58 -0
  122. data/spec/opensearch/api/actions/delete_all_pits_spec.rb +35 -0
  123. data/spec/opensearch/api/actions/delete_by_query_spec.rb +0 -17
  124. data/spec/opensearch/api/actions/delete_document_spec.rb +10 -10
  125. data/spec/opensearch/api/actions/delete_pit_spec.rb +41 -0
  126. data/spec/opensearch/api/actions/exists_document_spec.rb +10 -10
  127. data/spec/opensearch/api/actions/explain_document_spec.rb +8 -8
  128. data/spec/opensearch/api/actions/get_all_pits_spec.rb +35 -0
  129. data/spec/opensearch/api/actions/get_document_source_spec.rb +6 -6
  130. data/spec/opensearch/api/actions/get_document_spec.rb +8 -8
  131. data/spec/opensearch/api/actions/get_script_spec.rb +2 -2
  132. data/spec/opensearch/api/actions/hashie_spec.rb +0 -2
  133. data/spec/opensearch/api/actions/index_document_spec.rb +12 -12
  134. data/spec/opensearch/api/actions/indices/clone_spec.rb +2 -2
  135. data/spec/opensearch/api/actions/indices/get_field_mapping_spec.rb +0 -11
  136. data/spec/opensearch/api/actions/indices/get_mapping_spec.rb +5 -16
  137. data/spec/opensearch/api/actions/indices/put_mapping_spec.rb +8 -21
  138. data/spec/opensearch/api/actions/indices/validate_query_spec.rb +0 -10
  139. data/spec/opensearch/api/actions/mget_spec.rb +2 -17
  140. data/spec/opensearch/api/actions/mtermvectors_spec.rb +3 -3
  141. data/spec/opensearch/api/actions/search_spec.rb +5 -16
  142. data/spec/opensearch/api/actions/termvectors_spec.rb +5 -5
  143. data/spec/opensearch/api/actions/update_document_spec.rb +11 -11
  144. data/spec/opensearch/api/utils_spec.rb +7 -14
  145. data.tar.gz.sig +0 -0
  146. metadata +40 -43
  147. metadata.gz.sig +0 -0
  148. data/lib/opensearch/api/actions/close_point_in_time.rb +0 -50
  149. data/lib/opensearch/api/actions/indices/exists_type.rb +0 -79
  150. data/lib/opensearch/api/actions/indices/flush_synced.rb +0 -79
  151. data/lib/opensearch/api/actions/open_point_in_time.rb +0 -72
  152. data/spec/opensearch/api/actions/close_point_in_time_spec.rb +0 -43
  153. data/spec/opensearch/api/actions/indices/exists_type_spec.rb +0 -117
  154. data/spec/opensearch/api/actions/indices/flush_synced_spec.rb +0 -99
  155. data/spec/opensearch/api/actions/open_point_in_time_spec.rb +0 -53
@@ -0,0 +1,58 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ #
3
+ # The OpenSearch Contributors require contributions made to
4
+ # this file be licensed under the Apache-2.0 license or a
5
+ # compatible open source license.
6
+ #
7
+ # Modifications Copyright OpenSearch Contributors. See
8
+ # GitHub history for details.
9
+
10
+ require 'spec_helper'
11
+
12
+ describe 'client#create_pit' do
13
+ let(:expected_args) do
14
+ [
15
+ 'POST',
16
+ 'movies,books/_search/point_in_time',
17
+ { keep_alive: '1m',
18
+ preference: :random,
19
+ routing: :route,
20
+ expand_wildcards: :open,
21
+ allow_partial_pit_creation: false },
22
+ nil
23
+ ]
24
+ end
25
+
26
+ let(:client) do
27
+ Class.new { include OpenSearch::API }.new
28
+ end
29
+
30
+ it 'requires the :index argument' do
31
+ expect {
32
+ client.create_pit(keep_alive: '1m')
33
+ }.to raise_exception(ArgumentError)
34
+ end
35
+
36
+ it 'requires the :index argument' do
37
+ expect {
38
+ client.create_pit(index: 'movies')
39
+ }.to raise_exception(ArgumentError)
40
+ end
41
+
42
+ it 'does not accept unregistered params' do
43
+ expect {
44
+ client.create_pit(index: 'movies', keep_alive: '1m', something: 42)
45
+ }.to raise_exception(ArgumentError)
46
+ end
47
+
48
+ it 'performs the request with all optional params' do
49
+ expect(client_double.create_pit(
50
+ index: %w[movies books],
51
+ keep_alive: '1m',
52
+ preference: :random,
53
+ routing: :route,
54
+ expand_wildcards: :open,
55
+ allow_partial_pit_creation: false
56
+ )).to eq({})
57
+ end
58
+ end
@@ -0,0 +1,35 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ #
3
+ # The OpenSearch Contributors require contributions made to
4
+ # this file be licensed under the Apache-2.0 license or a
5
+ # compatible open source license.
6
+ #
7
+ # Modifications Copyright OpenSearch Contributors. See
8
+ # GitHub history for details.
9
+
10
+ require 'spec_helper'
11
+
12
+ describe 'client#delete_all_pits' do
13
+ let(:expected_args) do
14
+ [
15
+ 'DELETE',
16
+ '_search/point_in_time/_all',
17
+ {},
18
+ nil
19
+ ]
20
+ end
21
+
22
+ let(:client) do
23
+ Class.new { include OpenSearch::API }.new
24
+ end
25
+
26
+ it 'does not accept unregistered params' do
27
+ expect {
28
+ client.delete_all_pits(something: :else)
29
+ }.to raise_exception(ArgumentError)
30
+ end
31
+
32
+ it 'performs the request with all optional params' do
33
+ expect(client_double.delete_all_pits).to eq({})
34
+ end
35
+ end
@@ -48,23 +48,6 @@ describe 'client#delete_by_query' do
48
48
  expect(client_double.delete_by_query(index: 'foo', body: { term: {} })).to eq({})
49
49
  end
50
50
 
51
- context 'when the type argument is provided' do
52
-
53
- let(:expected_args) do
54
- [
55
- 'POST',
56
- 'foo/tweet,post/_delete_by_query',
57
- {},
58
- { term: {} },
59
- {}
60
- ]
61
- end
62
-
63
- it 'performs the request' do
64
- expect(client_double.delete_by_query(index: 'foo', type: ['tweet', 'post'], body: { term: {} })).to eq({})
65
- end
66
- end
67
-
68
51
  context 'when a query is provided' do
69
52
  let(:expected_args) do
70
53
  [
@@ -31,7 +31,7 @@ describe 'client#delete' do
31
31
  let(:expected_args) do
32
32
  [
33
33
  'DELETE',
34
- 'foo/bar/1',
34
+ 'foo/_doc/1',
35
35
  params,
36
36
  nil,
37
37
  {}
@@ -48,18 +48,18 @@ describe 'client#delete' do
48
48
 
49
49
  it 'requires the :index argument' do
50
50
  expect {
51
- client.delete(type: 'bar', id: '1')
51
+ client.delete(id: '1')
52
52
  }.to raise_exception(ArgumentError)
53
53
  end
54
54
 
55
55
  it 'requires the :id argument' do
56
56
  expect {
57
- client.delete(index: 'foo', type: 'bar')
57
+ client.delete(index: 'foo')
58
58
  }.to raise_exception(ArgumentError)
59
59
  end
60
60
 
61
61
  it 'performs the request' do
62
- expect(client_double.delete(index: 'foo', type: 'bar', id: '1')).to eq({})
62
+ expect(client_double.delete(index: 'foo', id: '1')).to eq({})
63
63
  end
64
64
 
65
65
  context 'when url params are provided' do
@@ -69,7 +69,7 @@ describe 'client#delete' do
69
69
  end
70
70
 
71
71
  it 'performs the request' do
72
- expect(client_double.delete(index: 'foo', type: 'bar', id: '1', routing: 'abc123')).to eq({})
72
+ expect(client_double.delete(index: 'foo', id: '1', routing: 'abc123')).to eq({})
73
73
  end
74
74
  end
75
75
 
@@ -77,7 +77,7 @@ describe 'client#delete' do
77
77
 
78
78
  it 'raises an ArgumentError' do
79
79
  expect {
80
- client.delete(index: 'foo', type: 'bar', id: '1', qwertypoiuy: 'asdflkjhg')
80
+ client.delete(index: 'foo', id: '1', qwertypoiuy: 'asdflkjhg')
81
81
  }.to raise_exception(ArgumentError)
82
82
  end
83
83
  end
@@ -87,7 +87,7 @@ describe 'client#delete' do
87
87
  let(:expected_args) do
88
88
  [
89
89
  'DELETE',
90
- 'foo%5Ebar/bar%2Fbam/1',
90
+ 'foo%5Ebar/_doc/1',
91
91
  params,
92
92
  nil,
93
93
  {}
@@ -95,7 +95,7 @@ describe 'client#delete' do
95
95
  end
96
96
 
97
97
  it 'escapes the url params' do
98
- expect(client_double.delete(index: 'foo^bar', type: 'bar/bam', id: 1)).to eq({})
98
+ expect(client_double.delete(index: 'foo^bar', id: 1)).to eq({})
99
99
  end
100
100
  end
101
101
 
@@ -107,14 +107,14 @@ describe 'client#delete' do
107
107
 
108
108
  it 'raises the exception' do
109
109
  expect {
110
- client.delete(index: 'foo', type: 'bar', id: 'XXX')
110
+ client.delete(index: 'foo', id: 'XXX')
111
111
  }.to raise_exception(NotFound)
112
112
  end
113
113
 
114
114
  context 'when the :ignore option is provided' do
115
115
 
116
116
  it 'does not raise the NotFound exception' do
117
- expect(client.delete(index: 'foo', type: 'bar', id: 1, ignore: 404)).to eq(false)
117
+ expect(client.delete(index: 'foo', id: 1, ignore: 404)).to eq(false)
118
118
  end
119
119
  end
120
120
  end
@@ -0,0 +1,41 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ #
3
+ # The OpenSearch Contributors require contributions made to
4
+ # this file be licensed under the Apache-2.0 license or a
5
+ # compatible open source license.
6
+ #
7
+ # Modifications Copyright OpenSearch Contributors. See
8
+ # GitHub history for details.
9
+
10
+ require 'spec_helper'
11
+
12
+ describe 'client#delete_pit' do
13
+ let(:expected_args) do
14
+ [
15
+ 'DELETE',
16
+ '_search/point_in_time',
17
+ {},
18
+ { pit_id: ['abc'] }
19
+ ]
20
+ end
21
+
22
+ let(:client) do
23
+ Class.new { include OpenSearch::API }.new
24
+ end
25
+
26
+ it 'requires the :body argument' do
27
+ expect {
28
+ client.delete_pit
29
+ }.to raise_exception(ArgumentError)
30
+ end
31
+
32
+ it 'does not accept unregistered params' do
33
+ expect {
34
+ client.delete_pit(body: {}, something: :else)
35
+ }.to raise_exception(ArgumentError)
36
+ end
37
+
38
+ it 'performs the request with all optional params' do
39
+ expect(client_double.delete_pit(body: { pit_id: ['abc'] })).to eq({})
40
+ end
41
+ end
@@ -43,7 +43,7 @@ describe 'client#exists' do
43
43
  end
44
44
 
45
45
  let(:url) do
46
- 'foo/bar/1'
46
+ 'foo/_doc/1'
47
47
  end
48
48
 
49
49
  let(:client) do
@@ -52,13 +52,13 @@ describe 'client#exists' do
52
52
 
53
53
  it 'requires the :index argument' do
54
54
  expect {
55
- client.exists(type: 'bar', id: '1')
55
+ client.exists(id: '1')
56
56
  }.to raise_exception(ArgumentError)
57
57
  end
58
58
 
59
59
  it 'requires the :id argument' do
60
60
  expect {
61
- client.exists(index: 'foo', type: 'bar')
61
+ client.exists(index: 'foo')
62
62
  }.to raise_exception(ArgumentError)
63
63
  end
64
64
 
@@ -74,7 +74,7 @@ describe 'client#exists' do
74
74
  end
75
75
 
76
76
  it 'is aliased to a predicated method' do
77
- expect(client_double.exists?(index: 'foo', type: 'bar', id: '1')).to eq(true)
77
+ expect(client_double.exists?(index: 'foo', id: '1')).to eq(true)
78
78
  end
79
79
 
80
80
  context 'when URL parameters are provided' do
@@ -84,18 +84,18 @@ describe 'client#exists' do
84
84
  end
85
85
 
86
86
  it 'passes the parameters' do
87
- expect(client_double.exists(index: 'foo', type: 'bar', id: '1', routing: 'abc123')).to eq(true)
87
+ expect(client_double.exists(index: 'foo', id: '1', routing: 'abc123')).to eq(true)
88
88
  end
89
89
  end
90
90
 
91
91
  context 'when the request needs to be URL-escaped' do
92
92
 
93
93
  let(:url) do
94
- 'foo/bar%2Fbam/1'
94
+ 'foo%5Ebar/_doc/1'
95
95
  end
96
96
 
97
97
  it 'URL-escapes the characters' do
98
- expect(client_double.exists(index: 'foo', type: 'bar/bam', id: '1')).to eq(true)
98
+ expect(client_double.exists(index: 'foo^bar', id: '1')).to eq(true)
99
99
  end
100
100
  end
101
101
 
@@ -106,7 +106,7 @@ describe 'client#exists' do
106
106
  end
107
107
 
108
108
  it 'returns false' do
109
- expect(client_double.exists(index: 'foo', type: 'bar', id: '1')).to eq(false)
109
+ expect(client_double.exists(index: 'foo', id: '1')).to eq(false)
110
110
  end
111
111
  end
112
112
 
@@ -117,7 +117,7 @@ describe 'client#exists' do
117
117
  end
118
118
 
119
119
  it 'returns false' do
120
- expect(client_double.exists(index: 'foo', type: 'bar', id: '1')).to eq(false)
120
+ expect(client_double.exists(index: 'foo', id: '1')).to eq(false)
121
121
  end
122
122
  end
123
123
 
@@ -129,7 +129,7 @@ describe 'client#exists' do
129
129
 
130
130
  it 'raises the error' do
131
131
  expect {
132
- client_double.exists(index: 'foo', type: 'bar', id: '1')
132
+ client_double.exists(index: 'foo', id: '1')
133
133
  }.to raise_exception(StandardError)
134
134
  end
135
135
  end
@@ -48,7 +48,7 @@ describe 'client#explain' do
48
48
  end
49
49
 
50
50
  let(:url) do
51
- 'foo/bar/1/_explain'
51
+ 'foo/_explain/1'
52
52
  end
53
53
 
54
54
  let(:client) do
@@ -57,18 +57,18 @@ describe 'client#explain' do
57
57
 
58
58
  it 'requires the :index argument' do
59
59
  expect {
60
- client.explain(type: 'bar', id: '1')
60
+ client.explain(id: '1')
61
61
  }.to raise_exception(ArgumentError)
62
62
  end
63
63
 
64
64
  it 'requires the :id argument' do
65
65
  expect {
66
- client.explain(index: 'foo', type: 'bar')
66
+ client.explain(index: 'foo')
67
67
  }.to raise_exception(ArgumentError)
68
68
  end
69
69
 
70
70
  it 'performs the request' do
71
- expect(client_double.explain(index: 'foo', type: 'bar', id: 1, body: {})).to eq({})
71
+ expect(client_double.explain(index: 'foo', id: 1, body: {})).to eq({})
72
72
  end
73
73
 
74
74
  context 'when a query is provided' do
@@ -82,7 +82,7 @@ describe 'client#explain' do
82
82
  end
83
83
 
84
84
  it 'passes the query' do
85
- expect(client_double.explain(index: 'foo', type: 'bar', id: '1', q: 'abc123')).to eq({})
85
+ expect(client_double.explain(index: 'foo', id: '1', q: 'abc123')).to eq({})
86
86
  end
87
87
  end
88
88
 
@@ -92,17 +92,17 @@ describe 'client#explain' do
92
92
  end
93
93
 
94
94
  it 'passes the query definition' do
95
- expect(client_double.explain(index: 'foo', type: 'bar', id: '1', body: { query: { match: {} } })).to eq({})
95
+ expect(client_double.explain(index: 'foo', id: '1', body: { query: { match: {} } })).to eq({})
96
96
  end
97
97
  end
98
98
 
99
99
  context 'when the request needs to be URL-escaped' do
100
100
  let(:url) do
101
- 'foo%5Ebar/bar%2Fbam/1/_explain'
101
+ 'foo%5Ebar/_explain/1'
102
102
  end
103
103
 
104
104
  it 'URL-escapes the parts' do
105
- expect(client_double.explain(index: 'foo^bar', type: 'bar/bam', id: '1', body: { })).to eq({})
105
+ expect(client_double.explain(index: 'foo^bar', id: '1', body: { })).to eq({})
106
106
  end
107
107
  end
108
108
  end
@@ -0,0 +1,35 @@
1
+ # SPDX-License-Identifier: Apache-2.0
2
+ #
3
+ # The OpenSearch Contributors require contributions made to
4
+ # this file be licensed under the Apache-2.0 license or a
5
+ # compatible open source license.
6
+ #
7
+ # Modifications Copyright OpenSearch Contributors. See
8
+ # GitHub history for details.
9
+
10
+ require 'spec_helper'
11
+
12
+ describe 'client#get_all_pits' do
13
+ let(:expected_args) do
14
+ [
15
+ 'GET',
16
+ '_search/point_in_time/_all',
17
+ {},
18
+ nil
19
+ ]
20
+ end
21
+
22
+ let(:client) do
23
+ Class.new { include OpenSearch::API }.new
24
+ end
25
+
26
+ it 'does not accept unregistered params' do
27
+ expect {
28
+ client.get_all_pits(something: :else)
29
+ }.to raise_exception(ArgumentError)
30
+ end
31
+
32
+ it 'performs the request with all optional params' do
33
+ expect(client_double.get_all_pits).to eq({})
34
+ end
35
+ end
@@ -43,7 +43,7 @@ describe 'client#get_source' do
43
43
  end
44
44
 
45
45
  let(:url) do
46
- 'foo/bar/1/_source'
46
+ 'foo/_source/1'
47
47
  end
48
48
 
49
49
  let(:client) do
@@ -52,13 +52,13 @@ describe 'client#get_source' do
52
52
 
53
53
  it 'requires the :index argument' do
54
54
  expect {
55
- client.get_source(type: 'bar', id: '1')
55
+ client.get_source(id: '1')
56
56
  }.to raise_exception(ArgumentError)
57
57
  end
58
58
 
59
59
  it 'requires the :id argument' do
60
60
  expect {
61
- client.get_source(index: 'foo', type: 'bar')
61
+ client.get_source(index: 'foo')
62
62
  }.to raise_exception(ArgumentError)
63
63
  end
64
64
 
@@ -80,18 +80,18 @@ describe 'client#get_source' do
80
80
  end
81
81
 
82
82
  it 'Passes the URL params' do
83
- expect(client_double.get_source(index: 'foo', type: 'bar', id: '1', routing: 'abc123')).to eq({})
83
+ expect(client_double.get_source(index: 'foo', id: '1', routing: 'abc123')).to eq({})
84
84
  end
85
85
  end
86
86
 
87
87
  context 'when the request needs to be URL-escaped' do
88
88
 
89
89
  let(:url) do
90
- 'foo%5Ebar/bar%2Fbam/1/_source'
90
+ 'foo%5Ebar/_source/1'
91
91
  end
92
92
 
93
93
  it 'URL-escapes the parts' do
94
- expect(client_double.get_source(index: 'foo^bar', type: 'bar/bam', id: '1')).to eq({})
94
+ expect(client_double.get_source(index: 'foo^bar', id: '1')).to eq({})
95
95
  end
96
96
  end
97
97
 
@@ -43,7 +43,7 @@ describe 'client#get' do
43
43
  end
44
44
 
45
45
  let(:url) do
46
- 'foo/bar/1'
46
+ 'foo/_doc/1'
47
47
  end
48
48
 
49
49
  let(:client) do
@@ -52,13 +52,13 @@ describe 'client#get' do
52
52
 
53
53
  it 'requires the :index argument' do
54
54
  expect {
55
- client.get(type: 'bar', id: '1')
55
+ client.get(id: '1')
56
56
  }.to raise_exception(ArgumentError)
57
57
  end
58
58
 
59
59
  it 'requires the :id argument' do
60
60
  expect {
61
- client.get(index: 'foo', type: 'bar')
61
+ client.get(index: 'foo')
62
62
  }.to raise_exception(ArgumentError)
63
63
  end
64
64
 
@@ -80,7 +80,7 @@ describe 'client#get' do
80
80
  end
81
81
 
82
82
  it 'Passes the URL params' do
83
- expect(client_double.get(index: 'foo', type: 'bar', id: '1', routing: 'abc123')).to eq({})
83
+ expect(client_double.get(index: 'foo', id: '1', routing: 'abc123')).to eq({})
84
84
  end
85
85
  end
86
86
 
@@ -88,7 +88,7 @@ describe 'client#get' do
88
88
 
89
89
  it 'Passes the URL params' do
90
90
  expect {
91
- client.get(index: 'foo', type: 'bar', id: '1', qwert: 'abc123')
91
+ client.get(index: 'foo', id: '1', qwert: 'abc123')
92
92
  }.to raise_exception(ArgumentError)
93
93
  end
94
94
  end
@@ -96,11 +96,11 @@ describe 'client#get' do
96
96
  context 'when the request needs to be URL-escaped' do
97
97
 
98
98
  let(:url) do
99
- 'foo%5Ebar/bar%2Fbam/1'
99
+ 'foo%5Ebar/_doc/1'
100
100
  end
101
101
 
102
102
  it 'URL-escapes the parts' do
103
- expect(client_double.get(index: 'foo^bar', type: 'bar/bam', id: '1')).to eq({})
103
+ expect(client_double.get(index: 'foo^bar', id: '1')).to eq({})
104
104
  end
105
105
  end
106
106
 
@@ -125,7 +125,7 @@ describe 'client#get' do
125
125
  end
126
126
 
127
127
  it 'returns false' do
128
- expect(client.get(index: 'foo', type: 'bar', id: '1', ignore: 404)).to eq(false)
128
+ expect(client.get(index: 'foo', id: '1', ignore: 404)).to eq(false)
129
129
  end
130
130
  end
131
131
  end
@@ -49,11 +49,11 @@ describe 'client#get_script' do
49
49
  context 'when the `lang` parameter is specificed' do
50
50
 
51
51
  let(:params) do
52
- { master_timeout: '1s' }
52
+ { cluster_manager_timeout: '1s' }
53
53
  end
54
54
 
55
55
  it 'performs the request' do
56
- expect(client_double.get_script(master_timeout: '1s', id: 'foo')).to eq({})
56
+ expect(client_double.get_script(cluster_manager_timeout: '1s', id: 'foo')).to eq({})
57
57
  end
58
58
  end
59
59
  end
@@ -45,7 +45,6 @@ describe 'Hashie' do
45
45
  "hits": [
46
46
  {
47
47
  "_index": "myindex",
48
- "_type": "mytype",
49
48
  "_id": "1",
50
49
  "_score": 0.51104903,
51
50
  "_source": {
@@ -63,7 +62,6 @@ describe 'Hashie' do
63
62
  },
64
63
  "facets": {
65
64
  "tags": {
66
- "_type": "terms",
67
65
  "missing": 0,
68
66
  "total": 10,
69
67
  "other": 0,
@@ -47,7 +47,7 @@ describe 'client#index' do
47
47
  end
48
48
 
49
49
  let(:url) do
50
- 'foo/bar'
50
+ 'foo/_doc'
51
51
  end
52
52
 
53
53
  let(:body) do
@@ -60,12 +60,12 @@ describe 'client#index' do
60
60
 
61
61
  it 'requires the :index argument' do
62
62
  expect {
63
- client.index(type: 'bar')
63
+ client.index()
64
64
  }.to raise_exception(ArgumentError)
65
65
  end
66
66
 
67
67
  it 'performs the request' do
68
- expect(client_double.index(index: 'foo', type: 'bar', body: body)).to eq({})
68
+ expect(client_double.index(index: 'foo', body: body)).to eq({})
69
69
  end
70
70
 
71
71
  context 'when a specific id is provided' do
@@ -75,11 +75,11 @@ describe 'client#index' do
75
75
  end
76
76
 
77
77
  let(:url) do
78
- 'foo/bar/1'
78
+ 'foo/_doc/1'
79
79
  end
80
80
 
81
81
  it 'performs the request' do
82
- expect(client_double.index(index: 'foo', type: 'bar', id: '1', body: body)).to eq({})
82
+ expect(client_double.index(index: 'foo', id: '1', body: body)).to eq({})
83
83
  end
84
84
  end
85
85
 
@@ -90,7 +90,7 @@ describe 'client#index' do
90
90
  end
91
91
 
92
92
  let(:url) do
93
- 'foo/bar'
93
+ 'foo/_doc'
94
94
  end
95
95
 
96
96
  let(:params) do
@@ -98,7 +98,7 @@ describe 'client#index' do
98
98
  end
99
99
 
100
100
  it 'passes the URL params' do
101
- expect(client_double.index(index: 'foo', type: 'bar', op_type: 'create', body: body)).to eq({})
101
+ expect(client_double.index(index: 'foo', op_type: 'create', body: body)).to eq({})
102
102
  end
103
103
 
104
104
  context 'when a specific id is provided' do
@@ -108,7 +108,7 @@ describe 'client#index' do
108
108
  end
109
109
 
110
110
  let(:url) do
111
- 'foo/bar/1'
111
+ 'foo/_doc/1'
112
112
  end
113
113
 
114
114
  let(:params) do
@@ -116,7 +116,7 @@ describe 'client#index' do
116
116
  end
117
117
 
118
118
  it 'passes the URL params' do
119
- expect(client_double.index(index: 'foo', type: 'bar', id: '1', op_type: 'create', body: body)).to eq({})
119
+ expect(client_double.index(index: 'foo', id: '1', op_type: 'create', body: body)).to eq({})
120
120
  end
121
121
  end
122
122
  end
@@ -127,11 +127,11 @@ describe 'client#index' do
127
127
  end
128
128
 
129
129
  let(:url) do
130
- 'foo/bar%2Fbam/123'
130
+ 'foo%5Ebar/_doc/123'
131
131
  end
132
132
 
133
133
  it 'URL-escapes the parts' do
134
- expect(client_double.index(index: 'foo', type: 'bar/bam', id: '123', body: body)).to eq({})
134
+ expect(client_double.index(index: 'foo^bar', id: '123', body: body)).to eq({})
135
135
  end
136
136
  end
137
137
 
@@ -139,7 +139,7 @@ describe 'client#index' do
139
139
 
140
140
  it 'raises and ArgumentError' do
141
141
  expect {
142
- client.index(index: 'foo', type: 'bar', id: '1', qwerty: 'yuiop')
142
+ client.index(index: 'foo', id: '1', qwerty: 'yuiop')
143
143
  }.to raise_exception(ArgumentError)
144
144
  end
145
145
  end
@@ -88,7 +88,7 @@ describe 'client.indices#clone' do
88
88
  let(:params) do
89
89
  {
90
90
  timeout: '1s',
91
- master_timeout: '10s',
91
+ cluster_manager_timeout: '10s',
92
92
  wait_for_active_shards: 1
93
93
  }
94
94
  end
@@ -97,7 +97,7 @@ describe 'client.indices#clone' do
97
97
  expect(client_double.indices.clone(index: 'my_source_index',
98
98
  target: 'my_target_index',
99
99
  timeout: '1s',
100
- master_timeout: '10s',
100
+ cluster_manager_timeout: '10s',
101
101
  wait_for_active_shards: 1)).to eq({})
102
102
  end
103
103
  end