zelastic 0.9.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be9663f3819fc9057a838604106173e90e8b48219542a67eeac5f6493e696921
4
- data.tar.gz: 67c3775b7911527728fc417c1978e223155d73bb7ade42629d8c595f2fcb0193
3
+ metadata.gz: 57c75cdfd5b9131b9836f4fe62975e634b19e6fdaf203c43dfb04fa47cfab19e
4
+ data.tar.gz: a45bbd2a537e3363e3ab77690b5ad60a059f6e2526f7ce7410242e93c6b266bb
5
5
  SHA512:
6
- metadata.gz: 668853db1e94c690e8a86c32b1de997d11563d531cdef95b8f9dcab49df74ac412e36d2b79832ff12bcd82a8dc7740ca0afaa76acf82af2a83efb12e2d55f15d
7
- data.tar.gz: e2e6f75c50b0c763654136fdf753e0734c0d79f5112f467c5f4fa6142cb332272595eecf1061120e82110bfd18ae08e0215fe205090cf35c23ea03b461fe6b98
6
+ metadata.gz: b2090c1670134753ac7f3cab263c36d795f3b409b7e4a0d74cf9d27a57d1a80250ce7f2ec47dcacae564485a7645775010d57a55cd5ee61216af7584865b9b45
7
+ data.tar.gz: 05f156758b28a8c5198282567490ccfc93d3c499f785dd2eaf654b5243a3cada6e2f5362e7842bc9f32bda084f5d43a4fb775ecc91f90e3bbdbf8fab0680153b
@@ -14,10 +14,10 @@ jobs:
14
14
  strategy:
15
15
  fail-fast: false
16
16
  matrix:
17
- elasticsearch: ["8.3.3"]
17
+ elasticsearch: ["8.19.15"]
18
18
  elasticsearch_gem: ["~> 8", "~> 7"]
19
19
  include:
20
- - elasticsearch: "7.17.5"
20
+ - elasticsearch: "7.17.28"
21
21
  elasticsearch_gem: "~> 7"
22
22
 
23
23
  services:
data/CHANGELOG.md CHANGED
@@ -31,6 +31,13 @@ and this project adheres to [Semantic Versioning].
31
31
 
32
32
  ## [Unreleased] - XXXX-XX-XX
33
33
 
34
+ ## [0.9.1]
35
+ ### Added
36
+ - `op_type` and `conflicts` kwargs on `IndexManager#reindex_from_local` and `#reindex_from_remote`. Defaults to `nil`,
37
+ which omits them from the request body and preserves Elasticsearch defaults. Pass `op_type: 'create'` and
38
+ `conflicts: 'proceed'` for safe concurrent backfills - this avoids overwriting fresher live writes at the destination, and
39
+ logs conflicts instead of aborting.
40
+
34
41
  ## [0.8.0] - 2022-08-19
35
42
  ### Added
36
43
  - Support for Ruby 3 (and keep support for 2.7).
@@ -19,9 +19,9 @@ module Zelastic
19
19
  def populate_index(unique_name = nil, batch_size: 3000, refresh: false)
20
20
  index_name = index_name_from_unique(unique_name)
21
21
 
22
- config.data_source.find_in_batches(batch_size: batch_size).with_index do |batch, i|
23
- logger.info(populate_index_log(batch_size: batch_size, batch_number: i + 1))
24
- indexer.index_batch(batch, client: client, index_name: index_name, refresh: refresh)
22
+ config.data_source.find_in_batches(batch_size:).with_index do |batch, i|
23
+ logger.info(populate_index_log(batch_size:, batch_number: i + 1))
24
+ indexer.index_batch(batch, client:, index_name:, refresh:)
25
25
  end
26
26
  end
27
27
 
@@ -64,9 +64,9 @@ module Zelastic
64
64
  )
65
65
 
66
66
  actions = other_write_indices.map do |index|
67
- { remove: { index: index, alias: config.write_alias } }
67
+ { remove: { index:, alias: config.write_alias } }
68
68
  end
69
- client.indices.update_aliases(body: { actions: actions })
69
+ client.indices.update_aliases(body: { actions: })
70
70
  end
71
71
 
72
72
  def cleanup_old_indices
@@ -92,23 +92,38 @@ module Zelastic
92
92
  client.indices.delete(index: indices_to_delete)
93
93
  end
94
94
 
95
- def reindex_from_local(source_index:, dest_index:, wait_for_completion: false)
95
+ def reindex_from_local(source_index:, dest_index:, wait_for_completion: false, op_type: nil, conflicts: nil)
96
96
  logger.info("Reindexing from #{source_index} to #{dest_index}")
97
- reindex(source: { index: source_index }, dest_index: dest_index,
98
- wait_for_completion: wait_for_completion
97
+ reindex(
98
+ source: { index: source_index }, dest_index:,
99
+ wait_for_completion:,
100
+ op_type:,
101
+ conflicts:
99
102
  )
100
103
  end
101
104
 
102
- def reindex_from_remote(source_host:, source_index:, dest_index:,
103
- username: nil, password: nil, wait_for_completion: false)
105
+ def reindex_from_remote(
106
+ source_host:,
107
+ source_index:,
108
+ dest_index:,
109
+ username: nil,
110
+ password: nil,
111
+ wait_for_completion: false,
112
+ op_type: nil,
113
+ conflicts: nil
114
+ )
104
115
  logger.info("Reindexing from remote #{source_host}/#{source_index} to #{dest_index}")
105
116
 
106
117
  remote = { host: source_host }
107
118
  remote[:username] = username if username
108
119
  remote[:password] = password if password
109
120
 
110
- reindex(source: { remote: remote, index: source_index }, dest_index: dest_index,
111
- wait_for_completion: wait_for_completion
121
+ reindex(
122
+ source: { remote:, index: source_index },
123
+ dest_index:,
124
+ wait_for_completion:,
125
+ op_type:,
126
+ conflicts:
112
127
  )
113
128
  end
114
129
 
@@ -126,14 +141,14 @@ module Zelastic
126
141
 
127
142
  def_delegators :config, :logger
128
143
 
129
- def reindex(source:, dest_index:, wait_for_completion:)
130
- client.reindex(
131
- body: {
132
- source: source,
133
- dest: { index: dest_index }
134
- },
135
- wait_for_completion: wait_for_completion
136
- )
144
+ def reindex(source:, dest_index:, wait_for_completion:, op_type: nil, conflicts: nil)
145
+ dest = { index: dest_index }
146
+ dest[:op_type] = op_type if op_type
147
+
148
+ body = { source:, dest: }
149
+ body[:conflicts] = conflicts if conflicts
150
+
151
+ client.reindex(body:, wait_for_completion:)
137
152
  end
138
153
 
139
154
  def indexer
@@ -23,9 +23,9 @@ module Zelastic
23
23
 
24
24
  def index_batch(batch, client: nil, index_name: nil, refresh: false)
25
25
  version = current_version
26
- execute_bulk(client: client, index_name: index_name, refresh: refresh) do |index|
26
+ execute_bulk(client:, index_name:, refresh:) do |index|
27
27
  batch.map do |record|
28
- index_command(index: index, version: version, record: record)
28
+ index_command(index:, version:, record:)
29
29
  end
30
30
  end
31
31
  end
@@ -33,8 +33,8 @@ module Zelastic
33
33
  def index_record(record, refresh: false)
34
34
  version = current_version
35
35
 
36
- execute_bulk(refresh: refresh) do |index_name|
37
- [index_command(index: index_name, version: version, record: record)]
36
+ execute_bulk(refresh:) do |index_name|
37
+ [index_command(index: index_name, version:, record:)]
38
38
  end
39
39
  end
40
40
 
@@ -56,7 +56,7 @@ module Zelastic
56
56
  logger.info('ES: Deleting batch records')
57
57
 
58
58
  config.clients.map do |client|
59
- client.delete_by_query(index: config.write_alias, body: { query: query })
59
+ client.delete_by_query(index: config.write_alias, body: { query: })
60
60
  end
61
61
  end
62
62
 
@@ -82,7 +82,7 @@ module Zelastic
82
82
  _index: index,
83
83
  _id: record.id,
84
84
  data: config.index_data(record),
85
- version: version,
85
+ version:,
86
86
  version_type: :external
87
87
  }
88
88
  }
@@ -96,7 +96,7 @@ module Zelastic
96
96
 
97
97
  commands = indices.flat_map(&block)
98
98
 
99
- current_client.bulk(body: commands, refresh: refresh).tap do |result|
99
+ current_client.bulk(body: commands, refresh:).tap do |result|
100
100
  check_errors!(result)
101
101
  end
102
102
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Zelastic
4
- VERSION = '0.9.0'
4
+ VERSION = '0.9.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zelastic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - carwow Developers
@@ -174,7 +174,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
174
174
  - !ruby/object:Gem::Version
175
175
  version: '0'
176
176
  requirements: []
177
- rubygems_version: 4.0.3
177
+ rubygems_version: 3.6.9
178
178
  specification_version: 4
179
179
  summary: Zero-downtime (re-)indexing of ActiveRecord models into Elasticsearch.
180
180
  test_files: []