es-reindex 0.3.2 → 0.3.3

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
  SHA1:
3
- metadata.gz: 6bb1862c74c923e6e30a22bc694f2b4cc97a11ac
4
- data.tar.gz: bc5529358af365d1803a6d5c5a5158c6e265fd36
3
+ metadata.gz: 75e91c0a58aec17def06e3d69858f98cd759f46e
4
+ data.tar.gz: d223121aa74c36553917cbd6b9cede4068383024
5
5
  SHA512:
6
- metadata.gz: 5eec5cb2304c337e4fd242f2035d99354f1542939948830292f5a94f4a1d4d684e066f1a6cd576e23f27fac84678d203d9fad544ce81235c337beeff0ec8b99d
7
- data.tar.gz: 341436662c907031f3ed38ead2e96dca6a2228203b47b6c70d5d7a1f6a9f84cd648c01d5b61d0332dc30f2811057f603660ecb061d647b7269772ee8fd69ccd7
6
+ metadata.gz: 4ff8dd6b08a4cea265aa49d212a8ddb7a3c34472d0751932f9cec3e4b0152cb06bdb71c18e4d9ea4f71e404cab8003ef33cc2123153feb6119eb02f3bc5ae4b2
7
+ data.tar.gz: 67a9a28d9106e8c2d885eab9f4006a935a889a290aaa384701bf561ae66efc03b7d75ec744863029c8b24c04e8760659776d58fbe20b9ebee12c55c921027d35
@@ -1,5 +1,6 @@
1
1
  ## Changelog
2
2
 
3
+ + __0.3.3__: Added `-nm` option [@wader](https://github.com/wader)
3
4
  + __0.3.2__: Remove activesupport dependency entirely, handle aliased indices [@waterlink](https://github.com/waterlink)
4
5
  + __0.3.1__: Add activesupport dependency since es-reindex uses methods from it.
5
6
  + __0.3.0__: Add `:if` and `:unless` callbacks
@@ -17,7 +17,7 @@ Progress and time estimation is displayed during the scrolling process.
17
17
 
18
18
  Refer to script's help:
19
19
 
20
- ```bash
20
+ ```
21
21
  $ ./es-reindex.rb -h
22
22
 
23
23
  Script to copy particular ES index including its (re)creation w/options set
@@ -25,11 +25,12 @@ and mapping copied.
25
25
 
26
26
  Usage:
27
27
 
28
- ./es-reindex.rb [-r] [-f <frame>] [source_url/]<index> [destination_url/]<index>
28
+ ./es-reindex [options] [source_url/]<index> [destination_url/]<index>
29
29
 
30
- - -r - remove the index in the new location first
31
- - -f - specify frame size to be obtained with one fetch during scrolling
32
- - -u - update existing documents (default: only create non-existing)
30
+ - -r - remove the index in the new location first
31
+ - -f - specify frame size to be obtained with one fetch during scrolling
32
+ - -u - update existing documents (default: only create non-existing)
33
+ - -nm - don't copy mappings and settings
33
34
  - optional source/destination urls default to http://127.0.0.1:9200
34
35
  ```
35
36
 
@@ -12,11 +12,12 @@ if ARGV.size == 0 or ARGV[0] =~ /^-(?:h|-?help)$/
12
12
 
13
13
  Usage:
14
14
 
15
- #{__FILE__} [-r] [-f <frame>] [source_url/]<index> [destination_url/]<index>
15
+ #{__FILE__} [options] [source_url/]<index> [destination_url/]<index>
16
16
 
17
- - -r - remove the index in the new location first
18
- - -f - specify frame size to be obtained with one fetch during scrolling
19
- - -u - update existing documents (default: only create non-existing)
17
+ - -r - remove the index in the new location first
18
+ - -f - specify frame size to be obtained with one fetch during scrolling
19
+ - -u - update existing documents (default: only create non-existing)
20
+ - -nm - dont't copy mappings and settings
20
21
  - optional source/destination urls default to http://127.0.0.1:9200
21
22
  \n"
22
23
 
@@ -108,8 +108,8 @@ class ESReindex
108
108
  return false unless get_mappings
109
109
  create_msg = " with settings & mappings from '#{surl}/#{sidx}'"
110
110
  else
111
- @mappings = options[:mappings].call
112
- @settings = options[:settings].call
111
+ @mappings = options[:mappings].nil? ? {} : options[:mappings].call
112
+ @settings = options[:settings].nil? ? {} : options[:settings].call
113
113
  create_msg = ""
114
114
  end
115
115
 
@@ -2,13 +2,19 @@ class ESReindex
2
2
  class ArgsParser
3
3
 
4
4
  def self.parse(args)
5
- remove, update, frame, src, dst = false, false, 1000, nil, nil
5
+ remove = false
6
+ update = false
7
+ frame = 1000
8
+ src = nil
9
+ dst = nil
10
+ copy_mappings = true
6
11
 
7
12
  while args[0]
8
13
  case arg = args.shift
9
14
  when '-r' then remove = true
10
15
  when '-f' then frame = args.shift.to_i
11
16
  when '-u' then update = true
17
+ when '-nm' then copy_mappings = false
12
18
  else
13
19
  u = arg.chomp '/'
14
20
  !src ? (src = u) : !dst ? (dst = u) :
@@ -19,7 +25,8 @@ class ESReindex
19
25
  return src, dst, {
20
26
  remove: remove,
21
27
  frame: frame,
22
- update: update
28
+ update: update,
29
+ copy_mappings: copy_mappings,
23
30
  }
24
31
  end
25
32
  end
@@ -1,3 +1,3 @@
1
1
  class ESReindex
2
- VERSION = '0.3.2'
2
+ VERSION = '0.3.3'
3
3
  end
@@ -74,4 +74,20 @@ describe ESReindex::ArgsParser do
74
74
  expect(parsed_opts[:update]).to be true
75
75
  end
76
76
  end
77
+
78
+ context "without -nm" do
79
+ let(:args) { ["-u"] }
80
+
81
+ it "sets copy_mappings to true" do
82
+ expect(parsed_opts[:copy_mappings]).to be true
83
+ end
84
+ end
85
+
86
+ context "with -nm" do
87
+ let(:args) { ["-u", "-nm"] }
88
+
89
+ it "sets copy_mappings to false" do
90
+ expect(parsed_opts[:copy_mappings]).to be false
91
+ end
92
+ end
77
93
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: es-reindex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justin Aiken
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-27 00:00:00.000000000 Z
12
+ date: 2015-09-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: elasticsearch
@@ -170,3 +170,4 @@ test_files:
170
170
  - spec/integration/reindex_spec.rb
171
171
  - spec/spec_helper.rb
172
172
  - spec/support/test_model.rb
173
+ has_rdoc: