solr_wrapper 4.0.1 → 4.1.0
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 +12 -4
- data/lib/solr_wrapper/checksum_validator.rb +13 -6
- data/lib/solr_wrapper/client.rb +3 -3
- data/lib/solr_wrapper/configuration.rb +37 -8
- data/lib/solr_wrapper/downloader.rb +15 -9
- data/lib/solr_wrapper/instance.rb +50 -13
- data/lib/solr_wrapper/settings.rb +5 -1
- data/lib/solr_wrapper/version.rb +1 -1
- data/solr_wrapper.gemspec +4 -3
- data/spec/fixtures/basic_configs/solrconfig.xml +4 -4
- data/spec/lib/solr_wrapper/configuration_spec.rb +2 -1
- data/spec/spec_helper.rb +0 -3
- metadata +38 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dea9ffb20f5c86f84c5f55ac9ccd393ebdb4ac3eccc321bec26327727626b882
|
4
|
+
data.tar.gz: d9f85c0414b81491599cc76ba88540e8ba894c47205debb0b6699ccec00b5905
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86d8223ecd9df368ede9c624f3d150f65f06e6644b060ad3c2628b3338145aeaf1c82c72818b9867ff7b428480663a3da65694185641998f5d5cfade3830b2ef
|
7
|
+
data.tar.gz: '08585c280ca1884815c42d4d585eef463bb3cc878376a6fbb33a77e4e1add615e5effc72d76d6ac4b0a7eee8b36719f8c34b930277956e179f07660912b99bbe'
|
data/.github/workflows/ci.yml
CHANGED
@@ -12,11 +12,19 @@ jobs:
|
|
12
12
|
strategy:
|
13
13
|
matrix:
|
14
14
|
ruby:
|
15
|
-
- 2.
|
16
|
-
- 3.
|
17
|
-
- jruby-9.
|
15
|
+
- '3.2.5'
|
16
|
+
- '3.3.4'
|
17
|
+
- jruby-9.4.8.0
|
18
|
+
solr_version: ['']
|
19
|
+
include:
|
20
|
+
- ruby: '3.3.4'
|
21
|
+
solr_version: '8.11.4'
|
22
|
+
- ruby: '3.3.4'
|
23
|
+
solr_version: '9.6.1'
|
24
|
+
env:
|
25
|
+
SOLR_WRAPPER_SOLR_VERSION: ${{ matrix.solr_version }}
|
18
26
|
steps:
|
19
|
-
- uses: actions/checkout@
|
27
|
+
- uses: actions/checkout@v3
|
20
28
|
- name: Set up Ruby
|
21
29
|
uses: ruby/setup-ruby@v1
|
22
30
|
with:
|
@@ -13,13 +13,16 @@ module SolrWrapper
|
|
13
13
|
|
14
14
|
def validate?(file)
|
15
15
|
return true if config.validate == false
|
16
|
-
|
16
|
+
|
17
|
+
actual_sum(file) == expected_sum
|
17
18
|
end
|
18
19
|
|
19
20
|
def validate!(file)
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
return if validate?(file)
|
22
|
+
|
23
|
+
return if config.ignore_checksum || defined?(JRUBY_VERSION)
|
24
|
+
|
25
|
+
raise "Checksum mismatch: #{file} (expected(#{expected_sum}) != actual(#{actual_sum(file)})"
|
23
26
|
end
|
24
27
|
|
25
28
|
private
|
@@ -36,8 +39,12 @@ module SolrWrapper
|
|
36
39
|
File.join(config.download_dir, File.basename(checksumurl(suffix)))
|
37
40
|
end
|
38
41
|
|
39
|
-
def
|
40
|
-
|
42
|
+
def actual_sum(file)
|
43
|
+
Digest.const_get(algorithm.upcase).file(file).hexdigest
|
44
|
+
end
|
45
|
+
|
46
|
+
def expected_sum
|
47
|
+
config.checksum || read_file(algorithm)
|
41
48
|
end
|
42
49
|
|
43
50
|
def read_file(alg)
|
data/lib/solr_wrapper/client.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'faraday'
|
2
2
|
require 'json'
|
3
3
|
|
4
4
|
module SolrWrapper
|
@@ -18,7 +18,7 @@ module SolrWrapper
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def collection?(name)
|
21
|
-
response =
|
21
|
+
response = Faraday.get("#{url}admin/collections?action=LIST&wt=json")
|
22
22
|
data = JSON.parse(response.body)
|
23
23
|
return if data['error'] && data['error']['msg'] == 'Solr instance is not running in SolrCloud mode.'
|
24
24
|
|
@@ -26,7 +26,7 @@ module SolrWrapper
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def core?(name)
|
29
|
-
response =
|
29
|
+
response = Faraday.get("#{url}admin/cores?action=STATUS&wt=json&core=#{name}")
|
30
30
|
!JSON.parse(response.body)['status'][name].empty?
|
31
31
|
end
|
32
32
|
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
require '
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday/follow_redirects'
|
2
3
|
|
3
4
|
module SolrWrapper
|
4
5
|
class Configuration
|
@@ -9,6 +10,7 @@ module SolrWrapper
|
|
9
10
|
@verbose = options[:verbose]
|
10
11
|
|
11
12
|
@options = load_configs(Array(options[:config])).merge(options)
|
13
|
+
@options[:env] ||= ENV
|
12
14
|
end
|
13
15
|
|
14
16
|
def solr_xml
|
@@ -84,7 +86,12 @@ module SolrWrapper
|
|
84
86
|
|
85
87
|
def version
|
86
88
|
@version ||= begin
|
87
|
-
config_version =
|
89
|
+
config_version = if env_options[:version].nil? || env_options[:version].empty?
|
90
|
+
options.fetch(:version, SolrWrapper.default_instance_options[:version])
|
91
|
+
else
|
92
|
+
env_options[:version]
|
93
|
+
end
|
94
|
+
|
88
95
|
if config_version == 'latest'
|
89
96
|
fetch_latest_version
|
90
97
|
else
|
@@ -110,18 +117,23 @@ module SolrWrapper
|
|
110
117
|
options[:mirror_url] + mirror_artifact_path
|
111
118
|
else
|
112
119
|
begin
|
113
|
-
|
120
|
+
client = Faraday.new(closest_mirror_url) do |faraday|
|
121
|
+
faraday.use Faraday::FollowRedirects::Middleware
|
122
|
+
faraday.adapter Faraday.default_adapter
|
123
|
+
end
|
124
|
+
|
125
|
+
json = client.get.body
|
114
126
|
doc = JSON.parse(json)
|
115
127
|
url = doc['preferred'] + doc['path_info']
|
116
128
|
|
117
|
-
response =
|
129
|
+
response = Faraday.head(url)
|
118
130
|
|
119
|
-
if response.
|
131
|
+
if response.success?
|
120
132
|
url
|
121
133
|
else
|
122
134
|
archive_download_url
|
123
135
|
end
|
124
|
-
rescue Errno::ECONNRESET, SocketError,
|
136
|
+
rescue Errno::ECONNRESET, SocketError, Faraday::Error
|
125
137
|
archive_download_url
|
126
138
|
end
|
127
139
|
end
|
@@ -186,7 +198,8 @@ module SolrWrapper
|
|
186
198
|
$stderr.puts "Unable to parse config #{config_file}" if verbose?
|
187
199
|
return {}
|
188
200
|
end
|
189
|
-
|
201
|
+
|
202
|
+
config.transform_keys!(&:to_sym)
|
190
203
|
absoluteize_paths(config, root: File.dirname(config_file))
|
191
204
|
end
|
192
205
|
|
@@ -209,8 +222,24 @@ module SolrWrapper
|
|
209
222
|
end
|
210
223
|
|
211
224
|
def fetch_latest_version
|
212
|
-
|
225
|
+
url = options.fetch(:latest_version_url, 'https://solr.apache.org/downloads.html')
|
226
|
+
|
227
|
+
client = Faraday.new(url) do |faraday|
|
228
|
+
faraday.use Faraday::FollowRedirects::Middleware
|
229
|
+
faraday.adapter Faraday.default_adapter
|
230
|
+
end
|
231
|
+
|
232
|
+
response = client.get
|
213
233
|
response.body.to_s[/Solr \d+\.\d+\.\d+/][/\d+\.\d+\.\d+/]
|
214
234
|
end
|
235
|
+
|
236
|
+
def env_options
|
237
|
+
@env_options ||= begin
|
238
|
+
env = options.fetch(:env, {})
|
239
|
+
{
|
240
|
+
version: env['SOLR_WRAPPER_SOLR_VERSION']
|
241
|
+
}
|
242
|
+
end
|
243
|
+
end
|
215
244
|
end
|
216
245
|
end
|
@@ -1,23 +1,29 @@
|
|
1
1
|
require 'ruby-progressbar'
|
2
|
-
require '
|
2
|
+
require 'faraday'
|
3
|
+
require 'faraday/follow_redirects'
|
3
4
|
|
4
5
|
module SolrWrapper
|
5
6
|
class Downloader
|
6
7
|
def self.fetch_with_progressbar(url, output)
|
7
8
|
pbar = SafeProgressBar.new(title: File.basename(url), total: nil, format: '%t: |%B| %p%% (%e )')
|
8
9
|
|
9
|
-
|
10
|
-
|
10
|
+
client = Faraday.new(url) do |faraday|
|
11
|
+
faraday.use Faraday::FollowRedirects::Middleware
|
12
|
+
faraday.adapter Faraday.default_adapter
|
13
|
+
end
|
11
14
|
|
12
15
|
File.open(output, 'wb') do |f|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
client.get do |req|
|
17
|
+
req.options.on_data = Proc.new do |chunk, overall_received_bytes, env|
|
18
|
+
pbar.total = env.response_headers['content-length'].to_i
|
19
|
+
pbar.progress = overall_received_bytes
|
20
|
+
f.write(chunk)
|
21
|
+
end
|
16
22
|
end
|
17
|
-
|
18
|
-
nil
|
19
23
|
end
|
20
|
-
|
24
|
+
|
25
|
+
true
|
26
|
+
rescue Faraday::Error => e
|
21
27
|
raise SolrWrapperError, "Unable to download solr from #{url}\n#{e}"
|
22
28
|
end
|
23
29
|
|
@@ -144,23 +144,52 @@ module SolrWrapper
|
|
144
144
|
# @option options [String] :name
|
145
145
|
# @option options [String] :dir
|
146
146
|
def create(options = {})
|
147
|
-
|
147
|
+
tmpdir = nil
|
148
148
|
|
149
|
-
|
150
|
-
|
151
|
-
create_options[:n] = options[:config_name] if options[:config_name]
|
152
|
-
create_options[:d] = options[:dir] if options[:dir]
|
149
|
+
begin
|
150
|
+
options[:name] ||= SecureRandom.hex
|
153
151
|
|
154
|
-
|
155
|
-
|
156
|
-
|
152
|
+
create_options = {}
|
153
|
+
if version >= '9.7'
|
154
|
+
create_options[:url] = config.base_url
|
155
|
+
else
|
156
|
+
create_options[:p] = port
|
157
|
+
end
|
158
|
+
create_options[:c] = options[:name] if options[:name]
|
159
|
+
create_options[:n] = options[:config_name] if options[:config_name]
|
160
|
+
|
161
|
+
if options[:dir]
|
162
|
+
# Solr 9.7 required that the dir argument contain a `conf` directory that
|
163
|
+
# contains the actual configuration files.
|
164
|
+
if version >= '9.7' && !File.exist?(File.join(options[:dir], 'conf'))
|
165
|
+
|
166
|
+
if options[:dir].match?(/conf\/$/)
|
167
|
+
create_options[:d] = File.expand_path(options[:dir], '..')
|
168
|
+
else
|
169
|
+
tmpdir = Dir.mktmpdir
|
170
|
+
|
171
|
+
FileUtils.mkdir("#{tmpdir}/conf")
|
172
|
+
FileUtils.cp_r("#{options[:dir]}/.", "#{tmpdir}/conf")
|
173
|
+
create_options[:d] = tmpdir
|
174
|
+
end
|
175
|
+
else
|
176
|
+
create_options[:d] = options[:dir]
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
Retriable.retriable do
|
181
|
+
raise "Not started yet" unless started?
|
182
|
+
end
|
157
183
|
|
158
|
-
|
159
|
-
|
184
|
+
# short-circuit if we're using persisted data with an existing core/collection
|
185
|
+
return if options[:persist] && create_options[:c] && client.exists?(create_options[:c])
|
160
186
|
|
161
|
-
|
187
|
+
exec("create", create_options)
|
162
188
|
|
163
|
-
|
189
|
+
options[:name]
|
190
|
+
ensure
|
191
|
+
FileUtils.remove_entry tmpdir if tmpdir
|
192
|
+
end
|
164
193
|
end
|
165
194
|
|
166
195
|
##
|
@@ -203,7 +232,15 @@ module SolrWrapper
|
|
203
232
|
# Create a new collection in solr
|
204
233
|
# @param [String] name collection name
|
205
234
|
def delete(name, _options = {})
|
206
|
-
|
235
|
+
delete_options = { c: name }
|
236
|
+
|
237
|
+
if version >= '9.7'
|
238
|
+
delete_options[:url] = config.base_url
|
239
|
+
else
|
240
|
+
delete_options[:p] = port
|
241
|
+
end
|
242
|
+
|
243
|
+
exec("delete", delete_options)
|
207
244
|
end
|
208
245
|
|
209
246
|
##
|
@@ -42,10 +42,14 @@ module SolrWrapper
|
|
42
42
|
@zookeeper_port ||= "#{port.to_i + 1000}"
|
43
43
|
end
|
44
44
|
|
45
|
+
def base_url
|
46
|
+
"http://#{host}:#{port}/"
|
47
|
+
end
|
48
|
+
|
45
49
|
##
|
46
50
|
# Get a (likely) URL to the solr instance
|
47
51
|
def url
|
48
|
-
"
|
52
|
+
"#{base_url}solr/"
|
49
53
|
end
|
50
54
|
|
51
55
|
def instance_dir
|
data/lib/solr_wrapper/version.rb
CHANGED
data/solr_wrapper.gemspec
CHANGED
@@ -18,16 +18,17 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "
|
21
|
+
spec.add_dependency "faraday"
|
22
|
+
spec.add_dependency "faraday-follow_redirects"
|
22
23
|
spec.add_dependency "minitar"
|
23
24
|
spec.add_dependency "ruby-progressbar"
|
24
25
|
spec.add_dependency "retriable"
|
26
|
+
spec.add_dependency "ostruct"
|
25
27
|
|
26
28
|
spec.add_development_dependency "bundler", ">= 1.7", "< 3"
|
27
|
-
spec.add_development_dependency "rake", "
|
29
|
+
spec.add_development_dependency "rake", ">= 12.2", "< 14"
|
28
30
|
|
29
31
|
spec.add_development_dependency "rspec"
|
30
32
|
spec.add_development_dependency "simple_solr_client", "= 0.2.0" # 0.2.1 removed support for schema retrieval
|
31
|
-
spec.add_development_dependency "coveralls"
|
32
33
|
spec.add_development_dependency "webmock"
|
33
34
|
end
|
@@ -240,7 +240,7 @@
|
|
240
240
|
autowarmCount - the number of entries to prepopulate from
|
241
241
|
and old cache.
|
242
242
|
-->
|
243
|
-
<filterCache class="solr.
|
243
|
+
<filterCache class="solr.CaffeineCache"
|
244
244
|
size="512"
|
245
245
|
initialSize="512"
|
246
246
|
autowarmCount="0"/>
|
@@ -250,7 +250,7 @@
|
|
250
250
|
Caches results of searches - ordered lists of document ids
|
251
251
|
(DocList) based on a query, a sort, and the range of documents requested.
|
252
252
|
-->
|
253
|
-
<queryResultCache class="solr.
|
253
|
+
<queryResultCache class="solr.CaffeineCache"
|
254
254
|
size="512"
|
255
255
|
initialSize="512"
|
256
256
|
autowarmCount="0"/>
|
@@ -261,14 +261,14 @@
|
|
261
261
|
document). Since Lucene internal document ids are transient,
|
262
262
|
this cache will not be autowarmed.
|
263
263
|
-->
|
264
|
-
<documentCache class="solr.
|
264
|
+
<documentCache class="solr.CaffeineCache"
|
265
265
|
size="512"
|
266
266
|
initialSize="512"
|
267
267
|
autowarmCount="0"/>
|
268
268
|
|
269
269
|
<!-- custom cache currently used by block join -->
|
270
270
|
<cache name="perSegFilter"
|
271
|
-
class="solr.
|
271
|
+
class="solr.CaffeineCache"
|
272
272
|
size="10"
|
273
273
|
initialSize="0"
|
274
274
|
autowarmCount="10"
|
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe SolrWrapper::Configuration do
|
4
|
-
let(:config) { described_class.new options }
|
4
|
+
let(:config) { described_class.new default_options.merge(options) }
|
5
|
+
let(:default_options) { { env: {} } }
|
5
6
|
|
6
7
|
describe "#port" do
|
7
8
|
subject { config.port }
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,17 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solr_wrapper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday-follow_redirects
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
31
|
- - ">="
|
@@ -66,6 +80,20 @@ dependencies:
|
|
66
80
|
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: ostruct
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: bundler
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,22 +118,22 @@ dependencies:
|
|
90
118
|
name: rake
|
91
119
|
requirement: !ruby/object:Gem::Requirement
|
92
120
|
requirements:
|
93
|
-
- - "
|
121
|
+
- - ">="
|
94
122
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
123
|
+
version: '12.2'
|
96
124
|
- - "<"
|
97
125
|
- !ruby/object:Gem::Version
|
98
|
-
version: '
|
126
|
+
version: '14'
|
99
127
|
type: :development
|
100
128
|
prerelease: false
|
101
129
|
version_requirements: !ruby/object:Gem::Requirement
|
102
130
|
requirements:
|
103
|
-
- - "
|
131
|
+
- - ">="
|
104
132
|
- !ruby/object:Gem::Version
|
105
|
-
version: '
|
133
|
+
version: '12.2'
|
106
134
|
- - "<"
|
107
135
|
- !ruby/object:Gem::Version
|
108
|
-
version: '
|
136
|
+
version: '14'
|
109
137
|
- !ruby/object:Gem::Dependency
|
110
138
|
name: rspec
|
111
139
|
requirement: !ruby/object:Gem::Requirement
|
@@ -134,20 +162,6 @@ dependencies:
|
|
134
162
|
- - '='
|
135
163
|
- !ruby/object:Gem::Version
|
136
164
|
version: 0.2.0
|
137
|
-
- !ruby/object:Gem::Dependency
|
138
|
-
name: coveralls
|
139
|
-
requirement: !ruby/object:Gem::Requirement
|
140
|
-
requirements:
|
141
|
-
- - ">="
|
142
|
-
- !ruby/object:Gem::Version
|
143
|
-
version: '0'
|
144
|
-
type: :development
|
145
|
-
prerelease: false
|
146
|
-
version_requirements: !ruby/object:Gem::Requirement
|
147
|
-
requirements:
|
148
|
-
- - ">="
|
149
|
-
- !ruby/object:Gem::Version
|
150
|
-
version: '0'
|
151
165
|
- !ruby/object:Gem::Dependency
|
152
166
|
name: webmock
|
153
167
|
requirement: !ruby/object:Gem::Requirement
|
@@ -230,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
230
244
|
- !ruby/object:Gem::Version
|
231
245
|
version: '0'
|
232
246
|
requirements: []
|
233
|
-
rubygems_version: 3.
|
247
|
+
rubygems_version: 3.5.9
|
234
248
|
signing_key:
|
235
249
|
specification_version: 4
|
236
250
|
summary: Solr service wrapper
|