esse 0.4.0.rc2 → 0.4.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 378f933ddf41a9d403121e9272b87814a01ee9e462eea5b9ad556d1ba593e46a
4
- data.tar.gz: b3551d3361c380b750ca4e52c065d3372e6ec0c5762526f0f65894c097c79163
3
+ metadata.gz: 5dd8f8e268f5c33ed55b160ca803a3d3b4d3c4e7a806b93941b53281325291fb
4
+ data.tar.gz: 4b9437a67ff80a09b3951174c60e4658b987f08633dd2ca124fde50cb2cca0b4
5
5
  SHA512:
6
- metadata.gz: f70d6495c34e176226a16e22da5e04b3ac74cce0d3469a3fa3ddf61c133a402d5577113839b0f4a52935cc71564be08930b529e25abb610c6bee1fcdadad77bb
7
- data.tar.gz: 1cd02580736bb222d0a6e3e7a26fbdc17e925dafbc8cda97eb87fb911c85f1dac4c32543ffdde3418fade6a632722492147278f6c293184d42cae6ccc2a3ee28
6
+ metadata.gz: c35caa2948ee2c511e4f0171bfd23b92a3ccf6812bcbc4c1f7b007d8e3c42912aa483b1a9baa00b75a54f66de6ad92de1087c4b87d174eab9364931d7a22c3c9
7
+ data.tar.gz: 3944a4f0ab6e2b73fe9f52a6dff26b64d1d1ed927f40f7b1eaf42f7b27898b7232c79068cefd9395433838fe8697151b02ccb1166d4d8f4eef186a36729a5881
@@ -15,13 +15,15 @@ module Esse
15
15
  * Delete the old index.
16
16
  DESC
17
17
  option :suffix, type: :string, default: nil, aliases: '-s', desc: 'Suffix to append to index name'
18
- option :import, type: :boolean, default: true, desc: 'Import documents before point alias to the new index'
19
- option :reindex, type: :boolean, default: false, desc: 'Use _reindex API to import documents from the old index to the new index'
18
+ option :import, desc: 'Import documents before point alias to the new index'
19
+ option :reindex, desc: 'Use _reindex API to import documents from the old index to the new index'
20
20
  option :optimize, type: :boolean, default: true, desc: 'Optimize index before import documents by disabling refresh_interval and setting number_of_replicas to 0'
21
21
  option :settings, type: :hash, default: nil, desc: 'List of settings to pass to the index class. Example: --settings=refresh_interval:1s,number_of_replicas:0'
22
22
  def reset(*index_classes)
23
23
  require_relative 'index/reset'
24
24
  opts = HashUtils.deep_transform_keys(options.to_h, &:to_sym)
25
+ opts[:reindex] = Parser::BoolOrHash.new(:reindex, default: false).parse(opts[:reindex])
26
+ opts[:import] = Parser::BoolOrHash.new(:import, default: true).parse(opts[:import])
25
27
  if opts[:import] && opts[:reindex]
26
28
  raise ArgumentError, 'You cannot use --import and --reindex together'
27
29
  end
@@ -100,7 +102,6 @@ module Esse
100
102
  option :preload_lazy_attributes, type: :string, default: nil, desc: 'Command separated list of lazy document attributes to preload using search API before the bulk import. Or pass `true` to preload all lazy attributes'
101
103
  option :eager_load_lazy_attributes, type: :string, default: nil, desc: 'Comma separated list of lazy document attributes to include to the bulk index request. Or pass `true` to include all lazy attributes'
102
104
  option :update_lazy_attributes, type: :string, default: nil, desc: 'Comma separated list of lazy document attributes to bulk update after the bulk index request Or pass `true` to include all lazy attributes'
103
-
104
105
  def import(*index_classes)
105
106
  require_relative 'index/import'
106
107
  opts = HashUtils.deep_transform_keys(options.to_h, &:to_sym)
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Esse
4
+ module CLI
5
+ module Parser
6
+ FALSEY = [false, 'false', 'FALSE', 'f', 'F'].freeze
7
+ TRUTHY = [true, 'true', 'TRUE', 't', 'T'].freeze
8
+ HASH_MATCHER = /([\w\.\-]+)\:([^\s]+)/.freeze
9
+ HASH_SEPARATOR = /[\s]+/.freeze
10
+ ARRAY_SEPARATOR = /[\,]+/.freeze
11
+
12
+ class BoolOrHash
13
+ def initialize(key, default: nil)
14
+ @key = key
15
+ @default = default
16
+ end
17
+
18
+ def parse(input)
19
+ return true if TRUTHY.include?(input)
20
+ return false if FALSEY.include?(input)
21
+ return input if input.is_a?(Hash)
22
+ return @default if input.nil?
23
+ return true if @key.to_s == input
24
+ return @default unless HASH_MATCHER.match?(input)
25
+
26
+ compact_hash = input.to_s.split(HASH_SEPARATOR).each_with_object({}) do |pair, hash|
27
+ key, val = pair.match(HASH_MATCHER).captures
28
+ hash[key.to_sym] = may_array(val)
29
+ end
30
+ return @default if compact_hash.empty?
31
+
32
+ Esse::HashUtils.explode_keys(compact_hash)
33
+ end
34
+
35
+ private
36
+
37
+ def may_array(value)
38
+ return may_bool(value) unless ARRAY_SEPARATOR.match?(value)
39
+
40
+ value.split(ARRAY_SEPARATOR).map { |v| may_bool(v) }
41
+ end
42
+
43
+ def may_bool(value)
44
+ return true if TRUTHY.include?(value)
45
+ return false if FALSEY.include?(value)
46
+
47
+ value
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
data/lib/esse/cli.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require 'thor'
4
4
 
5
5
  require_relative 'primitives/output'
6
+ require_relative 'cli/parser/bool_or_hash'
6
7
  require_relative 'cli/index'
7
8
  require_relative 'cli/generate'
8
9
  require_relative 'cli/event_listener'
data/lib/esse/events.rb CHANGED
@@ -58,5 +58,6 @@ module Esse
58
58
  register_event 'elasticsearch.get'
59
59
  register_event 'elasticsearch.reindex'
60
60
  register_event 'elasticsearch.update_by_query'
61
+ register_event 'elasticsearch.delete_by_query'
61
62
  end
62
63
  end
@@ -315,6 +315,20 @@ module Esse
315
315
  cluster.api.update_by_query(**definition)
316
316
  end
317
317
 
318
+ # Delete documents by query
319
+ #
320
+ # @param options [Hash] Hash of paramenters that will be passed along to elasticsearch request
321
+ # @option [String, nil] :suffix The index suffix. Defaults to the nil.
322
+ #
323
+ # @return [Hash] The elasticsearch response hash
324
+ def delete_by_query(suffix: nil, **options)
325
+ definition = {
326
+ index: index_name(suffix: suffix),
327
+ }.merge(options)
328
+ cluster.may_update_type!(definition)
329
+ cluster.api.delete_by_query(**definition)
330
+ end
331
+
318
332
  protected
319
333
 
320
334
  def document?(doc)
@@ -53,8 +53,11 @@ module Esse
53
53
 
54
54
  suffix ||= Esse.timestamp
55
55
  suffix = Esse.timestamp while index_exist?(suffix: suffix)
56
+ syncronous_import = true
57
+ syncronous_import = false if reindex.is_a?(Hash) && reindex[:wait_for_completion] == false
56
58
 
57
- if optimize && import
59
+ optimized_creation = optimize && syncronous_import && (import || reindex)
60
+ if optimized_creation
58
61
  definition = [settings_hash(settings: settings), mappings_hash].reduce(&:merge)
59
62
  number_of_replicas = definition.dig(Esse::SETTING_ROOT_KEY, :index, :number_of_replicas)
60
63
  refresh_interval = definition.dig(Esse::SETTING_ROOT_KEY, :index, :refresh_interval)
@@ -68,28 +71,50 @@ module Esse
68
71
  if index_exist? && aliases.none?
69
72
  cluster.api.delete_index(index: index_name)
70
73
  end
74
+
71
75
  if import
72
76
  import_kwargs = import.is_a?(Hash) ? import : {}
73
- import_kwargs[:refresh] ||= refresh if refresh
77
+ import_kwargs[:refresh] ||= refresh unless refresh.nil?
74
78
  import(**options, **import_kwargs, suffix: suffix)
75
79
  elsif reindex && (source_indexes = indices_pointing_to_alias).any?
76
80
  reindex_kwargs = reindex.is_a?(Hash) ? reindex : {}
77
- reindex_kwargs[:wait_for_completion] = true unless reindex_kwargs.key?(:wait_for_completion)
81
+ reindex_kwargs[:refresh] ||= refresh unless refresh.nil?
78
82
  source_indexes.each do |from|
79
- cluster.api.reindex(**options, body: { source: { index: from }, dest: { index: index_name(suffix: suffix) } }, refresh: refresh)
83
+ reindex(**reindex_kwargs, body: {
84
+ source: { index: from },
85
+ dest: { index: index_name(suffix: suffix) }
86
+ })
80
87
  end
81
88
  end
82
89
 
83
- if optimize && import && number_of_replicas != new_number_of_replicas || refresh_interval != new_refresh_interval
90
+ if optimized_creation && number_of_replicas != new_number_of_replicas || refresh_interval != new_refresh_interval
84
91
  update_settings(suffix: suffix, settings: settings)
85
92
  refresh(suffix: suffix)
86
93
  end
87
94
 
88
- update_aliases(suffix: suffix)
95
+ update_aliases(suffix: suffix) if syncronous_import
89
96
 
90
97
  true
91
98
  end
92
99
 
100
+ # Copies documents from a source to a destination.
101
+ #
102
+ # To avoid http timeout, we are sending the request with `wait_for_completion: false` and polling the task
103
+ # until it is completed.
104
+ #
105
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-reindex.html
106
+ def reindex(body:, wait_for_completion: true, scroll: '30m', poll_interval: 5, **options)
107
+ resp = cluster.api.reindex(**options, body: body, scroll: scroll, wait_for_completion: false)
108
+ return resp unless wait_for_completion
109
+
110
+ task_id = resp['task']
111
+ task = nil
112
+ while (task = cluster.api.task(id: task_id))['completed'] == false
113
+ sleep poll_interval
114
+ end
115
+ task
116
+ end
117
+
93
118
  # Checks the index existance. Returns true or false
94
119
  #
95
120
  # UsersIndex.index_exist? #=> true
@@ -23,6 +23,34 @@ module Esse
23
23
  def health(**options)
24
24
  coerce_exception { client.cluster.health(**options) }
25
25
  end
26
+
27
+ # Returns information about the tasks currently executing on one or more nodes in the cluster.
28
+ #
29
+ # @option arguments [String] :format a short version of the Accept header, e.g. json, yaml
30
+ # @option arguments [List] :nodes 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
31
+ # @option arguments [List] :actions A comma-separated list of actions that should be returned. Leave empty to return all.
32
+ # @option arguments [Boolean] :detailed Return detailed task information (default: false)
33
+ # @option arguments [String] :parent_task_id Return tasks with specified parent task id (node_id:task_number). Set to -1 to return all.
34
+ # @option arguments [List] :h Comma-separated list of column names to display
35
+ # @option arguments [Boolean] :help Return help information
36
+ # @option arguments [List] :s Comma-separated list of column names or column aliases to sort by
37
+ # @option arguments [String] :time The unit in which to display time values (options: d, h, m, s, ms, micros, nanos)
38
+ # @option arguments [Boolean] :v Verbose mode. Display column headers
39
+ # @option arguments [Hash] :headers Custom HTTP headers
40
+ #
41
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/tasks.html
42
+ def tasks(**options)
43
+ # coerce_exception { client.perform_request('GET', '/_tasks', options).body }
44
+ coerce_exception { client.tasks.list(**options) }
45
+ end
46
+
47
+ def task(id:, **options)
48
+ coerce_exception { client.tasks.get(task_id: id, **options) }
49
+ end
50
+
51
+ def cancel_task(id:, **options)
52
+ coerce_exception { client.tasks.cancel(task_id: id, **options) }
53
+ end
26
54
  end
27
55
 
28
56
  include InstanceMethods
@@ -192,6 +192,104 @@ module Esse
192
192
  response
193
193
  end
194
194
  end
195
+
196
+
197
+ # Performs an update on every document in the index without changing the source,
198
+ # for example to pick up a mapping change.
199
+ #
200
+ # @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*)
201
+ # @option arguments [String] :analyzer The analyzer to use for the query string
202
+ # @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false)
203
+ # @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR)
204
+ # @option arguments [String] :df The field to use as default where no field prefix is given in the query string
205
+ # @option arguments [Number] :from Starting offset (default: 0)
206
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
207
+ # @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)
208
+ # @option arguments [String] :conflicts What to do when the update by query hits version conflicts? (options: abort, proceed)
209
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
210
+ # @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
211
+ # @option arguments [String] :pipeline Ingest pipeline to set on index requests made by this action. (default: none)
212
+ # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
213
+ # @option arguments [String] :q Query in the Lucene query string syntax
214
+ # @option arguments [List] :routing A comma-separated list of specific routing values
215
+ # @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search
216
+ # @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch)
217
+ # @option arguments [Time] :search_timeout Explicit timeout for each search request. Defaults to no timeout.
218
+ # @option arguments [Number] :size Deprecated, please use `max_docs` instead
219
+ # @option arguments [Number] :max_docs Maximum number of documents to process (default: all documents)
220
+ # @option arguments [List] :sort A comma-separated list of <field>:<direction> pairs
221
+ # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return
222
+ # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field
223
+ # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field
224
+ # @option arguments [Number] :terminate_after The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
225
+ # @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes
226
+ # @option arguments [Boolean] :version Specify whether to return document version as part of a hit
227
+ # @option arguments [Boolean] :version_type Should the document increment the version number (internal) on hit or not (reindex)
228
+ # @option arguments [Boolean] :request_cache Specify if request cache should be used for this request or not, defaults to index level setting
229
+ # @option arguments [Boolean] :refresh Should the affected indexes be refreshed?
230
+ # @option arguments [Time] :timeout Time each individual bulk request should wait for shards that are unavailable.
231
+ # @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the update by query 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)
232
+ # @option arguments [Number] :scroll_size Size on the scroll request powering the update by query
233
+ # @option arguments [Boolean] :wait_for_completion Should the request should block until the update by query operation is complete.
234
+ # @option arguments [Number] :requests_per_second The throttle to set on this request in sub-requests per second. -1 means no throttle.
235
+ # @option arguments [Number|string] :slices The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`.
236
+ # @option arguments [Hash] :headers Custom HTTP headers
237
+ # @option arguments [Hash] :body The search definition using the Query DSL
238
+ #
239
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html
240
+ def update_by_query(index:, **options)
241
+ throw_error_when_readonly!
242
+
243
+ Esse::Events.instrument('elasticsearch.update_by_query') do |payload|
244
+ payload[:request] = opts = options.merge(index: index)
245
+ payload[:response] = coerce_exception { client.update_by_query(**opts) }
246
+ end
247
+ end
248
+
249
+ # Deletes documents matching the provided query.
250
+ #
251
+ # @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
252
+ # @option arguments [String] :analyzer The analyzer to use for the query string
253
+ # @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false)
254
+ # @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR)
255
+ # @option arguments [String] :df The field to use as default where no field prefix is given in the query string
256
+ # @option arguments [Number] :from Starting offset (default: 0)
257
+ # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
258
+ # @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)
259
+ # @option arguments [String] :conflicts What to do when the delete by query hits version conflicts? (options: abort, proceed)
260
+ # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
261
+ # @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
262
+ # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
263
+ # @option arguments [String] :q Query in the Lucene query string syntax
264
+ # @option arguments [List] :routing A comma-separated list of specific routing values
265
+ # @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search
266
+ # @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch)
267
+ # @option arguments [Time] :search_timeout Explicit timeout for each search request. Defaults to no timeout.
268
+ # @option arguments [Number] :max_docs Maximum number of documents to process (default: all documents)
269
+ # @option arguments [List] :sort A comma-separated list of <field>:<direction> pairs
270
+ # @option arguments [Number] :terminate_after The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
271
+ # @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes
272
+ # @option arguments [Boolean] :version Specify whether to return document version as part of a hit
273
+ # @option arguments [Boolean] :request_cache Specify if request cache should be used for this request or not, defaults to index level setting
274
+ # @option arguments [Boolean] :refresh Should the affected indexes be refreshed?
275
+ # @option arguments [Time] :timeout Time each individual bulk request should wait for shards that are unavailable.
276
+ # @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the delete by query 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)
277
+ # @option arguments [Number] :scroll_size Size on the scroll request powering the delete by query
278
+ # @option arguments [Boolean] :wait_for_completion Should the request should block until the delete by query is complete.
279
+ # @option arguments [Number] :requests_per_second The throttle for this request in sub-requests per second. -1 means no throttle.
280
+ # @option arguments [Number|string] :slices The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`.
281
+ # @option arguments [Hash] :headers Custom HTTP headers
282
+ # @option arguments [Hash] :body The search definition using the Query DSL (*Required*)
283
+ #
284
+ # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-delete-by-query.html
285
+ def delete_by_query(index:, **options)
286
+ throw_error_when_readonly!
287
+
288
+ Esse::Events.instrument('elasticsearch.delete_by_query') do |payload|
289
+ payload[:request] = opts = options.merge(index: index)
290
+ payload[:response] = coerce_exception { client.delete_by_query(**opts) }
291
+ end
292
+ end
195
293
  end
196
294
 
197
295
  include InstanceMethods
@@ -210,58 +210,6 @@ module Esse
210
210
  payload[:response] = coerce_exception { client.reindex(**opts) }
211
211
  end
212
212
  end
213
-
214
- # Performs an update on every document in the index without changing the source,
215
- # for example to pick up a mapping change.
216
- #
217
- # @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*)
218
- # @option arguments [String] :analyzer The analyzer to use for the query string
219
- # @option arguments [Boolean] :analyze_wildcard Specify whether wildcard and prefix queries should be analyzed (default: false)
220
- # @option arguments [String] :default_operator The default operator for query string query (AND or OR) (options: AND, OR)
221
- # @option arguments [String] :df The field to use as default where no field prefix is given in the query string
222
- # @option arguments [Number] :from Starting offset (default: 0)
223
- # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed)
224
- # @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)
225
- # @option arguments [String] :conflicts What to do when the update by query hits version conflicts? (options: abort, proceed)
226
- # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all)
227
- # @option arguments [Boolean] :lenient Specify whether format-based query failures (such as providing text to a numeric field) should be ignored
228
- # @option arguments [String] :pipeline Ingest pipeline to set on index requests made by this action. (default: none)
229
- # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random)
230
- # @option arguments [String] :q Query in the Lucene query string syntax
231
- # @option arguments [List] :routing A comma-separated list of specific routing values
232
- # @option arguments [Time] :scroll Specify how long a consistent view of the index should be maintained for scrolled search
233
- # @option arguments [String] :search_type Search operation type (options: query_then_fetch, dfs_query_then_fetch)
234
- # @option arguments [Time] :search_timeout Explicit timeout for each search request. Defaults to no timeout.
235
- # @option arguments [Number] :size Deprecated, please use `max_docs` instead
236
- # @option arguments [Number] :max_docs Maximum number of documents to process (default: all documents)
237
- # @option arguments [List] :sort A comma-separated list of <field>:<direction> pairs
238
- # @option arguments [List] :_source True or false to return the _source field or not, or a list of fields to return
239
- # @option arguments [List] :_source_excludes A list of fields to exclude from the returned _source field
240
- # @option arguments [List] :_source_includes A list of fields to extract and return from the _source field
241
- # @option arguments [Number] :terminate_after The maximum number of documents to collect for each shard, upon reaching which the query execution will terminate early.
242
- # @option arguments [List] :stats Specific 'tag' of the request for logging and statistical purposes
243
- # @option arguments [Boolean] :version Specify whether to return document version as part of a hit
244
- # @option arguments [Boolean] :version_type Should the document increment the version number (internal) on hit or not (reindex)
245
- # @option arguments [Boolean] :request_cache Specify if request cache should be used for this request or not, defaults to index level setting
246
- # @option arguments [Boolean] :refresh Should the affected indexes be refreshed?
247
- # @option arguments [Time] :timeout Time each individual bulk request should wait for shards that are unavailable.
248
- # @option arguments [String] :wait_for_active_shards Sets the number of shard copies that must be active before proceeding with the update by query 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)
249
- # @option arguments [Number] :scroll_size Size on the scroll request powering the update by query
250
- # @option arguments [Boolean] :wait_for_completion Should the request should block until the update by query operation is complete.
251
- # @option arguments [Number] :requests_per_second The throttle to set on this request in sub-requests per second. -1 means no throttle.
252
- # @option arguments [Number|string] :slices The number of slices this task should be divided into. Defaults to 1, meaning the task isn't sliced into subtasks. Can be set to `auto`.
253
- # @option arguments [Hash] :headers Custom HTTP headers
254
- # @option arguments [Hash] :body The search definition using the Query DSL
255
- #
256
- # @see https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-update-by-query.html
257
- def update_by_query(index:, **options)
258
- throw_error_when_readonly!
259
-
260
- Esse::Events.instrument('elasticsearch.update_by_query') do |payload|
261
- payload[:request] = opts = options.merge(index: index)
262
- payload[:response] = coerce_exception { client.update_by_query(**opts) }
263
- end
264
- end
265
213
  end
266
214
 
267
215
  include InstanceMethods
@@ -3,7 +3,7 @@
3
3
  module Esse
4
4
  class Transport
5
5
  require_relative './transport/aliases'
6
- require_relative './transport/health'
6
+ require_relative './transport/cluster'
7
7
  require_relative './transport/indices'
8
8
  require_relative './transport/search'
9
9
  require_relative './transport/documents'
data/lib/esse/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Esse
4
- VERSION = '0.4.0.rc2'
4
+ VERSION = '0.4.0.rc3'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: esse
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0.rc2
4
+ version: 0.4.0.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos G. Zimmermann
8
8
  autorequire:
9
9
  bindir: exec
10
10
  cert_chain: []
11
- date: 2024-09-11 00:00:00.000000000 Z
11
+ date: 2024-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -228,6 +228,7 @@ files:
228
228
  - lib/esse/cli/index/update_aliases.rb
229
229
  - lib/esse/cli/index/update_mapping.rb
230
230
  - lib/esse/cli/index/update_settings.rb
231
+ - lib/esse/cli/parser/bool_or_hash.rb
231
232
  - lib/esse/cli/templates/collection.rb.erb
232
233
  - lib/esse/cli/templates/config.rb.erb
233
234
  - lib/esse/cli/templates/document.rb.erb
@@ -296,8 +297,8 @@ files:
296
297
  - lib/esse/template_loader.rb
297
298
  - lib/esse/transport.rb
298
299
  - lib/esse/transport/aliases.rb
300
+ - lib/esse/transport/cluster.rb
299
301
  - lib/esse/transport/documents.rb
300
- - lib/esse/transport/health.rb
301
302
  - lib/esse/transport/indices.rb
302
303
  - lib/esse/transport/search.rb
303
304
  - lib/esse/version.rb