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 +4 -4
- data/.github/workflows/ci.yml +2 -2
- data/CHANGELOG.md +7 -0
- data/lib/zelastic/index_manager.rb +35 -20
- data/lib/zelastic/indexer.rb +7 -7
- data/lib/zelastic/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 57c75cdfd5b9131b9836f4fe62975e634b19e6fdaf203c43dfb04fa47cfab19e
|
|
4
|
+
data.tar.gz: a45bbd2a537e3363e3ab77690b5ad60a059f6e2526f7ce7410242e93c6b266bb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b2090c1670134753ac7f3cab263c36d795f3b409b7e4a0d74cf9d27a57d1a80250ce7f2ec47dcacae564485a7645775010d57a55cd5ee61216af7584865b9b45
|
|
7
|
+
data.tar.gz: 05f156758b28a8c5198282567490ccfc93d3c499f785dd2eaf654b5243a3cada6e2f5362e7842bc9f32bda084f5d43a4fb775ecc91f90e3bbdbf8fab0680153b
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -14,10 +14,10 @@ jobs:
|
|
|
14
14
|
strategy:
|
|
15
15
|
fail-fast: false
|
|
16
16
|
matrix:
|
|
17
|
-
elasticsearch: ["8.
|
|
17
|
+
elasticsearch: ["8.19.15"]
|
|
18
18
|
elasticsearch_gem: ["~> 8", "~> 7"]
|
|
19
19
|
include:
|
|
20
|
-
- elasticsearch: "7.17.
|
|
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:
|
|
23
|
-
logger.info(populate_index_log(batch_size
|
|
24
|
-
indexer.index_batch(batch, client
|
|
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
|
|
67
|
+
{ remove: { index:, alias: config.write_alias } }
|
|
68
68
|
end
|
|
69
|
-
client.indices.update_aliases(body: { 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(
|
|
98
|
-
|
|
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(
|
|
103
|
-
|
|
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(
|
|
111
|
-
|
|
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
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
data/lib/zelastic/indexer.rb
CHANGED
|
@@ -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
|
|
26
|
+
execute_bulk(client:, index_name:, refresh:) do |index|
|
|
27
27
|
batch.map do |record|
|
|
28
|
-
index_command(index
|
|
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:
|
|
37
|
-
[index_command(index: index_name, version
|
|
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:
|
|
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
|
|
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:
|
|
99
|
+
current_client.bulk(body: commands, refresh:).tap do |result|
|
|
100
100
|
check_errors!(result)
|
|
101
101
|
end
|
|
102
102
|
end
|
data/lib/zelastic/version.rb
CHANGED
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.
|
|
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:
|
|
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: []
|