elasticsearch-extensions 0.0.27 → 0.0.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +23 -6
- data/LICENSE.txt +199 -10
- data/README.md +6 -21
- data/Rakefile +21 -4
- data/elasticsearch-extensions.gemspec +38 -27
- data/lib/elasticsearch-extensions.rb +5 -0
- data/lib/elasticsearch/extensions.rb +17 -0
- data/lib/elasticsearch/extensions/ansi.rb +17 -0
- data/lib/elasticsearch/extensions/ansi/actions.rb +18 -1
- data/lib/elasticsearch/extensions/ansi/helpers.rb +17 -0
- data/lib/elasticsearch/extensions/ansi/response.rb +17 -0
- data/lib/elasticsearch/extensions/backup.rb +38 -3
- data/lib/elasticsearch/extensions/reindex.rb +32 -15
- data/lib/elasticsearch/extensions/test/cluster.rb +42 -17
- data/lib/elasticsearch/extensions/test/cluster/tasks.rb +17 -0
- data/lib/elasticsearch/extensions/test/profiling.rb +17 -0
- data/lib/elasticsearch/extensions/test/startup_shutdown.rb +17 -0
- data/lib/elasticsearch/extensions/version.rb +18 -1
- data/test/ansi/unit/ansi_test.rb +23 -6
- data/test/backup/unit/backup_test.rb +21 -0
- data/test/reindex/integration/reindex_test.rb +27 -40
- data/test/reindex/unit/reindex_test.rb +21 -4
- data/test/test/cluster/integration/cluster_test.rb +17 -0
- data/test/test/cluster/unit/cluster_test.rb +50 -8
- data/test/test_helper.rb +27 -2
- metadata +44 -41
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
# encoding: utf-8
|
2
19
|
|
3
20
|
require 'elasticsearch'
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
# encoding: utf-8
|
2
19
|
|
3
20
|
require 'elasticsearch/extensions'
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
# encoding: utf-8
|
2
19
|
|
3
20
|
module Elasticsearch
|
@@ -100,7 +117,7 @@ module Elasticsearch
|
|
100
117
|
output << ""
|
101
118
|
end
|
102
119
|
output << Helpers.___
|
103
|
-
output << "#{hits.size.to_s.ansi(:bold)} of #{json['hits']['total'].to_s.ansi(:bold)} results".ansi(:faint)
|
120
|
+
output << "#{hits.size.to_s.ansi(:bold)} of #{json['hits']['total']['value'].to_s.ansi(:bold)} results".ansi(:faint)
|
104
121
|
|
105
122
|
output.join("\n")
|
106
123
|
end
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
# encoding: utf-8
|
2
19
|
|
3
20
|
module Elasticsearch
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
module Elasticsearch
|
2
19
|
module Extensions
|
3
20
|
module ANSI
|
@@ -1,13 +1,41 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
# encoding: utf-8
|
2
19
|
|
3
20
|
require 'pathname'
|
4
21
|
require 'fileutils'
|
5
22
|
|
6
23
|
require 'multi_json'
|
7
|
-
|
24
|
+
|
25
|
+
begin
|
26
|
+
require 'oj'
|
27
|
+
rescue LoadError
|
28
|
+
warn('The "oj" gem could not be loaded. JSON parsing and serialization performance may not be optimal.')
|
29
|
+
end
|
30
|
+
|
31
|
+
begin
|
32
|
+
require 'patron'
|
33
|
+
rescue LoadError
|
34
|
+
warn('The "patron" gem could not be loaded. HTTP requests may not be performed optimally.')
|
35
|
+
end
|
36
|
+
|
8
37
|
|
9
38
|
require 'elasticsearch'
|
10
|
-
require 'patron'
|
11
39
|
|
12
40
|
module Backup
|
13
41
|
module Database
|
@@ -154,12 +182,19 @@ module Backup
|
|
154
182
|
while r = client.scroll(scroll_id: r['_scroll_id'], scroll: scroll) and not r['hits']['hits'].empty? do
|
155
183
|
r['hits']['hits'].each do |hit|
|
156
184
|
FileUtils.mkdir_p "#{path.join hit['_index'], hit['_type']}"
|
157
|
-
File.open("#{path.join hit['_index'], hit['_type'], hit['_id']}.json", 'w') do |file|
|
185
|
+
File.open("#{path.join hit['_index'], hit['_type'], __sanitize_filename(hit['_id'])}.json", 'w') do |file|
|
158
186
|
file.write MultiJson.dump(hit)
|
159
187
|
end
|
160
188
|
end
|
161
189
|
end
|
162
190
|
end
|
191
|
+
|
192
|
+
def __sanitize_filename name
|
193
|
+
name
|
194
|
+
.encode(Encoding::UTF_8, invalid: :replace, undef: :replace, replace: "�")
|
195
|
+
.strip
|
196
|
+
.tr("\u{202E}%$|:;/\t\r\n\\", "-")
|
197
|
+
end
|
163
198
|
end
|
164
199
|
end
|
165
200
|
end
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
# encoding: utf-8
|
2
19
|
|
3
20
|
module Elasticsearch
|
@@ -23,10 +40,10 @@ module Elasticsearch
|
|
23
40
|
end; extend self
|
24
41
|
|
25
42
|
module API
|
26
|
-
# Copy documents from one index into another and refresh the
|
43
|
+
# Copy documents from one index into another and refresh the destination index
|
27
44
|
#
|
28
45
|
# @example
|
29
|
-
# client.reindex source: { index: 'test1' },
|
46
|
+
# client.reindex source: { index: 'test1' }, dest: { index: 'test2' }, refresh: true
|
30
47
|
#
|
31
48
|
# The method allows all the options as {Reindex::Reindex.new}.
|
32
49
|
#
|
@@ -50,40 +67,40 @@ module Elasticsearch
|
|
50
67
|
# client = Elasticsearch::Client.new
|
51
68
|
# reindex = Elasticsearch::Extensions::Reindex.new \
|
52
69
|
# source: { index: 'test1', client: client },
|
53
|
-
#
|
70
|
+
# dest: { index: 'test2' }
|
54
71
|
#
|
55
72
|
# reindex.perform
|
56
73
|
#
|
57
74
|
# @example Copy documents to a different cluster
|
58
75
|
#
|
59
76
|
# source_client = Elasticsearch::Client.new url: 'http://localhost:9200'
|
60
|
-
#
|
77
|
+
# destination_client = Elasticsearch::Client.new url: 'http://localhost:9250'
|
61
78
|
#
|
62
79
|
# reindex = Elasticsearch::Extensions::Reindex.new \
|
63
80
|
# source: { index: 'test', client: source_client },
|
64
|
-
#
|
81
|
+
# dest: { index: 'test', client: destination_client }
|
65
82
|
# reindex.perform
|
66
83
|
#
|
67
84
|
# @example Transform the documents during re-indexing
|
68
85
|
#
|
69
86
|
# reindex = Elasticsearch::Extensions::Reindex.new \
|
70
87
|
# source: { index: 'test1', client: client },
|
71
|
-
#
|
88
|
+
# dest: { index: 'test2' },
|
72
89
|
# transform: lambda { |doc| doc['_source']['category'].upcase! }
|
73
90
|
#
|
74
91
|
#
|
75
92
|
# The reindexing process works by "scrolling" an index and sending
|
76
|
-
# batches via the "Bulk" API to the
|
93
|
+
# batches via the "Bulk" API to the destination index/cluster
|
77
94
|
#
|
78
95
|
# @option arguments [String] :source The source index/cluster definition (*Required*)
|
79
|
-
# @option arguments [String] :
|
96
|
+
# @option arguments [String] :dest The destination index/cluster definition (*Required*)
|
80
97
|
# @option arguments [Proc] :transform A block which will be executed for each document
|
81
98
|
# @option arguments [Integer] :batch_size The size of the batch for scroll operation (Default: 1000)
|
82
99
|
# @option arguments [String] :scroll The timeout for the scroll operation (Default: 5min)
|
83
|
-
# @option arguments [Boolean] :refresh Whether to refresh the
|
100
|
+
# @option arguments [Boolean] :refresh Whether to refresh the destination index after
|
84
101
|
# the operation is completed (Default: false)
|
85
102
|
#
|
86
|
-
# Be aware, that if you want to change the
|
103
|
+
# Be aware, that if you want to change the destination index settings and/or mappings,
|
87
104
|
# you have to do so in advance by using the "Indices Create" API.
|
88
105
|
#
|
89
106
|
# Note, that there is a native "Reindex" API in Elasticsearch 2.3.x and higer versions,
|
@@ -98,7 +115,7 @@ module Elasticsearch
|
|
98
115
|
[
|
99
116
|
[:source, :index],
|
100
117
|
[:source, :client],
|
101
|
-
[:
|
118
|
+
[:dest, :index]
|
102
119
|
].each do |required_option|
|
103
120
|
value = required_option.reduce(arguments) { |sum, o| sum = sum[o] ? sum[o] : {} }
|
104
121
|
|
@@ -113,7 +130,7 @@ module Elasticsearch
|
|
113
130
|
refresh: false
|
114
131
|
}.merge(arguments)
|
115
132
|
|
116
|
-
arguments[:
|
133
|
+
arguments[:dest][:client] ||= arguments[:source][:client]
|
117
134
|
end
|
118
135
|
|
119
136
|
# Performs the operation
|
@@ -144,14 +161,14 @@ module Elasticsearch
|
|
144
161
|
output[:errors] += bulk_response['items'].select { |k, v| k.values.first['error'] }.size
|
145
162
|
end
|
146
163
|
|
147
|
-
arguments[:
|
164
|
+
arguments[:dest][:client].indices.refresh index: arguments[:dest][:index] if arguments[:refresh]
|
148
165
|
|
149
166
|
output
|
150
167
|
end
|
151
168
|
|
152
169
|
def __store_batch(documents)
|
153
170
|
body = documents.map do |doc|
|
154
|
-
doc['_index'] = arguments[:
|
171
|
+
doc['_index'] = arguments[:dest][:index]
|
155
172
|
|
156
173
|
arguments[:transform].call(doc) if arguments[:transform]
|
157
174
|
|
@@ -162,7 +179,7 @@ module Elasticsearch
|
|
162
179
|
{ index: doc }
|
163
180
|
end
|
164
181
|
|
165
|
-
arguments[:
|
182
|
+
arguments[:dest][:client].bulk body: body
|
166
183
|
end
|
167
184
|
end
|
168
185
|
end
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# Licensed to Elasticsearch B.V. under one or more contributor
|
2
|
+
# license agreements. See the NOTICE file distributed with
|
3
|
+
# this work for additional information regarding copyright
|
4
|
+
# ownership. Elasticsearch B.V. licenses this file to you under
|
5
|
+
# the Apache License, Version 2.0 (the "License"); you may
|
6
|
+
# not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing,
|
12
|
+
# software distributed under the License is distributed on an
|
13
|
+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
14
|
+
# KIND, either express or implied. See the License for the
|
15
|
+
# specific language governing permissions and limitations
|
16
|
+
# under the License.
|
17
|
+
|
1
18
|
require 'timeout'
|
2
19
|
require 'net/http'
|
3
20
|
require 'fileutils'
|
@@ -21,7 +38,6 @@ end
|
|
21
38
|
module Elasticsearch
|
22
39
|
module Extensions
|
23
40
|
module Test
|
24
|
-
|
25
41
|
# A convenience Ruby class for starting and stopping an Elasticsearch cluster,
|
26
42
|
# eg. for integration tests
|
27
43
|
#
|
@@ -43,12 +59,11 @@ module Elasticsearch
|
|
43
59
|
# @see Cluster#initialize
|
44
60
|
#
|
45
61
|
module Cluster
|
46
|
-
|
47
62
|
# Starts a cluster
|
48
63
|
#
|
49
64
|
# @see Cluster#start
|
50
65
|
#
|
51
|
-
def start(arguments={})
|
66
|
+
def start(arguments = {})
|
52
67
|
Cluster.new(arguments).start
|
53
68
|
end
|
54
69
|
|
@@ -56,7 +71,7 @@ module Elasticsearch
|
|
56
71
|
#
|
57
72
|
# @see Cluster#stop
|
58
73
|
#
|
59
|
-
def stop(arguments={})
|
74
|
+
def stop(arguments = {})
|
60
75
|
Cluster.new(arguments).stop
|
61
76
|
end
|
62
77
|
|
@@ -64,7 +79,7 @@ module Elasticsearch
|
|
64
79
|
#
|
65
80
|
# @see Cluster#running?
|
66
81
|
#
|
67
|
-
def running?(arguments={})
|
82
|
+
def running?(arguments = {})
|
68
83
|
Cluster.new(arguments).running?
|
69
84
|
end
|
70
85
|
|
@@ -72,7 +87,7 @@ module Elasticsearch
|
|
72
87
|
#
|
73
88
|
# @see Cluster#wait_for_green
|
74
89
|
#
|
75
|
-
def wait_for_green(arguments={})
|
90
|
+
def wait_for_green(arguments = {})
|
76
91
|
Cluster.new(arguments).wait_for_green
|
77
92
|
end
|
78
93
|
|
@@ -190,12 +205,15 @@ module Elasticsearch
|
|
190
205
|
-E path.repo=/tmp \
|
191
206
|
-E repositories.url.allowed_urls=http://snapshot.test* \
|
192
207
|
-E discovery.zen.minimum_master_nodes=#{arguments[:number_of_nodes]-1} \
|
208
|
+
-E xpack.security.enabled=false \
|
193
209
|
-E node.max_local_storage_nodes=#{arguments[:number_of_nodes]} \
|
194
210
|
-E logger.level=#{ENV['DEBUG'] ? 'DEBUG' : 'INFO'} \
|
195
211
|
#{arguments[:es_params]}
|
196
212
|
COMMAND
|
197
213
|
}
|
198
214
|
}
|
215
|
+
COMMANDS['7.0'] = COMMANDS['6.0'].clone
|
216
|
+
COMMANDS['8.0'] = COMMANDS['7.0'].clone
|
199
217
|
COMMANDS.freeze
|
200
218
|
|
201
219
|
# Create a new instance of the Cluster class
|
@@ -237,7 +255,11 @@ module Elasticsearch
|
|
237
255
|
@arguments[:network_host] ||= ENV.fetch('TEST_CLUSTER_NETWORK_HOST', __default_network_host)
|
238
256
|
@arguments[:quiet] ||= ! ENV.fetch('QUIET', '').empty?
|
239
257
|
|
240
|
-
@clear_cluster =
|
258
|
+
@clear_cluster = if @arguments[:clear_cluster].nil?
|
259
|
+
(ENV.fetch('TEST_CLUSTER_CLEAR', 'true') != 'false')
|
260
|
+
else
|
261
|
+
!!@arguments[:clear_cluster]
|
262
|
+
end
|
241
263
|
|
242
264
|
# Make sure `cluster_name` is not dangerous
|
243
265
|
raise ArgumentError, "The `cluster_name` argument cannot be empty string or a slash" \
|
@@ -407,7 +429,7 @@ module Elasticsearch
|
|
407
429
|
'0.0.0.0'
|
408
430
|
when /^2/
|
409
431
|
'_local_'
|
410
|
-
when /^5|^6/
|
432
|
+
when /^5|^6|^7|^8/
|
411
433
|
'_local_'
|
412
434
|
else
|
413
435
|
raise RuntimeError, "Cannot determine default network host from version [#{version}]"
|
@@ -450,9 +472,10 @@ module Elasticsearch
|
|
450
472
|
#
|
451
473
|
def __determine_version
|
452
474
|
path_to_lib = File.dirname(arguments[:command]) + '/../lib/'
|
475
|
+
|
453
476
|
version = if arguments[:version]
|
454
477
|
arguments[:version]
|
455
|
-
elsif File.exist?(path_to_lib) && !(jar = Dir.entries(path_to_lib).select { |f| f
|
478
|
+
elsif File.exist?(path_to_lib) && !(jar = Dir.entries(path_to_lib).select { |f| f =~ /^elasticsearch\-\d/ }.first).nil?
|
456
479
|
__log "Determining version from [#{jar}]" if ENV['DEBUG']
|
457
480
|
if m = jar.match(/elasticsearch\-(\d+\.\d+\.\d+).*/)
|
458
481
|
m[1]
|
@@ -482,15 +505,14 @@ module Elasticsearch
|
|
482
505
|
begin
|
483
506
|
# First, try the new `--version` syntax...
|
484
507
|
__log "Running [#{arguments[:command]} --version] to determine version" if ENV['DEBUG']
|
485
|
-
|
486
|
-
pid =
|
508
|
+
io = IO.popen("#{arguments[:command]} --version")
|
509
|
+
pid = io.pid
|
487
510
|
|
488
511
|
Timeout::timeout(arguments[:timeout_version]) do
|
489
512
|
Process.wait(pid)
|
490
|
-
|
491
|
-
output = rout.read unless rout.closed?
|
492
|
-
rout.close unless rout.closed?
|
513
|
+
output = io.read
|
493
514
|
end
|
515
|
+
|
494
516
|
rescue Timeout::Error
|
495
517
|
# ...else, the old `-v` syntax
|
496
518
|
__log "Running [#{arguments[:command]} -v] to determine version" if ENV['DEBUG']
|
@@ -499,8 +521,7 @@ module Elasticsearch
|
|
499
521
|
if pid
|
500
522
|
Process.kill('INT', pid) rescue Errno::ESRCH # Most likely the process has terminated already
|
501
523
|
end
|
502
|
-
|
503
|
-
rout.close unless rout.closed?
|
524
|
+
io.close unless io.closed?
|
504
525
|
end
|
505
526
|
|
506
527
|
STDERR.puts "> #{output}" if ENV['DEBUG']
|
@@ -509,7 +530,7 @@ module Elasticsearch
|
|
509
530
|
raise RuntimeError, "Cannot determine Elasticsearch version from [#{arguments[:command]} --version] or [#{arguments[:command]} -v]"
|
510
531
|
end
|
511
532
|
|
512
|
-
if
|
533
|
+
if(m = output.match(/Version: (\d+\.\d+.\d+).*,/))
|
513
534
|
m[1]
|
514
535
|
else
|
515
536
|
raise RuntimeError, "Cannot determine Elasticsearch version from elasticsearch --version output [#{output}]"
|
@@ -527,6 +548,10 @@ module Elasticsearch
|
|
527
548
|
'5.0'
|
528
549
|
when /^6\..*/
|
529
550
|
'6.0'
|
551
|
+
when /^7\..*/
|
552
|
+
'7.0'
|
553
|
+
when /^8\..*/
|
554
|
+
'8.0'
|
530
555
|
else
|
531
556
|
raise RuntimeError, "Cannot determine major version from [#{version}]"
|
532
557
|
end
|