es_dump_restore 2.2.2 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/es_dump_restore/app.rb +10 -4
- data/lib/es_dump_restore/es_client.rb +9 -5
- data/lib/es_dump_restore/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fba1c866a6ebce9f261aaf8415155de3f450d5ef
|
4
|
+
data.tar.gz: 9ebbc5d6ffc601122b84864ce6bb7750e86e4b43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6f5d6f71fc4a58c8989643e1d31aa1fe4952a227d392595d73525ff10ec2b89abe7af1d77281006af986a836aff0e6386a0b3fa5d14e37bb2434744cc663da35
|
7
|
+
data.tar.gz: 4729f3c751b2606aa8a4c714bcc9add0719bd3403a78a1471708d177d4544ce2e3fcec42faf0f2514ccc4cd240a5c244dd991b1f3156a77c4d597f017cb3849e
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
# Version 3.0.0 - December 1, 2017
|
2
|
+
|
3
|
+
* Fixes a bug causing document versions not to be recorded
|
4
|
+
* BREAKING CHANGE: Exposes a --preserve-versions option to dump and dump_type with a default value
|
5
|
+
of **false** in order to record document versions. Previous intended default behavior was to
|
6
|
+
preserve versions.
|
7
|
+
|
1
8
|
# Version 2.2.2 - November 13, 2017
|
2
9
|
|
3
10
|
* Fix for incorrect parsing of the retry command-line parameter (thanks to Mat Moore!)
|
data/lib/es_dump_restore/app.rb
CHANGED
@@ -14,15 +14,17 @@ module EsDumpRestore
|
|
14
14
|
option :verbose, :type => :boolean # add some additional output
|
15
15
|
|
16
16
|
desc "dump URL INDEX_NAME FILENAME", "Creates a dumpfile based on the given ElasticSearch index"
|
17
|
+
method_option :preserve_versions, type: :boolean, desc: "Whether to record the current version for each indexed document"
|
17
18
|
def dump(url, index_name, filename)
|
18
19
|
client = EsClient.new(url, index_name, nil)
|
19
|
-
_dump(client, filename)
|
20
|
+
_dump(client, filename, options[:preserve_versions])
|
20
21
|
end
|
21
22
|
|
22
23
|
desc "dump_type URL INDEX_NAME TYPE FILENAME", "Creates a dumpfile based on the given ElasticSearch index"
|
24
|
+
method_option :preserve_versions, type: :boolean, desc: "Whether to record the current version for each indexed document"
|
23
25
|
def dump_type(url, index_name, type, filename)
|
24
26
|
client = EsClient.new(url, index_name, type)
|
25
|
-
_dump(client, filename)
|
27
|
+
_dump(client, filename, options[:preserve_versions])
|
26
28
|
end
|
27
29
|
|
28
30
|
desc "restore URL INDEX_NAME FILENAME", "Restores a dumpfile into the given ElasticSearch index"
|
@@ -62,7 +64,7 @@ module EsDumpRestore
|
|
62
64
|
|
63
65
|
private
|
64
66
|
|
65
|
-
def _dump(client, filename)
|
67
|
+
def _dump(client, filename, preserve_versions)
|
66
68
|
Dumpfile.write(filename) do |dumpfile|
|
67
69
|
dumpfile.index = {
|
68
70
|
settings: client.settings,
|
@@ -77,8 +79,12 @@ module EsDumpRestore
|
|
77
79
|
client.each_scroll_hit(scroll_id) do |hit|
|
78
80
|
hit['fields'] ||= {}
|
79
81
|
metadata = { index: { _type: hit["_type"], _id: hit["_id"] } }
|
82
|
+
if preserve_versions
|
83
|
+
metadata[:index][:version_type] = :external
|
84
|
+
metadata[:index][:_version] = hit["_version"]
|
85
|
+
end
|
80
86
|
|
81
|
-
%w(_timestamp
|
87
|
+
%w(_timestamp _routing _percolate _parent _ttl).each do |metadata_field|
|
82
88
|
metadata[:index][metadata_field] = hit['fields'][metadata_field] if hit['fields'][metadata_field]
|
83
89
|
end
|
84
90
|
|
@@ -46,9 +46,9 @@ module EsDumpRestore
|
|
46
46
|
|
47
47
|
def start_scan(&block)
|
48
48
|
scroll = request(:get, "#{@path_prefix}/_search",
|
49
|
-
query: { search_type: 'scan', scroll: '10m', size: 500 },
|
49
|
+
query: { search_type: 'scan', scroll: '10m', size: 500, version: true },
|
50
50
|
body: MultiJson.dump({
|
51
|
-
fields: ['_source', '_timestamp', '
|
51
|
+
fields: ['_source', '_timestamp', '_routing', '_percolate', '_parent', '_ttl'],
|
52
52
|
query: { match_all: {} } }
|
53
53
|
))
|
54
54
|
total = scroll["hits"]["total"]
|
@@ -60,9 +60,13 @@ module EsDumpRestore
|
|
60
60
|
def each_scroll_hit(scroll_id, &block)
|
61
61
|
done = 0
|
62
62
|
loop do
|
63
|
-
batch = request(:get, '_search/scroll', {
|
64
|
-
|
65
|
-
|
63
|
+
batch = request(:get, '_search/scroll', {
|
64
|
+
query: {
|
65
|
+
version: true,
|
66
|
+
scroll: '10m',
|
67
|
+
scroll_id: scroll_id
|
68
|
+
}
|
69
|
+
}, [404])
|
66
70
|
|
67
71
|
batch_hits = batch["hits"]
|
68
72
|
break if batch_hits.nil?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: es_dump_restore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nat Budin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multi_json
|
@@ -135,8 +135,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
137
|
rubyforge_project:
|
138
|
-
rubygems_version: 2.6.
|
138
|
+
rubygems_version: 2.6.13
|
139
139
|
signing_key:
|
140
140
|
specification_version: 4
|
141
141
|
summary: Dump ElasticSearch indexes to files and restore them back
|
142
142
|
test_files: []
|
143
|
+
has_rdoc:
|