elasticsearch-api 7.3.0 → 7.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (187) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +16 -23
  3. data/elasticsearch-api.gemspec +1 -1
  4. data/lib/elasticsearch/api/actions/abort_benchmark.rb +1 -2
  5. data/lib/elasticsearch/api/actions/benchmark.rb +2 -3
  6. data/lib/elasticsearch/api/actions/bulk.rb +35 -68
  7. data/lib/elasticsearch/api/actions/cat/aliases.rb +30 -52
  8. data/lib/elasticsearch/api/actions/cat/allocation.rb +36 -50
  9. data/lib/elasticsearch/api/actions/cat/count.rb +25 -46
  10. data/lib/elasticsearch/api/actions/cat/fielddata.rb +31 -33
  11. data/lib/elasticsearch/api/actions/cat/health.rb +27 -37
  12. data/lib/elasticsearch/api/actions/cat/help.rb +14 -10
  13. data/lib/elasticsearch/api/actions/cat/indices.rb +45 -62
  14. data/lib/elasticsearch/api/actions/cat/master.rb +24 -34
  15. data/lib/elasticsearch/api/actions/cat/nodeattrs.rb +20 -16
  16. data/lib/elasticsearch/api/actions/cat/nodes.rb +34 -46
  17. data/lib/elasticsearch/api/actions/cat/params_registry.rb +0 -1
  18. data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +29 -35
  19. data/lib/elasticsearch/api/actions/cat/plugins.rb +21 -18
  20. data/lib/elasticsearch/api/actions/cat/recovery.rb +40 -56
  21. data/lib/elasticsearch/api/actions/cat/repositories.rb +21 -24
  22. data/lib/elasticsearch/api/actions/cat/segments.rb +29 -22
  23. data/lib/elasticsearch/api/actions/cat/shards.rb +38 -59
  24. data/lib/elasticsearch/api/actions/cat/snapshots.rb +32 -27
  25. data/lib/elasticsearch/api/actions/cat/tasks.rb +25 -19
  26. data/lib/elasticsearch/api/actions/cat/templates.rb +26 -18
  27. data/lib/elasticsearch/api/actions/cat/thread_pool.rb +36 -46
  28. data/lib/elasticsearch/api/actions/clear_scroll.rb +21 -8
  29. data/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +15 -13
  30. data/lib/elasticsearch/api/actions/cluster/get_settings.rb +18 -18
  31. data/lib/elasticsearch/api/actions/cluster/health.rb +42 -44
  32. data/lib/elasticsearch/api/actions/cluster/params_registry.rb +0 -1
  33. data/lib/elasticsearch/api/actions/cluster/pending_tasks.rb +15 -17
  34. data/lib/elasticsearch/api/actions/cluster/put_settings.rb +20 -17
  35. data/lib/elasticsearch/api/actions/cluster/remote_info.rb +8 -6
  36. data/lib/elasticsearch/api/actions/cluster/reroute.rb +25 -37
  37. data/lib/elasticsearch/api/actions/cluster/state.rb +37 -41
  38. data/lib/elasticsearch/api/actions/cluster/stats.rb +20 -12
  39. data/lib/elasticsearch/api/actions/count.rb +52 -39
  40. data/lib/elasticsearch/api/actions/create.rb +25 -26
  41. data/lib/elasticsearch/api/actions/delete.rb +43 -36
  42. data/lib/elasticsearch/api/actions/delete_by_query.rb +74 -62
  43. data/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb +39 -0
  44. data/lib/elasticsearch/api/actions/delete_by_rethrottle.rb +4 -3
  45. data/lib/elasticsearch/api/actions/delete_script.rb +19 -13
  46. data/lib/elasticsearch/api/actions/exists.rb +44 -34
  47. data/lib/elasticsearch/api/actions/exists_source.rb +43 -25
  48. data/lib/elasticsearch/api/actions/explain.rb +46 -51
  49. data/lib/elasticsearch/api/actions/field_caps.rb +27 -20
  50. data/lib/elasticsearch/api/actions/get.rb +42 -41
  51. data/lib/elasticsearch/api/actions/get_script.rb +19 -14
  52. data/lib/elasticsearch/api/actions/get_source.rb +38 -44
  53. data/lib/elasticsearch/api/actions/index.rb +60 -89
  54. data/lib/elasticsearch/api/actions/indices/analyze.rb +19 -48
  55. data/lib/elasticsearch/api/actions/indices/clear_cache.rb +29 -41
  56. data/lib/elasticsearch/api/actions/indices/clone.rb +50 -0
  57. data/lib/elasticsearch/api/actions/indices/close.rb +28 -32
  58. data/lib/elasticsearch/api/actions/indices/create.rb +22 -70
  59. data/lib/elasticsearch/api/actions/indices/delete.rb +23 -35
  60. data/lib/elasticsearch/api/actions/indices/delete_alias.rb +24 -20
  61. data/lib/elasticsearch/api/actions/indices/delete_template.rb +18 -20
  62. data/lib/elasticsearch/api/actions/indices/exists.rb +32 -34
  63. data/lib/elasticsearch/api/actions/indices/exists_alias.rb +33 -29
  64. data/lib/elasticsearch/api/actions/indices/exists_template.rb +21 -16
  65. data/lib/elasticsearch/api/actions/indices/exists_type.rb +29 -29
  66. data/lib/elasticsearch/api/actions/indices/flush.rb +28 -28
  67. data/lib/elasticsearch/api/actions/indices/flush_synced.rb +23 -12
  68. data/lib/elasticsearch/api/actions/indices/forcemerge.rb +26 -41
  69. data/lib/elasticsearch/api/actions/indices/freeze.rb +7 -8
  70. data/lib/elasticsearch/api/actions/indices/get.rb +25 -19
  71. data/lib/elasticsearch/api/actions/indices/get_alias.rb +31 -23
  72. data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +42 -38
  73. data/lib/elasticsearch/api/actions/indices/get_mapping.rb +39 -31
  74. data/lib/elasticsearch/api/actions/indices/get_settings.rb +34 -37
  75. data/lib/elasticsearch/api/actions/indices/get_template.rb +21 -23
  76. data/lib/elasticsearch/api/actions/indices/get_upgrade.rb +48 -0
  77. data/lib/elasticsearch/api/actions/indices/open.rb +24 -21
  78. data/lib/elasticsearch/api/actions/indices/params_registry.rb +0 -1
  79. data/lib/elasticsearch/api/actions/indices/put_alias.rb +25 -27
  80. data/lib/elasticsearch/api/actions/indices/put_mapping.rb +40 -39
  81. data/lib/elasticsearch/api/actions/indices/put_settings.rb +30 -37
  82. data/lib/elasticsearch/api/actions/indices/put_template.rb +23 -23
  83. data/lib/elasticsearch/api/actions/indices/recovery.rb +20 -23
  84. data/lib/elasticsearch/api/actions/indices/refresh.rb +22 -26
  85. data/lib/elasticsearch/api/actions/indices/rollover.rb +28 -19
  86. data/lib/elasticsearch/api/actions/indices/segments.rb +24 -17
  87. data/lib/elasticsearch/api/actions/indices/shard_stores.rb +27 -15
  88. data/lib/elasticsearch/api/actions/indices/shrink.rb +23 -17
  89. data/lib/elasticsearch/api/actions/indices/split.rb +23 -17
  90. data/lib/elasticsearch/api/actions/indices/stats.rb +53 -104
  91. data/lib/elasticsearch/api/actions/indices/unfreeze.rb +7 -7
  92. data/lib/elasticsearch/api/actions/indices/update_aliases.rb +15 -32
  93. data/lib/elasticsearch/api/actions/indices/upgrade.rb +26 -16
  94. data/lib/elasticsearch/api/actions/indices/validate_query.rb +46 -59
  95. data/lib/elasticsearch/api/actions/info.rb +9 -6
  96. data/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb +18 -12
  97. data/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +21 -11
  98. data/lib/elasticsearch/api/actions/ingest/params_registry.rb +0 -1
  99. data/lib/elasticsearch/api/actions/ingest/processor_grok.rb +12 -13
  100. data/lib/elasticsearch/api/actions/ingest/put_pipeline.rb +19 -14
  101. data/lib/elasticsearch/api/actions/ingest/simulate.rb +23 -13
  102. data/lib/elasticsearch/api/actions/mget.rb +37 -44
  103. data/lib/elasticsearch/api/actions/msearch.rb +54 -54
  104. data/lib/elasticsearch/api/actions/msearch_template.rb +46 -35
  105. data/lib/elasticsearch/api/actions/mtermvectors.rb +39 -35
  106. data/lib/elasticsearch/api/actions/nodes/hot_threads.rb +30 -25
  107. data/lib/elasticsearch/api/actions/nodes/info.rb +29 -63
  108. data/lib/elasticsearch/api/actions/nodes/params_registry.rb +0 -1
  109. data/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb +24 -22
  110. data/lib/elasticsearch/api/actions/nodes/shutdown.rb +4 -4
  111. data/lib/elasticsearch/api/actions/nodes/stats.rb +43 -36
  112. data/lib/elasticsearch/api/actions/nodes/usage.rb +31 -10
  113. data/lib/elasticsearch/api/actions/params_registry.rb +0 -1
  114. data/lib/elasticsearch/api/actions/ping.rb +12 -13
  115. data/lib/elasticsearch/api/actions/put_script.rb +26 -30
  116. data/lib/elasticsearch/api/actions/rank_eval.rb +24 -15
  117. data/lib/elasticsearch/api/actions/reindex.rb +25 -48
  118. data/lib/elasticsearch/api/actions/reindex_rethrottle.rb +18 -12
  119. data/lib/elasticsearch/api/actions/remote/info.rb +1 -2
  120. data/lib/elasticsearch/api/actions/render_search_template.rb +17 -15
  121. data/lib/elasticsearch/api/actions/scripts_painless_execute.rb +8 -6
  122. data/lib/elasticsearch/api/actions/scroll.rb +28 -51
  123. data/lib/elasticsearch/api/actions/search.rb +104 -165
  124. data/lib/elasticsearch/api/actions/search_shards.rb +31 -28
  125. data/lib/elasticsearch/api/actions/search_template.rb +48 -40
  126. data/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb +44 -0
  127. data/lib/elasticsearch/api/actions/snapshot/create.rb +22 -29
  128. data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +19 -24
  129. data/lib/elasticsearch/api/actions/snapshot/delete.rb +20 -22
  130. data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +16 -18
  131. data/lib/elasticsearch/api/actions/snapshot/get.rb +22 -31
  132. data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +21 -25
  133. data/lib/elasticsearch/api/actions/snapshot/params_registry.rb +0 -1
  134. data/lib/elasticsearch/api/actions/snapshot/restore.rb +21 -32
  135. data/lib/elasticsearch/api/actions/snapshot/status.rb +23 -24
  136. data/lib/elasticsearch/api/actions/snapshot/verify_repository.rb +18 -13
  137. data/lib/elasticsearch/api/actions/tasks/cancel.rb +19 -13
  138. data/lib/elasticsearch/api/actions/tasks/get.rb +16 -13
  139. data/lib/elasticsearch/api/actions/tasks/list.rb +20 -18
  140. data/lib/elasticsearch/api/actions/tasks/params_registry.rb +0 -1
  141. data/lib/elasticsearch/api/actions/termvectors.rb +52 -70
  142. data/lib/elasticsearch/api/actions/update.rb +53 -98
  143. data/lib/elasticsearch/api/actions/update_by_query.rb +77 -66
  144. data/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb +17 -11
  145. data/lib/elasticsearch/api/version.rb +1 -1
  146. data/spec/elasticsearch/api/actions/cat/segments_spec.rb +9 -11
  147. data/spec/elasticsearch/api/actions/cluster/put_settings_spec.rb +1 -1
  148. data/spec/elasticsearch/api/actions/count_spec.rb +8 -8
  149. data/spec/elasticsearch/api/actions/delete_by_query_spec.rb +12 -7
  150. data/spec/elasticsearch/api/actions/delete_script_spec.rb +0 -14
  151. data/spec/elasticsearch/api/actions/exists_document_spec.rb +1 -1
  152. data/spec/elasticsearch/api/actions/get_document_source_spec.rb +1 -1
  153. data/spec/elasticsearch/api/actions/index_document_spec.rb +6 -15
  154. data/spec/elasticsearch/api/actions/indices/analyze_spec.rb +0 -4
  155. data/spec/elasticsearch/api/actions/indices/clear_cache_spec.rb +1 -5
  156. data/spec/elasticsearch/api/actions/indices/clone_spec.rb +109 -0
  157. data/spec/elasticsearch/api/actions/indices/delete_alias_spec.rb +2 -2
  158. data/spec/elasticsearch/api/actions/indices/get_spec.rb +0 -11
  159. data/spec/elasticsearch/api/actions/indices/put_alias_spec.rb +3 -3
  160. data/spec/elasticsearch/api/actions/indices/put_mapping_spec.rb +3 -3
  161. data/spec/elasticsearch/api/actions/indices/stats_spec.rb +0 -1
  162. data/spec/elasticsearch/api/actions/nodes/hot_threads_spec.rb +3 -3
  163. data/spec/elasticsearch/api/actions/put_script_spec.rb +20 -15
  164. data/spec/elasticsearch/api/actions/render_search_template_spec.rb +23 -7
  165. data/spec/elasticsearch/api/actions/scroll_spec.rb +37 -0
  166. data/spec/elasticsearch/api/actions/search_spec.rb +0 -15
  167. data/spec/elasticsearch/api/actions/tasks/list_spec.rb +0 -11
  168. data/spec/elasticsearch/api/actions/update_document_spec.rb +3 -7
  169. data/spec/elasticsearch/api/rest_api_yaml_spec.rb +1 -1
  170. data/spec/rest_yaml_tests_helper.rb +12 -0
  171. data/utils/Gemfile +1 -0
  172. data/utils/Thorfile +0 -1
  173. data/utils/thor/generate_source.rb +192 -85
  174. data/utils/thor/generator/endpoint_specifics.rb +157 -0
  175. data/utils/thor/generator/files_helper.rb +37 -0
  176. data/utils/thor/lister.rb +3 -4
  177. data/utils/thor/templates/_documentation_top.erb +27 -0
  178. data/utils/thor/templates/_method_setup.erb +35 -0
  179. data/utils/thor/templates/_params_registry.erb +12 -0
  180. data/utils/thor/templates/_perform_request.erb +37 -0
  181. data/utils/thor/templates/method.erb +59 -0
  182. data/utils/thor/templates/{ruby/test.erb → test.erb} +0 -0
  183. data/utils/thor/templates/{ruby/test_helper.rb → test_helper.rb} +0 -0
  184. metadata +31 -14
  185. data/spec/elasticsearch/api/actions/scoll_spec.rb +0 -21
  186. data/utils/thor/generate_api.rb +0 -193
  187. data/utils/thor/templates/ruby/method.erb +0 -62
@@ -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 lang: 'groovy', id: 'my_score', body: { script: '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
@@ -5,21 +5,23 @@
5
5
  module Elasticsearch
6
6
  module API
7
7
  module Actions
8
-
9
- # The Painless execute API allows an arbitrary script to be executed and a result to be returned.
8
+ # Allows an arbitrary script to be executed and a result to be returned
10
9
  #
10
+
11
11
  # @option arguments [Hash] :body The script to execute
12
12
  #
13
- # @see https://www.elastic.co/guide/en/elasticsearch/painless/master/painless-execute-api.html
13
+ # @see https://www.elastic.co/guide/en/elasticsearch/painless/7.5/painless-execute-api.html
14
14
  #
15
- def scripts_painless_execute(arguments={})
15
+ def scripts_painless_execute(arguments = {})
16
+ arguments = arguments.clone
17
+
16
18
  method = Elasticsearch::API::HTTP_GET
17
19
  path = "_scripts/painless/_execute"
18
20
  params = {}
19
- body = arguments[:body]
20
21
 
22
+ body = arguments[:body]
21
23
  perform_request(method, path, params, body).body
22
24
  end
23
25
  end
24
- end
26
+ end
25
27
  end
@@ -5,70 +5,47 @@
5
5
  module Elasticsearch
6
6
  module API
7
7
  module Actions
8
-
9
- # Efficiently iterate over a large result set.
10
- #
11
- # When using `from` and `size` to return a large result sets, performance drops as you "paginate" in the set,
12
- # and you can't guarantee the consistency when the index is being updated at the same time.
13
- #
14
- # The "Scroll" API uses a "point in time" snapshot of the index state, which was created via a "Search" API
15
- # request specifying the `scroll` parameter.
16
- #
17
- # @example A basic example
18
- #
19
- # result = client.search index: 'scrollindex',
20
- # scroll: '5m',
21
- # body: { query: { match: { title: 'test' } }, sort: '_id' }
22
- #
23
- # result = client.scroll body: { scroll_id: result['_scroll_id'], scroll: '5m' }
24
- #
25
- # @example Call the `scroll` API until all the documents are returned
26
- #
27
- # # Index 1,000 documents
28
- # client.indices.delete index: 'test'
29
- # 1_000.times do |i| client.index index: 'test', type: 'test', id: i+1, body: {title: "Test #{i+1}"} end
30
- # client.indices.refresh index: 'test'
31
- #
32
- # # Open the "view" of the index by passing the `scroll` parameter
33
- # # Sorting by `_doc` makes the operations faster
34
- # r = client.search index: 'test', scroll: '1m', body: {sort: ['_doc']}
35
- #
36
- # # Display the initial results
37
- # puts "--- BATCH 0 -------------------------------------------------"
38
- # puts r['hits']['hits'].map { |d| d['_source']['title'] }.inspect
8
+ # Allows to retrieve a large numbers of results from a single search request.
39
9
  #
40
- # # Call the `scroll` API until empty results are returned
41
- # while r = client.scroll(body: { scroll_id: r['_scroll_id'] }, scroll: '5m') and not r['hits']['hits'].empty? do
42
- # puts "--- BATCH #{defined?($i) ? $i += 1 : $i = 1} -------------------------------------------------"
43
- # puts r['hits']['hits'].map { |d| d['_source']['title'] }.inspect
44
- # puts
45
- # end
46
- #
47
- # @option arguments [String] :scroll_id The scroll ID
48
- # @option arguments [Hash] :body The scroll ID if not passed by URL or query parameter.
10
+ # @option arguments [String] :scroll_id The scroll ID *Deprecated*
49
11
  # @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search
50
12
  # @option arguments [String] :scroll_id The scroll ID for scrolled search
51
13
  # @option arguments [Boolean] :rest_total_hits_as_int Indicates whether hits.total should be rendered as an integer or an object in the rest search response
14
+
15
+ # @option arguments [Hash] :body The scroll ID if not passed by URL or query parameter.
16
+ #
17
+ # *Deprecation notice*:
18
+ # A scroll id can be quite large and should be specified as part of the body
19
+ # Deprecated since version 7.0.0
52
20
  #
53
- # @see https://www.elastic.co/guide/en/elasticsearch/guide/current/scan-scroll.html#scan-scroll
54
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-scroll.html
55
21
  #
56
- def scroll(arguments={})
57
- method = HTTP_GET
58
- path = "_search/scroll"
22
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-request-body.html#request-body-search-scroll
23
+ #
24
+ def scroll(arguments = {})
25
+ arguments = arguments.clone
26
+
27
+ _scroll_id = arguments.delete(:scroll_id)
28
+
29
+ method = Elasticsearch::API::HTTP_GET
30
+ path = if _scroll_id
31
+ "_search/scroll/#{Utils.__listify(_scroll_id)}"
32
+ else
33
+ "_search/scroll"
34
+ end
59
35
  params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
60
- body = arguments[:body]
61
36
 
37
+ body = arguments[:body]
62
38
  perform_request(method, path, params, body).body
63
39
  end
64
40
 
65
41
  # Register this action with its valid params when the module is loaded.
66
42
  #
67
- # @since 6.1.1
43
+ # @since 6.2.0
68
44
  ParamsRegistry.register(:scroll, [
69
- :scroll,
70
- :scroll_id,
71
- :rest_total_hits_as_int ].freeze)
45
+ :scroll,
46
+ :scroll_id,
47
+ :rest_total_hits_as_int
48
+ ].freeze)
49
+ end
72
50
  end
73
- end
74
51
  end