opensearch-api 1.0.0 → 2.0.2

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 (64) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/README.md +3 -3
  4. data/lib/opensearch/api/actions/benchmark.rb +0 -1
  5. data/lib/opensearch/api/actions/bulk.rb +1 -7
  6. data/lib/opensearch/api/actions/count.rb +1 -6
  7. data/lib/opensearch/api/actions/create.rb +0 -1
  8. data/lib/opensearch/api/actions/delete.rb +1 -8
  9. data/lib/opensearch/api/actions/delete_by_query.rb +1 -8
  10. data/lib/opensearch/api/actions/exists.rb +1 -8
  11. data/lib/opensearch/api/actions/exists_source.rb +1 -8
  12. data/lib/opensearch/api/actions/explain.rb +1 -8
  13. data/lib/opensearch/api/actions/get.rb +1 -8
  14. data/lib/opensearch/api/actions/get_source.rb +1 -8
  15. data/lib/opensearch/api/actions/index.rb +1 -8
  16. data/lib/opensearch/api/actions/indices/create.rb +0 -2
  17. data/lib/opensearch/api/actions/indices/get.rb +0 -2
  18. data/lib/opensearch/api/actions/indices/get_field_mapping.rb +1 -10
  19. data/lib/opensearch/api/actions/indices/get_mapping.rb +1 -10
  20. data/lib/opensearch/api/actions/indices/get_template.rb +0 -2
  21. data/lib/opensearch/api/actions/indices/put_mapping.rb +1 -12
  22. data/lib/opensearch/api/actions/indices/put_template.rb +0 -2
  23. data/lib/opensearch/api/actions/indices/rollover.rb +0 -2
  24. data/lib/opensearch/api/actions/indices/validate_query.rb +1 -6
  25. data/lib/opensearch/api/actions/mget.rb +2 -7
  26. data/lib/opensearch/api/actions/msearch.rb +1 -6
  27. data/lib/opensearch/api/actions/msearch_template.rb +1 -6
  28. data/lib/opensearch/api/actions/mtermvectors.rb +1 -6
  29. data/lib/opensearch/api/actions/search.rb +1 -7
  30. data/lib/opensearch/api/actions/search_template.rb +1 -6
  31. data/lib/opensearch/api/actions/termvectors.rb +1 -8
  32. data/lib/opensearch/api/actions/update.rb +1 -8
  33. data/lib/opensearch/api/actions/update_by_query.rb +1 -8
  34. data/lib/opensearch/api/utils.rb +1 -1
  35. data/lib/opensearch/api/version.rb +1 -1
  36. data/lib/opensearch/api.rb +1 -1
  37. data/opensearch-api.gemspec +0 -1
  38. data/spec/opensearch/api/actions/bulk_spec.rb +10 -21
  39. data/spec/opensearch/api/actions/count_spec.rb +3 -3
  40. data/spec/opensearch/api/actions/create_document_spec.rb +8 -8
  41. data/spec/opensearch/api/actions/delete_by_query_spec.rb +0 -17
  42. data/spec/opensearch/api/actions/delete_document_spec.rb +10 -10
  43. data/spec/opensearch/api/actions/exists_document_spec.rb +10 -10
  44. data/spec/opensearch/api/actions/explain_document_spec.rb +8 -8
  45. data/spec/opensearch/api/actions/get_document_source_spec.rb +6 -6
  46. data/spec/opensearch/api/actions/get_document_spec.rb +8 -8
  47. data/spec/opensearch/api/actions/index_document_spec.rb +12 -12
  48. data/spec/opensearch/api/actions/indices/get_field_mapping_spec.rb +0 -11
  49. data/spec/opensearch/api/actions/indices/get_mapping_spec.rb +5 -16
  50. data/spec/opensearch/api/actions/indices/put_mapping_spec.rb +8 -21
  51. data/spec/opensearch/api/actions/indices/validate_query_spec.rb +0 -10
  52. data/spec/opensearch/api/actions/mget_spec.rb +2 -17
  53. data/spec/opensearch/api/actions/mtermvectors_spec.rb +3 -3
  54. data/spec/opensearch/api/actions/search_spec.rb +5 -16
  55. data/spec/opensearch/api/actions/termvectors_spec.rb +5 -5
  56. data/spec/opensearch/api/actions/update_document_spec.rb +11 -11
  57. data/spec/opensearch/api/utils_spec.rb +1 -8
  58. data.tar.gz.sig +0 -0
  59. metadata +2 -22
  60. metadata.gz.sig +0 -0
  61. data/lib/opensearch/api/actions/indices/exists_type.rb +0 -79
  62. data/lib/opensearch/api/actions/indices/flush_synced.rb +0 -79
  63. data/spec/opensearch/api/actions/indices/exists_type_spec.rb +0 -117
  64. data/spec/opensearch/api/actions/indices/flush_synced_spec.rb +0 -99
@@ -1,79 +0,0 @@
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
- # Licensed to Elasticsearch B.V. under one or more contributor
11
- # license agreements. See the NOTICE file distributed with
12
- # this work for additional information regarding copyright
13
- # ownership. Elasticsearch B.V. licenses this file to you under
14
- # the Apache License, Version 2.0 (the "License"); you may
15
- # not use this file except in compliance with the License.
16
- # You may obtain a copy of the License at
17
- #
18
- # http://www.apache.org/licenses/LICENSE-2.0
19
- #
20
- # Unless required by applicable law or agreed to in writing,
21
- # software distributed under the License is distributed on an
22
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23
- # KIND, either express or implied. See the License for the
24
- # specific language governing permissions and limitations
25
- # under the License.
26
-
27
- module OpenSearch
28
- module API
29
- module Indices
30
- module Actions
31
- # Returns information about whether a particular document type exists. (DEPRECATED)
32
- #
33
- # @option arguments [List] :index A comma-separated list of index names; use `_all` to check the types across all indices
34
- # @option arguments [List] :type A comma-separated list of document types to check
35
- # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
36
- # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
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
- # @option arguments [Boolean] :local Return local information, do not retrieve the state from master node (default: false)
39
- # @option arguments [Hash] :headers Custom HTTP headers
40
- #
41
- #
42
- def exists_type(arguments = {})
43
- raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
44
- raise ArgumentError, "Required argument 'type' missing" unless arguments[:type]
45
-
46
- headers = arguments.delete(:headers) || {}
47
-
48
- arguments = arguments.clone
49
-
50
- _index = arguments.delete(:index)
51
-
52
- _type = arguments.delete(:type)
53
-
54
- method = OpenSearch::API::HTTP_HEAD
55
- path = "#{Utils.__listify(_index)}/_mapping/#{Utils.__listify(_type)}"
56
- params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
57
-
58
- body = nil
59
-
60
- Utils.__rescue_from_not_found do
61
- perform_request(method, path, params, body, headers).status == 200 ? true : false
62
- end
63
- end
64
-
65
- alias_method :exists_type?, :exists_type
66
-
67
- # Register this action with its valid params when the module is loaded.
68
- #
69
- # @since 6.2.0
70
- ParamsRegistry.register(:exists_type, [
71
- :ignore_unavailable,
72
- :allow_no_indices,
73
- :expand_wildcards,
74
- :local
75
- ].freeze)
76
- end
77
- end
78
- end
79
- end
@@ -1,79 +0,0 @@
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
- # Licensed to Elasticsearch B.V. under one or more contributor
11
- # license agreements. See the NOTICE file distributed with
12
- # this work for additional information regarding copyright
13
- # ownership. Elasticsearch B.V. licenses this file to you under
14
- # the Apache License, Version 2.0 (the "License"); you may
15
- # not use this file except in compliance with the License.
16
- # You may obtain a copy of the License at
17
- #
18
- # http://www.apache.org/licenses/LICENSE-2.0
19
- #
20
- # Unless required by applicable law or agreed to in writing,
21
- # software distributed under the License is distributed on an
22
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23
- # KIND, either express or implied. See the License for the
24
- # specific language governing permissions and limitations
25
- # under the License.
26
-
27
- module OpenSearch
28
- module API
29
- module Indices
30
- module Actions
31
- # Performs a synced flush operation on one or more indices. Synced flush is deprecated and will be removed in 8.0. Use flush instead
32
- #
33
- # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string for all indices
34
- # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
35
- # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)
36
- # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, none, all)
37
- # @option arguments [Hash] :headers Custom HTTP headers
38
- #
39
- # *Deprecation notice*:
40
- # Synced flush is deprecated and will be removed in 8.0. Use flush instead.
41
- # Deprecated since version 7.6.0
42
- #
43
- #
44
- #
45
- def flush_synced(arguments = {})
46
- headers = arguments.delete(:headers) || {}
47
-
48
- arguments = arguments.clone
49
-
50
- _index = arguments.delete(:index)
51
-
52
- method = OpenSearch::API::HTTP_POST
53
- path = if _index
54
- "#{Utils.__listify(_index)}/_flush/synced"
55
- else
56
- "_flush/synced"
57
- end
58
- params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
59
-
60
- body = nil
61
- if Array(arguments[:ignore]).include?(404)
62
- Utils.__rescue_from_not_found { perform_request(method, path, params, body, headers).body }
63
- else
64
- perform_request(method, path, params, body, headers).body
65
- end
66
- end
67
-
68
- # Register this action with its valid params when the module is loaded.
69
- #
70
- # @since 6.2.0
71
- ParamsRegistry.register(:flush_synced, [
72
- :ignore_unavailable,
73
- :allow_no_indices,
74
- :expand_wildcards
75
- ].freeze)
76
- end
77
- end
78
- end
79
- end
@@ -1,117 +0,0 @@
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
- # Licensed to Elasticsearch B.V. under one or more contributor
11
- # license agreements. See the NOTICE file distributed with
12
- # this work for additional information regarding copyright
13
- # ownership. Elasticsearch B.V. licenses this file to you under
14
- # the Apache License, Version 2.0 (the "License"); you may
15
- # not use this file except in compliance with the License.
16
- # You may obtain a copy of the License at
17
- #
18
- # http://www.apache.org/licenses/LICENSE-2.0
19
- #
20
- # Unless required by applicable law or agreed to in writing,
21
- # software distributed under the License is distributed on an
22
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23
- # KIND, either express or implied. See the License for the
24
- # specific language governing permissions and limitations
25
- # under the License.
26
-
27
- require 'spec_helper'
28
-
29
- describe 'client.indices#exists_type' do
30
-
31
- let(:expected_args) do
32
- [
33
- 'HEAD',
34
- url,
35
- params,
36
- nil,
37
- {}
38
- ]
39
- end
40
-
41
- let(:params) do
42
- {}
43
- end
44
-
45
- let(:url) do
46
- 'foo/_mapping/bar'
47
- end
48
-
49
- it 'performs the request' do
50
- expect(client_double.indices.exists_type(index: 'foo', type: 'bar')).to eq(true)
51
- end
52
-
53
- it 'aliased to a predicate method' do
54
- expect(client_double.indices.exists_type?(index: 'foo', type: 'bar')).to eq(true)
55
- end
56
-
57
- context 'when multiple indices are specified' do
58
-
59
- let(:url) do
60
- 'foo,bar/_mapping/bam'
61
- end
62
-
63
- it 'performs the request' do
64
- expect(client_double.indices.exists_type(index: ['foo','bar'], type: 'bam')).to eq(true)
65
- end
66
- end
67
-
68
- context 'when the path needs to be URL-escaped' do
69
-
70
- let(:url) do
71
- 'foo%5Ebar/_mapping/bar%2Fbam'
72
- end
73
-
74
- it 'performs the request' do
75
- expect(client_double.indices.exists_type(index: 'foo^bar', type: 'bar/bam')).to eq(true)
76
- end
77
- end
78
-
79
- context 'when 404 response is received' do
80
-
81
- let(:response_double) do
82
- double('response', status: 404, body: {}, headers: {})
83
- end
84
-
85
- it 'returns false' do
86
- expect(client_double.indices.exists_type(index: 'foo', type: 'bar')).to eq(false)
87
- end
88
- end
89
-
90
- context 'when a \'not found\' exception is raised' do
91
-
92
- let(:client) do
93
- Class.new { include OpenSearch::API }.new.tap do |_client|
94
- expect(_client).to receive(:perform_request).with(*expected_args).and_raise(StandardError.new('404 Not Found'))
95
- end
96
- end
97
-
98
- it 'returns false' do
99
- expect(client.indices.exists_type(index: 'foo', type: 'bar')).to eq(false)
100
- end
101
- end
102
-
103
- context 'when a generic exception is raised' do
104
-
105
- let(:client) do
106
- Class.new { include OpenSearch::API }.new.tap do |_client|
107
- expect(_client).to receive(:perform_request).with(*expected_args).and_raise(StandardError.new)
108
- end
109
- end
110
-
111
- it 'raises the exception' do
112
- expect {
113
- client.indices.exists_type(index: 'foo', type: 'bar')
114
- }.to raise_exception(StandardError)
115
- end
116
- end
117
- end
@@ -1,99 +0,0 @@
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
- # Licensed to Elasticsearch B.V. under one or more contributor
11
- # license agreements. See the NOTICE file distributed with
12
- # this work for additional information regarding copyright
13
- # ownership. Elasticsearch B.V. licenses this file to you under
14
- # the Apache License, Version 2.0 (the "License"); you may
15
- # not use this file except in compliance with the License.
16
- # You may obtain a copy of the License at
17
- #
18
- # http://www.apache.org/licenses/LICENSE-2.0
19
- #
20
- # Unless required by applicable law or agreed to in writing,
21
- # software distributed under the License is distributed on an
22
- # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
23
- # KIND, either express or implied. See the License for the
24
- # specific language governing permissions and limitations
25
- # under the License.
26
-
27
- require 'spec_helper'
28
-
29
- describe 'client.indices#flush_synced' do
30
-
31
- let(:expected_args) do
32
- [
33
- 'POST',
34
- url,
35
- params,
36
- nil,
37
- {}
38
- ]
39
- end
40
-
41
- let(:params) do
42
- {}
43
- end
44
-
45
- let(:url) do
46
- 'foo/_flush/synced'
47
- end
48
-
49
- it 'performs the request' do
50
- expect(client_double.indices.flush_synced(index: 'foo')).to eq({})
51
- end
52
-
53
- context 'when a \'not found\' exception is raised' do
54
-
55
- let(:client) do
56
- Class.new { include OpenSearch::API }.new.tap do |_client|
57
- expect(_client).to receive(:perform_request).with(*expected_args).and_raise(NotFound)
58
- end
59
- end
60
-
61
- it 'raises the exception' do
62
- expect {
63
- client.indices.flush_synced(index: 'foo')
64
- }.to raise_exception(NotFound)
65
- end
66
- end
67
-
68
- context 'when a \'not found\' exception is raised' do
69
-
70
- let(:client) do
71
- Class.new { include OpenSearch::API }.new.tap do |_client|
72
- expect(_client).to receive(:perform_request).with(*expected_args).and_raise(NotFound)
73
- end
74
- end
75
-
76
- it 'raises the exception' do
77
- expect {
78
- client.indices.flush_synced(index: 'foo')
79
- }.to raise_exception(NotFound)
80
- end
81
- end
82
-
83
- context 'when the ignore parameter is specified' do
84
-
85
- let(:client) do
86
- Class.new { include OpenSearch::API }.new.tap do |_client|
87
- expect(_client).to receive(:perform_request).with(*expected_args).and_raise(StandardError.new('404 Not Found'))
88
- end
89
- end
90
-
91
- let(:params) do
92
- { ignore: 404 }
93
- end
94
-
95
- it 'does not raise the exception' do
96
- expect(client.indices.flush_synced(index: 'foo', ignore: 404)).to eq(false)
97
- end
98
- end
99
- end