elasticsearch-api 7.4.0 → 7.5.0.pre.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +16 -23
  3. data/lib/elasticsearch/api/actions/abort_benchmark.rb +1 -2
  4. data/lib/elasticsearch/api/actions/benchmark.rb +2 -3
  5. data/lib/elasticsearch/api/actions/bulk.rb +35 -68
  6. data/lib/elasticsearch/api/actions/cat/aliases.rb +30 -52
  7. data/lib/elasticsearch/api/actions/cat/allocation.rb +36 -50
  8. data/lib/elasticsearch/api/actions/cat/count.rb +25 -46
  9. data/lib/elasticsearch/api/actions/cat/fielddata.rb +31 -33
  10. data/lib/elasticsearch/api/actions/cat/health.rb +27 -37
  11. data/lib/elasticsearch/api/actions/cat/help.rb +14 -10
  12. data/lib/elasticsearch/api/actions/cat/indices.rb +45 -62
  13. data/lib/elasticsearch/api/actions/cat/master.rb +24 -34
  14. data/lib/elasticsearch/api/actions/cat/nodeattrs.rb +20 -16
  15. data/lib/elasticsearch/api/actions/cat/nodes.rb +34 -46
  16. data/lib/elasticsearch/api/actions/cat/params_registry.rb +0 -1
  17. data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +29 -35
  18. data/lib/elasticsearch/api/actions/cat/plugins.rb +21 -18
  19. data/lib/elasticsearch/api/actions/cat/recovery.rb +40 -56
  20. data/lib/elasticsearch/api/actions/cat/repositories.rb +21 -24
  21. data/lib/elasticsearch/api/actions/cat/segments.rb +29 -22
  22. data/lib/elasticsearch/api/actions/cat/shards.rb +38 -59
  23. data/lib/elasticsearch/api/actions/cat/snapshots.rb +32 -27
  24. data/lib/elasticsearch/api/actions/cat/tasks.rb +25 -19
  25. data/lib/elasticsearch/api/actions/cat/templates.rb +26 -18
  26. data/lib/elasticsearch/api/actions/cat/thread_pool.rb +36 -46
  27. data/lib/elasticsearch/api/actions/clear_scroll.rb +21 -8
  28. data/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +15 -13
  29. data/lib/elasticsearch/api/actions/cluster/get_settings.rb +18 -18
  30. data/lib/elasticsearch/api/actions/cluster/health.rb +42 -44
  31. data/lib/elasticsearch/api/actions/cluster/params_registry.rb +0 -1
  32. data/lib/elasticsearch/api/actions/cluster/pending_tasks.rb +15 -17
  33. data/lib/elasticsearch/api/actions/cluster/put_settings.rb +20 -17
  34. data/lib/elasticsearch/api/actions/cluster/remote_info.rb +8 -6
  35. data/lib/elasticsearch/api/actions/cluster/reroute.rb +25 -37
  36. data/lib/elasticsearch/api/actions/cluster/state.rb +37 -41
  37. data/lib/elasticsearch/api/actions/cluster/stats.rb +20 -12
  38. data/lib/elasticsearch/api/actions/count.rb +52 -39
  39. data/lib/elasticsearch/api/actions/create.rb +25 -26
  40. data/lib/elasticsearch/api/actions/delete.rb +43 -36
  41. data/lib/elasticsearch/api/actions/delete_by_query.rb +74 -62
  42. data/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb +39 -0
  43. data/lib/elasticsearch/api/actions/delete_by_rethrottle.rb +4 -3
  44. data/lib/elasticsearch/api/actions/delete_script.rb +19 -13
  45. data/lib/elasticsearch/api/actions/exists.rb +44 -34
  46. data/lib/elasticsearch/api/actions/exists_source.rb +43 -25
  47. data/lib/elasticsearch/api/actions/explain.rb +46 -51
  48. data/lib/elasticsearch/api/actions/field_caps.rb +27 -20
  49. data/lib/elasticsearch/api/actions/get.rb +42 -41
  50. data/lib/elasticsearch/api/actions/get_script.rb +19 -14
  51. data/lib/elasticsearch/api/actions/get_source.rb +38 -44
  52. data/lib/elasticsearch/api/actions/index.rb +60 -89
  53. data/lib/elasticsearch/api/actions/indices/analyze.rb +19 -48
  54. data/lib/elasticsearch/api/actions/indices/clear_cache.rb +29 -41
  55. data/lib/elasticsearch/api/actions/indices/clone.rb +21 -21
  56. data/lib/elasticsearch/api/actions/indices/close.rb +28 -32
  57. data/lib/elasticsearch/api/actions/indices/create.rb +22 -70
  58. data/lib/elasticsearch/api/actions/indices/delete.rb +23 -35
  59. data/lib/elasticsearch/api/actions/indices/delete_alias.rb +24 -20
  60. data/lib/elasticsearch/api/actions/indices/delete_template.rb +18 -20
  61. data/lib/elasticsearch/api/actions/indices/exists.rb +32 -34
  62. data/lib/elasticsearch/api/actions/indices/exists_alias.rb +33 -29
  63. data/lib/elasticsearch/api/actions/indices/exists_template.rb +21 -16
  64. data/lib/elasticsearch/api/actions/indices/exists_type.rb +29 -29
  65. data/lib/elasticsearch/api/actions/indices/flush.rb +28 -28
  66. data/lib/elasticsearch/api/actions/indices/flush_synced.rb +23 -12
  67. data/lib/elasticsearch/api/actions/indices/forcemerge.rb +26 -41
  68. data/lib/elasticsearch/api/actions/indices/freeze.rb +7 -8
  69. data/lib/elasticsearch/api/actions/indices/get.rb +25 -19
  70. data/lib/elasticsearch/api/actions/indices/get_alias.rb +31 -23
  71. data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +42 -38
  72. data/lib/elasticsearch/api/actions/indices/get_mapping.rb +39 -31
  73. data/lib/elasticsearch/api/actions/indices/get_settings.rb +34 -37
  74. data/lib/elasticsearch/api/actions/indices/get_template.rb +21 -23
  75. data/lib/elasticsearch/api/actions/indices/get_upgrade.rb +48 -0
  76. data/lib/elasticsearch/api/actions/indices/open.rb +24 -21
  77. data/lib/elasticsearch/api/actions/indices/params_registry.rb +0 -1
  78. data/lib/elasticsearch/api/actions/indices/put_alias.rb +25 -27
  79. data/lib/elasticsearch/api/actions/indices/put_mapping.rb +40 -39
  80. data/lib/elasticsearch/api/actions/indices/put_settings.rb +30 -37
  81. data/lib/elasticsearch/api/actions/indices/put_template.rb +23 -23
  82. data/lib/elasticsearch/api/actions/indices/recovery.rb +20 -23
  83. data/lib/elasticsearch/api/actions/indices/refresh.rb +22 -26
  84. data/lib/elasticsearch/api/actions/indices/rollover.rb +28 -19
  85. data/lib/elasticsearch/api/actions/indices/segments.rb +24 -17
  86. data/lib/elasticsearch/api/actions/indices/shard_stores.rb +27 -15
  87. data/lib/elasticsearch/api/actions/indices/shrink.rb +23 -17
  88. data/lib/elasticsearch/api/actions/indices/split.rb +23 -17
  89. data/lib/elasticsearch/api/actions/indices/stats.rb +53 -104
  90. data/lib/elasticsearch/api/actions/indices/unfreeze.rb +7 -7
  91. data/lib/elasticsearch/api/actions/indices/update_aliases.rb +15 -32
  92. data/lib/elasticsearch/api/actions/indices/upgrade.rb +26 -16
  93. data/lib/elasticsearch/api/actions/indices/validate_query.rb +46 -59
  94. data/lib/elasticsearch/api/actions/info.rb +9 -6
  95. data/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb +18 -12
  96. data/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +21 -11
  97. data/lib/elasticsearch/api/actions/ingest/params_registry.rb +0 -1
  98. data/lib/elasticsearch/api/actions/ingest/processor_grok.rb +12 -13
  99. data/lib/elasticsearch/api/actions/ingest/put_pipeline.rb +19 -14
  100. data/lib/elasticsearch/api/actions/ingest/simulate.rb +23 -13
  101. data/lib/elasticsearch/api/actions/mget.rb +37 -44
  102. data/lib/elasticsearch/api/actions/msearch.rb +54 -54
  103. data/lib/elasticsearch/api/actions/msearch_template.rb +46 -35
  104. data/lib/elasticsearch/api/actions/mtermvectors.rb +39 -35
  105. data/lib/elasticsearch/api/actions/nodes/hot_threads.rb +30 -25
  106. data/lib/elasticsearch/api/actions/nodes/info.rb +29 -63
  107. data/lib/elasticsearch/api/actions/nodes/params_registry.rb +0 -1
  108. data/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb +24 -22
  109. data/lib/elasticsearch/api/actions/nodes/shutdown.rb +4 -4
  110. data/lib/elasticsearch/api/actions/nodes/stats.rb +43 -36
  111. data/lib/elasticsearch/api/actions/nodes/usage.rb +31 -10
  112. data/lib/elasticsearch/api/actions/params_registry.rb +0 -1
  113. data/lib/elasticsearch/api/actions/ping.rb +12 -13
  114. data/lib/elasticsearch/api/actions/put_script.rb +26 -30
  115. data/lib/elasticsearch/api/actions/rank_eval.rb +24 -15
  116. data/lib/elasticsearch/api/actions/reindex.rb +25 -48
  117. data/lib/elasticsearch/api/actions/reindex_rethrottle.rb +18 -12
  118. data/lib/elasticsearch/api/actions/remote/info.rb +1 -2
  119. data/lib/elasticsearch/api/actions/render_search_template.rb +17 -15
  120. data/lib/elasticsearch/api/actions/scripts_painless_execute.rb +8 -6
  121. data/lib/elasticsearch/api/actions/scroll.rb +28 -51
  122. data/lib/elasticsearch/api/actions/search.rb +104 -165
  123. data/lib/elasticsearch/api/actions/search_shards.rb +31 -28
  124. data/lib/elasticsearch/api/actions/search_template.rb +48 -40
  125. data/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb +44 -0
  126. data/lib/elasticsearch/api/actions/snapshot/create.rb +22 -29
  127. data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +19 -24
  128. data/lib/elasticsearch/api/actions/snapshot/delete.rb +20 -22
  129. data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +16 -18
  130. data/lib/elasticsearch/api/actions/snapshot/get.rb +22 -31
  131. data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +21 -25
  132. data/lib/elasticsearch/api/actions/snapshot/params_registry.rb +0 -1
  133. data/lib/elasticsearch/api/actions/snapshot/restore.rb +21 -32
  134. data/lib/elasticsearch/api/actions/snapshot/status.rb +23 -24
  135. data/lib/elasticsearch/api/actions/snapshot/verify_repository.rb +18 -13
  136. data/lib/elasticsearch/api/actions/tasks/cancel.rb +19 -13
  137. data/lib/elasticsearch/api/actions/tasks/get.rb +16 -13
  138. data/lib/elasticsearch/api/actions/tasks/list.rb +20 -18
  139. data/lib/elasticsearch/api/actions/tasks/params_registry.rb +0 -1
  140. data/lib/elasticsearch/api/actions/termvectors.rb +52 -70
  141. data/lib/elasticsearch/api/actions/update.rb +53 -98
  142. data/lib/elasticsearch/api/actions/update_by_query.rb +77 -66
  143. data/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb +17 -11
  144. data/lib/elasticsearch/api/version.rb +1 -1
  145. data/spec/elasticsearch/api/actions/cat/segments_spec.rb +9 -11
  146. data/spec/elasticsearch/api/actions/cluster/put_settings_spec.rb +1 -1
  147. data/spec/elasticsearch/api/actions/count_spec.rb +8 -8
  148. data/spec/elasticsearch/api/actions/delete_by_query_spec.rb +12 -7
  149. data/spec/elasticsearch/api/actions/delete_script_spec.rb +0 -14
  150. data/spec/elasticsearch/api/actions/exists_document_spec.rb +1 -1
  151. data/spec/elasticsearch/api/actions/get_document_source_spec.rb +1 -1
  152. data/spec/elasticsearch/api/actions/index_document_spec.rb +6 -15
  153. data/spec/elasticsearch/api/actions/indices/analyze_spec.rb +0 -4
  154. data/spec/elasticsearch/api/actions/indices/clear_cache_spec.rb +1 -5
  155. data/spec/elasticsearch/api/actions/indices/clone_spec.rb +1 -1
  156. data/spec/elasticsearch/api/actions/indices/delete_alias_spec.rb +2 -2
  157. data/spec/elasticsearch/api/actions/indices/get_spec.rb +0 -11
  158. data/spec/elasticsearch/api/actions/indices/put_alias_spec.rb +3 -3
  159. data/spec/elasticsearch/api/actions/indices/put_mapping_spec.rb +3 -3
  160. data/spec/elasticsearch/api/actions/indices/stats_spec.rb +0 -1
  161. data/spec/elasticsearch/api/actions/nodes/hot_threads_spec.rb +3 -3
  162. data/spec/elasticsearch/api/actions/put_script_spec.rb +20 -15
  163. data/spec/elasticsearch/api/actions/render_search_template_spec.rb +23 -7
  164. data/spec/elasticsearch/api/actions/scroll_spec.rb +37 -0
  165. data/spec/elasticsearch/api/actions/search_spec.rb +0 -15
  166. data/spec/elasticsearch/api/actions/tasks/list_spec.rb +0 -11
  167. data/spec/elasticsearch/api/actions/update_document_spec.rb +3 -7
  168. data/spec/rest_yaml_tests_helper.rb +12 -0
  169. data/utils/Gemfile +1 -0
  170. data/utils/Thorfile +0 -1
  171. data/utils/thor/generate_source.rb +192 -85
  172. data/utils/thor/generator/endpoint_specifics.rb +157 -0
  173. data/utils/thor/generator/files_helper.rb +37 -0
  174. data/utils/thor/lister.rb +3 -4
  175. data/utils/thor/templates/_documentation_top.erb +27 -0
  176. data/utils/thor/templates/_method_setup.erb +35 -0
  177. data/utils/thor/templates/_params_registry.erb +12 -0
  178. data/utils/thor/templates/_perform_request.erb +37 -0
  179. data/utils/thor/templates/method.erb +59 -0
  180. data/utils/thor/templates/{ruby/test.erb → test.erb} +0 -0
  181. data/utils/thor/templates/{ruby/test_helper.rb → test_helper.rb} +0 -0
  182. metadata +19 -11
  183. data/spec/elasticsearch/api/actions/scoll_spec.rb +0 -21
  184. data/utils/thor/generate_api.rb +0 -193
  185. data/utils/thor/templates/ruby/method.erb +0 -62
@@ -5,40 +5,35 @@
5
5
  module Elasticsearch
6
6
  module API
7
7
  module Actions
8
-
9
- # Delete documents which match specified query.
10
- #
11
- # Provide the query either as a "query string" query in the `:q` argument, or using the Elasticsearch's
12
- # [Query DSL](https://www.elastic.co/guide/reference/query-dsl/) in the `:body` argument.
13
- #
14
- # @example Deleting documents with a simple query
15
- #
16
- # client.delete_by_query index: 'myindex', q: 'title:test'
17
- #
18
- # @example Deleting documents using the Query DSL
19
- #
20
- # client.delete_by_query index: 'myindex', body: { query: { term: { published: false } } }
8
+ # Deletes documents matching the provided query.
21
9
  #
22
- # @option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices (*Required*)
10
+ # @option arguments [List] :index A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices (*Required*)
23
11
  # @option arguments [List] :type A comma-separated list of document types to search; leave empty to perform the operation on all types
24
- # @option arguments [Hash] :body The search definition using the Query DSL (*Required*)
25
- # @option arguments [String] :analyzer The analyzer to use for the query string
26
12
  # @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false)
27
- # @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR)
13
+ # @option arguments [String] :default_operator The default operator for query string query (AND or OR)
14
+ # (options: AND,OR)
15
+
28
16
  # @option arguments [String] :df The field to use as default where no field prefix is given in the query string
29
17
  # @option arguments [Number] :from Starting offset (default: 0)
30
18
  # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
31
19
  # @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)
32
- # @option arguments [String] :conflicts What to do when the delete by query hits version conflicts? (options: abort, proceed)
33
- # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, none, all)
20
+ # @option arguments [String] :conflicts What to do when the delete by query hits version conflicts?
21
+ # (options: abort,proceed)
22
+
23
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both.
24
+ # (options: open,closed,none,all)
25
+
34
26
  # @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
35
27
  # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
36
28
  # @option arguments [String] :q Query in the Lucene query string syntax
37
29
  # @option arguments [List] :routing A comma-separated list of specific routing values
38
30
  # @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search
39
- # @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch)
31
+ # @option arguments [String] :search_type Search operation type
32
+ # (options: query_then_fetch,dfs_query_then_fetch)
33
+
40
34
  # @option arguments [Time] :search_timeout Explicit timeout for each search request. Defaults to no timeout.
41
- # @option arguments [Number] :size Number of hits to return (default: 10)
35
+ # @option arguments [Number] :size Deprecated, please use `max_docs` instead
36
+ # @option arguments [Number] :max_docs Maximum number of documents to process (default: all documents)
42
37
  # @option arguments [List] :sort A comma-separated list of <field>:<direction> pairs
43
38
  # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return
44
39
  # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field
@@ -54,58 +49,75 @@ module Elasticsearch
54
49
  # @option arguments [Boolean] :wait_for_completion Should the request should block until the delete by query is complete.
55
50
  # @option arguments [Number] :requests_per_second The throttle for this request in sub-requests per second. -1 means no throttle.
56
51
  # @option arguments [Number] :slices The number of slices this task should be divided into. Defaults to 1 meaning the task isn't sliced into subtasks.
52
+
53
+ # @option arguments [Hash] :body The search definition using the Query DSL (*Required*)
54
+ #
55
+ # *Deprecation notice*:
56
+ # Specifying types in urls has been deprecated
57
+ # Deprecated since version 7.0.0
57
58
  #
58
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/docs-delete-by-query.html
59
59
  #
60
- def delete_by_query(arguments={})
60
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-delete-by-query.html
61
+ #
62
+ def delete_by_query(arguments = {})
63
+ raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
61
64
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
62
- method = HTTP_POST
63
- path = Utils.__pathify Utils.__listify(arguments[:index]),
64
- Utils.__listify(arguments[:type]),
65
- '/_delete_by_query'
66
65
 
66
+ arguments = arguments.clone
67
+
68
+ _index = arguments.delete(:index)
69
+
70
+ _type = arguments.delete(:type)
71
+
72
+ method = Elasticsearch::API::HTTP_POST
73
+ path = if _index && _type
74
+ "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/_delete_by_query"
75
+ else
76
+ "#{Utils.__listify(_index)}/_delete_by_query"
77
+ end
67
78
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
68
- body = arguments[:body]
69
79
 
80
+ body = arguments[:body]
70
81
  perform_request(method, path, params, body).body
71
82
  end
72
83
 
73
84
  # Register this action with its valid params when the module is loaded.
74
85
  #
75
- # @since 6.1.1
86
+ # @since 6.2.0
76
87
  ParamsRegistry.register(:delete_by_query, [
77
- :analyzer,
78
- :analyze_wildcard,
79
- :default_operator,
80
- :df,
81
- :from,
82
- :ignore_unavailable,
83
- :allow_no_indices,
84
- :conflicts,
85
- :expand_wildcards,
86
- :lenient,
87
- :preference,
88
- :q,
89
- :routing,
90
- :scroll,
91
- :search_type,
92
- :search_timeout,
93
- :size,
94
- :sort,
95
- :_source,
96
- :_source_excludes,
97
- :_source_includes,
98
- :terminate_after,
99
- :stats,
100
- :version,
101
- :request_cache,
102
- :refresh,
103
- :timeout,
104
- :wait_for_active_shards,
105
- :scroll_size,
106
- :wait_for_completion,
107
- :requests_per_second,
108
- :slices ].freeze)
88
+ :analyze_wildcard,
89
+ :default_operator,
90
+ :df,
91
+ :from,
92
+ :ignore_unavailable,
93
+ :allow_no_indices,
94
+ :conflicts,
95
+ :expand_wildcards,
96
+ :lenient,
97
+ :preference,
98
+ :q,
99
+ :routing,
100
+ :scroll,
101
+ :search_type,
102
+ :search_timeout,
103
+ :size,
104
+ :max_docs,
105
+ :sort,
106
+ :_source,
107
+ :_source_excludes,
108
+ :_source_includes,
109
+ :terminate_after,
110
+ :stats,
111
+ :version,
112
+ :request_cache,
113
+ :refresh,
114
+ :timeout,
115
+ :wait_for_active_shards,
116
+ :scroll_size,
117
+ :wait_for_completion,
118
+ :requests_per_second,
119
+ :slices
120
+ ].freeze)
121
+ end
109
122
  end
110
- end
111
123
  end
@@ -0,0 +1,39 @@
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
+ module Elasticsearch
6
+ module API
7
+ module Actions
8
+ # Changes the number of requests per second for a particular Delete By Query operation.
9
+ #
10
+ # @option arguments [String] :task_id The task id to rethrottle
11
+ # @option arguments [Number] :requests_per_second The throttle to set on this request in floating sub-requests per second. -1 means set no throttle. (*Required*)
12
+
13
+ #
14
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-delete-by-query.html
15
+ #
16
+ def delete_by_query_rethrottle(arguments = {})
17
+ raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id]
18
+
19
+ arguments = arguments.clone
20
+
21
+ _task_id = arguments.delete(:task_id)
22
+
23
+ method = Elasticsearch::API::HTTP_POST
24
+ path = "_delete_by_query/#{Utils.__listify(_task_id)}/_rethrottle"
25
+ params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
26
+
27
+ body = nil
28
+ perform_request(method, path, params, body).body
29
+ end
30
+
31
+ # Register this action with its valid params when the module is loaded.
32
+ #
33
+ # @since 6.2.0
34
+ ParamsRegistry.register(:delete_by_query_rethrottle, [
35
+ :requests_per_second
36
+ ].freeze)
37
+ end
38
+ end
39
+ end
@@ -5,7 +5,6 @@
5
5
  module Elasticsearch
6
6
  module API
7
7
  module Actions
8
-
9
8
  # The value of requests_per_second can be changed on a running delete by query using the _rethrottle API
10
9
  #
11
10
  # @option arguments [String] :task_id The task id to rethrottle (*Required*)
@@ -13,8 +12,9 @@ module Elasticsearch
13
12
  #
14
13
  # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html
15
14
  #
16
- def delete_by_query_rethrottle(arguments={})
15
+ def delete_by_query_rethrottle(arguments = {})
17
16
  raise ArgumentError, "Required argument 'task_id' missing" unless arguments[:task_id]
17
+
18
18
  method = Elasticsearch::API::HTTP_POST
19
19
  path = "_delete_by_query/#{arguments[:task_id]}/_rethrottle"
20
20
  params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
@@ -27,7 +27,8 @@ module Elasticsearch
27
27
  #
28
28
  # @since 6.2.0
29
29
  ParamsRegistry.register(:delete_by_query_rethrottle, [
30
- :requests_per_second ].freeze)
30
+ :requests_per_second
31
+ ].freeze)
31
32
  end
32
33
  end
33
34
  end
@@ -5,31 +5,37 @@
5
5
  module Elasticsearch
6
6
  module API
7
7
  module Actions
8
-
9
- # Remove an indexed script from Elasticsearch
8
+ # Deletes a script.
10
9
  #
11
- # @option arguments [String] :id Script ID (*Required*)
10
+ # @option arguments [String] :id Script ID
12
11
  # @option arguments [Time] :timeout Explicit operation timeout
13
12
  # @option arguments [Time] :master_timeout Specify timeout for connection to master
13
+
14
14
  #
15
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html
15
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/modules-scripting.html
16
16
  #
17
- def delete_script(arguments={})
18
- raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
19
- method = HTTP_DELETE
20
- path = "_scripts/#{arguments.has_key?(:lang) ? "#{arguments.delete(:lang)}/" : ''}#{arguments[:id]}"
17
+ def delete_script(arguments = {})
18
+ raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
19
+
20
+ arguments = arguments.clone
21
+
22
+ _id = arguments.delete(:id)
23
+
24
+ method = Elasticsearch::API::HTTP_DELETE
25
+ path = "_scripts/#{Utils.__listify(_id)}"
21
26
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
22
- body = nil
23
27
 
28
+ body = nil
24
29
  perform_request(method, path, params, body).body
25
30
  end
26
31
 
27
32
  # Register this action with its valid params when the module is loaded.
28
33
  #
29
- # @since 6.1.1
34
+ # @since 6.2.0
30
35
  ParamsRegistry.register(:delete_script, [
31
- :timeout,
32
- :master_timeout ].freeze)
36
+ :timeout,
37
+ :master_timeout
38
+ ].freeze)
39
+ end
33
40
  end
34
- end
35
41
  end
@@ -5,18 +5,12 @@
5
5
  module Elasticsearch
6
6
  module API
7
7
  module Actions
8
-
9
- # Return true if the specified document exists, false otherwise.
10
- #
11
- # @example
8
+ # Returns information about whether a document exists in an index.
12
9
  #
13
- # client.exists? index: 'myindex', type: 'mytype', id: '1'
14
- #
15
- # @option arguments [String] :id The document ID (*Required*)
16
- # @option arguments [String] :index The name of the index (*Required*)
17
- # @option arguments [String] :type The type of the document (use `_all` to fetch the first document matching the ID across all types)
10
+ # @option arguments [String] :id The document ID
11
+ # @option arguments [String] :index The name of the index
12
+ # @option arguments [String] :type The type of the document (use `_all` to fetch the first document matching the ID across all types) *Deprecated*
18
13
  # @option arguments [List] :stored_fields A comma-separated list of stored fields to return in the response
19
- # @option arguments [String] :parent The ID of the parent document
20
14
  # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
21
15
  # @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode
22
16
  # @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation
@@ -25,44 +19,60 @@ module Elasticsearch
25
19
  # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field
26
20
  # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field
27
21
  # @option arguments [Number] :version Explicit version number for concurrency control
28
- # @option arguments [String] :version_type Specific version type (options: internal, external, external_gte, force)
22
+ # @option arguments [String] :version_type Specific version type
23
+ # (options: internal,external,external_gte,force)
29
24
 
30
25
  #
31
- # @see http://elasticsearch.org/guide/reference/api/get/
26
+ # *Deprecation notice*:
27
+ # Specifying types in urls has been deprecated
28
+ # Deprecated since version 7.0.0
29
+ #
32
30
  #
33
- def exists(arguments={})
34
- raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
31
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-get.html
32
+ #
33
+ def exists(arguments = {})
35
34
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
36
- arguments[:type] ||= UNDERSCORE_ALL
37
- method = HTTP_HEAD
38
- path = Utils.__pathify Utils.__escape(arguments[:index]),
39
- Utils.__escape(arguments[:type]),
40
- Utils.__escape(arguments[:id])
35
+ raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
36
+
37
+ arguments = arguments.clone
38
+
39
+ _id = arguments.delete(:id)
40
+
41
+ _index = arguments.delete(:index)
41
42
 
43
+ _type = arguments.delete(:type)
44
+
45
+ method = Elasticsearch::API::HTTP_HEAD
46
+ path = if _index && _type && _id
47
+ "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}"
48
+ else
49
+ "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
50
+ end
42
51
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
43
- body = nil
52
+
53
+ body = nil
44
54
 
45
55
  Utils.__rescue_from_not_found do
46
56
  perform_request(method, path, params, body).status == 200 ? true : false
47
57
  end
48
58
  end
49
- alias_method :exists?, :exists
50
59
 
60
+ alias_method :exists?, :exists
51
61
  # Register this action with its valid params when the module is loaded.
52
62
  #
53
- # @since 6.1.1
63
+ # @since 6.2.0
54
64
  ParamsRegistry.register(:exists, [
55
- :stored_fields,
56
- :parent,
57
- :preference,
58
- :realtime,
59
- :refresh,
60
- :routing,
61
- :_source,
62
- :_source_excludes,
63
- :_source_includes,
64
- :version,
65
- :version_type ].freeze)
65
+ :stored_fields,
66
+ :preference,
67
+ :realtime,
68
+ :refresh,
69
+ :routing,
70
+ :_source,
71
+ :_source_excludes,
72
+ :_source_includes,
73
+ :version,
74
+ :version_type
75
+ ].freeze)
76
+ end
66
77
  end
67
- end
68
78
  end
@@ -5,13 +5,11 @@
5
5
  module Elasticsearch
6
6
  module API
7
7
  module Actions
8
-
9
- # The get API allows to get a typed JSON document from the index based on its id.
8
+ # Returns information about whether a document source exists in an index.
10
9
  #
11
- # @option arguments [String] :id The document ID (*Required*)
12
- # @option arguments [String] :index The name of the index (*Required*)
13
- # @option arguments [String] :type The type of the document; use `_all` to fetch the first document matching the ID across all types (*Required*)
14
- # @option arguments [String] :parent The ID of the parent document
10
+ # @option arguments [String] :id The document ID
11
+ # @option arguments [String] :index The name of the index
12
+ # @option arguments [String] :type The type of the document; deprecated and optional starting with 7.0 *Deprecated*
15
13
  # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
16
14
  # @option arguments [Boolean] :realtime Specify whether to perform the operation in realtime or search mode
17
15
  # @option arguments [Boolean] :refresh Refresh the shard containing the document before performing the operation
@@ -20,36 +18,56 @@ module Elasticsearch
20
18
  # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field
21
19
  # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field
22
20
  # @option arguments [Number] :version Explicit version number for concurrency control
23
- # @option arguments [String] :version_type Specific version type (options: internal, external, external_gte, force)
21
+ # @option arguments [String] :version_type Specific version type
22
+ # (options: internal,external,external_gte,force)
23
+
24
24
  #
25
- # @see http://www.elastic.co/guide/en/elasticsearch/reference/current/docs-get.html
25
+ # *Deprecation notice*:
26
+ # Specifying types in urls has been deprecated
27
+ # Deprecated since version 7.0.0
26
28
  #
27
- def exists_source(arguments={})
28
- raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
29
+ #
30
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-get.html
31
+ #
32
+ def exists_source(arguments = {})
29
33
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
30
- raise ArgumentError, "Required argument 'type' missing" unless arguments[:type]
34
+ raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
35
+
36
+ arguments = arguments.clone
37
+
38
+ _id = arguments.delete(:id)
39
+
40
+ _index = arguments.delete(:index)
41
+
42
+ _type = arguments.delete(:type)
43
+
31
44
  method = Elasticsearch::API::HTTP_HEAD
32
- path = "#{arguments[:index]}/#{arguments[:type]}/#{arguments[:id]}/_source"
33
- params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
34
- body = nil
45
+ path = if _index && _type && _id
46
+ "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}/_source"
47
+ else
48
+ "#{Utils.__listify(_index)}/_source/#{Utils.__listify(_id)}"
49
+ end
50
+ params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
35
51
 
52
+ body = nil
36
53
  perform_request(method, path, params, body).body
37
54
  end
38
55
 
56
+ alias_method :exists_source?, :exists_source
39
57
  # Register this action with its valid params when the module is loaded.
40
58
  #
41
59
  # @since 6.2.0
42
60
  ParamsRegistry.register(:exists_source, [
43
- :parent,
44
- :preference,
45
- :realtime,
46
- :refresh,
47
- :routing,
48
- :_source,
49
- :_source_excludes,
50
- :_source_includes,
51
- :version,
52
- :version_type ].freeze)
61
+ :preference,
62
+ :realtime,
63
+ :refresh,
64
+ :routing,
65
+ :_source,
66
+ :_source_excludes,
67
+ :_source_includes,
68
+ :version,
69
+ :version_type
70
+ ].freeze)
71
+ end
53
72
  end
54
- end
55
73
  end