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
@@ -1,22 +1,42 @@
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
+
1
5
  module Elasticsearch
2
6
  module API
3
7
  module Nodes
4
8
  module Actions
5
-
6
- # The cluster nodes usage API allows to retrieve information on the usage of features for each node.
9
+ # Returns low-level information about REST actions usage on nodes.
7
10
  #
8
- # @option arguments [List] :metric Limit the information returned to the specified metrics (options: _all,rest_actions)
9
11
  # @option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes
12
+ # @option arguments [List] :metric Limit the information returned to the specified metrics
13
+ # (options: _all,rest_actions)
14
+
10
15
  # @option arguments [Time] :timeout Explicit operation timeout
16
+
11
17
  #
12
- # @see http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-usage.html
18
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/cluster-nodes-usage.html
13
19
  #
14
- def usage(arguments={})
20
+ def usage(arguments = {})
21
+ arguments = arguments.clone
22
+
23
+ _node_id = arguments.delete(:node_id)
24
+
25
+ _metric = arguments.delete(:metric)
26
+
15
27
  method = Elasticsearch::API::HTTP_GET
16
- path = "_nodes/usage"
17
- params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
18
- body = nil
28
+ path = if _node_id && _metric
29
+ "_nodes/#{Utils.__listify(_node_id)}/usage/#{Utils.__listify(_metric)}"
30
+ elsif _node_id
31
+ "_nodes/#{Utils.__listify(_node_id)}/usage"
32
+ elsif _metric
33
+ "_nodes/usage/#{Utils.__listify(_metric)}"
34
+ else
35
+ "_nodes/usage"
36
+ end
37
+ params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
19
38
 
39
+ body = nil
20
40
  perform_request(method, path, params, body).body
21
41
  end
22
42
 
@@ -24,8 +44,9 @@ module Elasticsearch
24
44
  #
25
45
  # @since 6.2.0
26
46
  ParamsRegistry.register(:usage, [
27
- :timeout ].freeze)
47
+ :timeout
48
+ ].freeze)
49
+ end
28
50
  end
29
- end
30
51
  end
31
52
  end
@@ -6,7 +6,6 @@ module Elasticsearch
6
6
  module API
7
7
  module Actions
8
8
  module ParamsRegistry
9
-
10
9
  extend self
11
10
 
12
11
  # A Mapping of all the actions to their list of valid params.
@@ -5,31 +5,30 @@
5
5
  module Elasticsearch
6
6
  module API
7
7
  module Actions
8
-
9
- # Returns true if the cluster returns a successful HTTP response, false otherwise.
10
- #
11
- # @example
8
+ # Returns whether the cluster is running.
12
9
  #
13
- # client.ping
10
+
14
11
  #
15
- # @see http://elasticsearch.org/guide/
12
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/index.html
16
13
  #
17
- def ping(arguments={})
18
- method = HTTP_HEAD
14
+ def ping(arguments = {})
15
+ arguments = arguments.clone
16
+
17
+ method = Elasticsearch::API::HTTP_HEAD
19
18
  path = ""
20
19
  params = {}
21
- body = nil
22
20
 
21
+ body = nil
23
22
  begin
24
- perform_request(method, path, params, body).status == 200 ? true : false
23
+ perform_request(method, path, params, body).status == 200 ? true : false
25
24
  rescue Exception => e
26
- if e.class.to_s =~ /NotFound|ConnectionFailed/ || e.message =~ /Not\s*Found|404|ConnectionFailed/i
25
+ if e.class.to_s =~ /NotFound|ConnectionFailed/ || e.message =~ /Not *Found|404|ConnectionFailed/i
27
26
  false
28
27
  else
29
28
  raise e
30
29
  end
31
- end
32
30
  end
31
+ end
32
+ end
33
33
  end
34
- end
35
34
  end
@@ -5,52 +5,48 @@
5
5
  module Elasticsearch
6
6
  module API
7
7
  module Actions
8
-
9
- # Store a script in an internal index (`.scripts`), to be able to reference them
10
- # in search definitions (with dynamic scripting disabled)
11
- #
12
- # @example Storing an Mvel script in Elasticsearch and using it in function score
13
- #
14
- # client.put_script id: 'my_score', body: { script: { lang: 'groovy', source: 'log(_score * factor)' } }
15
- #
16
- # client.search body: {
17
- # query: {
18
- # function_score: {
19
- # query: { match: { title: 'foo' } },
20
- # functions: [ { script_score: { script_id: 'my_score', params: { factor: 3 } } } ]
21
- # }
22
- # }
23
- # }
8
+ # Creates or updates a script.
24
9
  #
25
- # @option arguments [String] :id Script ID (*Required*)
10
+ # @option arguments [String] :id Script ID
26
11
  # @option arguments [String] :context Script context
27
- # @option arguments [Hash] :body The document (*Required*)
28
12
  # @option arguments [Time] :timeout Explicit operation timeout
29
13
  # @option arguments [Time] :master_timeout Specify timeout for connection to master
30
14
  # @option arguments [String] :context Context name to compile script against
15
+
16
+ # @option arguments [Hash] :body The document (*Required*)
31
17
  #
32
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/modules-scripting.html#_indexed_scripts
18
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/modules-scripting.html
33
19
  #
34
- def put_script(arguments={})
35
- raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
20
+ def put_script(arguments = {})
36
21
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
37
- method = HTTP_PUT
38
- path = "_scripts/#{arguments.has_key?(:lang) ? "#{arguments.delete(:lang)}/" : ''}#{arguments[:id]}"
22
+ raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
39
23
 
40
- params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
24
+ arguments = arguments.clone
25
+
26
+ _id = arguments.delete(:id)
41
27
 
42
- body = arguments[:body]
28
+ _context = arguments.delete(:context)
43
29
 
30
+ method = Elasticsearch::API::HTTP_PUT
31
+ path = if _id && _context
32
+ "_scripts/#{Utils.__listify(_id)}/#{Utils.__listify(_context)}"
33
+ else
34
+ "_scripts/#{Utils.__listify(_id)}"
35
+ end
36
+ params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
37
+
38
+ body = arguments[:body]
44
39
  perform_request(method, path, params, body).body
45
40
  end
46
41
 
47
42
  # Register this action with its valid params when the module is loaded.
48
43
  #
49
- # @since 6.1.1
44
+ # @since 6.2.0
50
45
  ParamsRegistry.register(:put_script, [
51
- :timeout,
52
- :master_timeout,
53
- :context ].freeze)
46
+ :timeout,
47
+ :master_timeout,
48
+ :context
49
+ ].freeze)
50
+ end
54
51
  end
55
- end
56
52
  end
@@ -5,26 +5,34 @@
5
5
  module Elasticsearch
6
6
  module API
7
7
  module Actions
8
-
9
- # The ranking evaluation API allows to evaluate the quality of ranked search results over a set of typical search queries.
10
- # Given this set of queries and a list of manually rated documents, the _rank_eval endpoint calculates and
11
- # returns typical information retrieval metrics like mean reciprocal rank, precision or discounted cumulative gain.
8
+ # Allows to evaluate the quality of ranked search results over a set of typical search queries
12
9
  #
13
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
14
- # @option arguments [Hash] :body The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. (*Required*)
15
11
  # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
16
12
  # @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)
17
- # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, none, all)
13
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both.
14
+ # (options: open,closed,none,all)
15
+
16
+ # @option arguments [Hash] :body The ranking evaluation search definition, including search requests, document ratings and ranking metric definition. (*Required*)
18
17
  #
19
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-rank-eval.html
18
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-rank-eval.html
20
19
  #
21
- def rank_eval(arguments={})
20
+ def rank_eval(arguments = {})
22
21
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
22
+
23
+ arguments = arguments.clone
24
+
25
+ _index = arguments.delete(:index)
26
+
23
27
  method = Elasticsearch::API::HTTP_GET
24
- path = "_rank_eval"
25
- params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
26
- body = arguments[:body]
28
+ path = if _index
29
+ "#{Utils.__listify(_index)}/_rank_eval"
30
+ else
31
+ "_rank_eval"
32
+ end
33
+ params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
27
34
 
35
+ body = arguments[:body]
28
36
  perform_request(method, path, params, body).body
29
37
  end
30
38
 
@@ -32,9 +40,10 @@ module Elasticsearch
32
40
  #
33
41
  # @since 6.2.0
34
42
  ParamsRegistry.register(:rank_eval, [
35
- :ignore_unavailable,
36
- :allow_no_indices,
37
- :expand_wildcards ].freeze)
43
+ :ignore_unavailable,
44
+ :allow_no_indices,
45
+ :expand_wildcards
46
+ ].freeze)
47
+ end
38
48
  end
39
- end
40
49
  end
@@ -5,72 +5,49 @@
5
5
  module Elasticsearch
6
6
  module API
7
7
  module Actions
8
-
9
- # Copy documents from one index to another, potentially changing
10
- # its settings, mappings and the documents itself.
11
- #
12
- # @example Copy documents into a different index
13
- #
14
- # client.reindex body: { source: { index: 'test1' }, dest: { index: 'test2' } }
15
- #
16
- # @example Limit the copied documents with a query
17
- #
18
- # client.reindex body: {
19
- # source: {
20
- # index: 'test1',
21
- # query: { terms: { category: ['one', 'two'] } }
22
- # },
23
- # dest: {
24
- # index: 'test2'
25
- # }
26
- # }
27
- #
28
- # @example Remove a field from reindexed documents
29
- #
30
- # client.reindex body: {
31
- # source: {
32
- # index: 'test1'
33
- # },
34
- # dest: {
35
- # index: 'test3'
36
- # },
37
- # script: {
38
- # inline: 'ctx._source.remove("category")'
39
- # }
40
- # }
8
+ # Allows to copy documents from one index to another, optionally filtering the source
9
+ # documents by a query, changing the destination index settings, or fetching the
10
+ # documents from a remote cluster.
41
11
  #
42
- # @option arguments [Hash] :body The search definition using the Query DSL and the prototype for the index request. (*Required*)
43
- # @option arguments [Boolean] :refresh Should the effected indexes be refreshed?
12
+ # @option arguments [Boolean] :refresh Should the affected indexes be refreshed?
44
13
  # @option arguments [Time] :timeout Time each individual bulk request should wait for shards that are unavailable.
45
14
  # @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the reindex operation. Defaults to 1, meaning the primary shard only. Set to `all` for all shard copies, otherwise set to any non-negative value less than or equal to the total number of copies for the shard (number of replicas + 1)
46
15
  # @option arguments [Boolean] :wait_for_completion Should the request should block until the reindex is complete.
47
16
  # @option arguments [Number] :requests_per_second The throttle to set on this request in sub-requests per second. -1 means no throttle.
48
17
  # @option arguments [Time] :scroll Control how long to keep the search context alive
49
18
  # @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.
19
+ # @option arguments [Number] :max_docs Maximum number of documents to process (default: all documents)
20
+
21
+ # @option arguments [Hash] :body The search definition using the Query DSL and the prototype for the index request. (*Required*)
50
22
  #
51
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html
23
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-reindex.html
52
24
  #
53
- def reindex(arguments={})
25
+ def reindex(arguments = {})
54
26
  raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
55
- method = 'POST'
27
+
28
+ arguments = arguments.clone
29
+
30
+ method = Elasticsearch::API::HTTP_POST
56
31
  path = "_reindex"
57
32
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
58
- body = arguments[:body]
59
33
 
34
+ body = arguments[:body]
60
35
  perform_request(method, path, params, body).body
61
36
  end
62
37
 
63
38
  # Register this action with its valid params when the module is loaded.
64
39
  #
65
- # @since 6.1.1
40
+ # @since 6.2.0
66
41
  ParamsRegistry.register(:reindex, [
67
- :refresh,
68
- :timeout,
69
- :wait_for_active_shards,
70
- :wait_for_completion,
71
- :requests_per_second,
72
- :scroll,
73
- :slices ].freeze)
42
+ :refresh,
43
+ :timeout,
44
+ :wait_for_active_shards,
45
+ :wait_for_completion,
46
+ :requests_per_second,
47
+ :scroll,
48
+ :slices,
49
+ :max_docs
50
+ ].freeze)
51
+ end
74
52
  end
75
- end
76
53
  end
@@ -5,21 +5,26 @@
5
5
  module Elasticsearch
6
6
  module API
7
7
  module Actions
8
-
9
- # The value of requests_per_second can be changed on a running reindex using the _rethrottle
8
+ # Changes the number of requests per second for a particular Reindex operation.
10
9
  #
11
- # @option arguments [String] :task_id The task id to rethrottle (*Required*)
12
- # @option arguments [Number] :requests_per_second The throttle to set on this request in floating sub-requests per second. -1 means set no throttle.
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
13
  #
14
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html
14
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/docs-reindex.html
15
15
  #
16
- def reindex_rethrottle(arguments={})
16
+ def reindex_rethrottle(arguments = {})
17
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
+
18
23
  method = Elasticsearch::API::HTTP_POST
19
- path = "_reindex/#{arguments[:task_id]}/_rethrottle"
20
- params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
21
- body = nil
24
+ path = "_reindex/#{Utils.__listify(_task_id)}/_rethrottle"
25
+ params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
22
26
 
27
+ body = nil
23
28
  perform_request(method, path, params, body).body
24
29
  end
25
30
 
@@ -27,7 +32,8 @@ module Elasticsearch
27
32
  #
28
33
  # @since 6.2.0
29
34
  ParamsRegistry.register(:reindex_rethrottle, [
30
- :requests_per_second ].freeze)
35
+ :requests_per_second
36
+ ].freeze)
37
+ end
31
38
  end
32
- end
33
- end
39
+ end
@@ -6,12 +6,11 @@ module Elasticsearch
6
6
  module API
7
7
  module Remote
8
8
  module Actions
9
-
10
9
  # Returns all of the configured remote cluster information
11
10
  #
12
11
  # @see http://www.elastic.co/guide/en/elasticsearch/reference/master/remote-info.html
13
12
  #
14
- def info(arguments={})
13
+ def info(arguments = {})
15
14
  method = HTTP_GET
16
15
  path = "_remote/info"
17
16
  params = {}
@@ -5,28 +5,30 @@
5
5
  module Elasticsearch
6
6
  module API
7
7
  module Actions
8
-
9
- # Pre-render search requests before they are executed and fill existing templates with template parameters
8
+ # Allows to use the Mustache language to pre-render a search definition.
10
9
  #
11
10
  # @option arguments [String] :id The id of the stored search template
11
+
12
12
  # @option arguments [Hash] :body The search definition template and its params
13
13
  #
14
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/master/search-template.html
14
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-template.html#_validating_templates
15
15
  #
16
- def render_search_template(arguments={})
17
- method = 'GET'
18
- path = "_render/template"
19
- params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
20
- body = arguments[:body]
16
+ def render_search_template(arguments = {})
17
+ arguments = arguments.clone
18
+
19
+ _id = arguments.delete(:id)
20
+
21
+ method = Elasticsearch::API::HTTP_GET
22
+ path = if _id
23
+ "_render/template/#{Utils.__listify(_id)}"
24
+ else
25
+ "_render/template"
26
+ end
27
+ params = {}
21
28
 
29
+ body = arguments[:body]
22
30
  perform_request(method, path, params, body).body
23
31
  end
24
-
25
- # Register this action with its valid params when the module is loaded.
26
- #
27
- # @since 6.1.1
28
- ParamsRegistry.register(:render_search_template, [
29
- :id ].freeze)
30
32
  end
31
- end
33
+ end
32
34
  end