solrb 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/solr/commands.rb +12 -8
- data/lib/solr/commit/request.rb +16 -3
- data/lib/solr/data_import/request.rb +7 -6
- data/lib/solr/delete/request.rb +11 -3
- data/lib/solr/errors/solr_connection_failed_error.rb +1 -1
- data/lib/solr/indexing/request.rb +7 -6
- data/lib/solr/request/default_node_selection_strategy.rb +1 -11
- data/lib/solr/request/first_shard_leader_node_selection_strategy.rb +5 -13
- data/lib/solr/request/leader_node_selection_strategy.rb +2 -12
- data/lib/solr/request/node_selection_strategy.rb +19 -0
- data/lib/solr/request/runner.rb +3 -0
- data/lib/solr/version.rb +1 -1
- data/lib/solr.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9ae1ed7f5931da9955de331a59ca5c10598882b38e137136464a136c9b9b079
|
4
|
+
data.tar.gz: 91b33fad87d4bc4b286d591a0b2c91d1c51a63e59e9a53f9cc8e8891592fba87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1539610c599f2493f8b3d6f0fd0c9b926b69032a2bffc0b0519aaf73c0e5175d63196657893452ce11b147a45243e648c683983049e0f685503be21ec6d60506
|
7
|
+
data.tar.gz: 8d059163628f2c9220a467d6cada61e7b26cb088cc2db82d6b02f14836875f6089e5eb001de0d9dea8f3a74f92eb498bd26ac84a54e85901b7feefadc17b7b62
|
data/Gemfile.lock
CHANGED
data/lib/solr/commands.rb
CHANGED
@@ -5,20 +5,24 @@ require 'solr/data_import/request'
|
|
5
5
|
|
6
6
|
module Solr
|
7
7
|
module Commands
|
8
|
-
def commit
|
9
|
-
Solr::Commit::Request.new.run
|
8
|
+
def commit(open_searcher: true, runner_options: nil)
|
9
|
+
Solr::Commit::Request.new.run(open_searcher: open_searcher,
|
10
|
+
runner_options: runner_options)
|
10
11
|
end
|
11
12
|
|
12
|
-
def delete_by_id(id, commit: false)
|
13
|
-
Solr::Delete::Request.new(id: id)
|
13
|
+
def delete_by_id(id, commit: false, runner_options: nil)
|
14
|
+
request = Solr::Delete::Request.new(id: id)
|
15
|
+
request.run(commit: commit, runner_options: runner_options)
|
14
16
|
end
|
15
17
|
|
16
|
-
def delete_by_query(query, commit: false)
|
17
|
-
Solr::Delete::Request.new(query: query)
|
18
|
+
def delete_by_query(query, commit: false, runner_options: nil)
|
19
|
+
request = Solr::Delete::Request.new(query: query)
|
20
|
+
request.run(commit: commit, runner_options: runner_options)
|
18
21
|
end
|
19
22
|
|
20
|
-
def data_import(params)
|
21
|
-
Solr::DataImport::Request.new(params)
|
23
|
+
def data_import(params, runner_options: nil)
|
24
|
+
request = Solr::DataImport::Request.new(params)
|
25
|
+
request.run(runner_options: runner_options)
|
22
26
|
end
|
23
27
|
end
|
24
28
|
end
|
data/lib/solr/commit/request.rb
CHANGED
@@ -3,9 +3,22 @@ module Solr
|
|
3
3
|
class Request
|
4
4
|
PATH = '/update'.freeze
|
5
5
|
|
6
|
-
def run
|
7
|
-
http_request =
|
8
|
-
|
6
|
+
def run(open_searcher: true, runner_options: nil)
|
7
|
+
http_request = build_http_request(open_searcher)
|
8
|
+
options = default_runner_options.merge(runner_options || {})
|
9
|
+
Solr::Request::Runner.call(request: http_request, **options)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def default_runner_options
|
15
|
+
{ node_selection_strategy: Solr::Request::LeaderNodeSelectionStrategy }
|
16
|
+
end
|
17
|
+
|
18
|
+
def build_http_request(open_searcher)
|
19
|
+
Solr::Request::HttpRequest.new(path: PATH,
|
20
|
+
url_params: { commit: true, openSearcher: open_searcher },
|
21
|
+
method: :post)
|
9
22
|
end
|
10
23
|
end
|
11
24
|
end
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'solr/request/first_shard_leader_node_selection_strategy'
|
2
|
-
|
3
1
|
module Solr
|
4
2
|
module DataImport
|
5
3
|
class Request
|
@@ -14,13 +12,16 @@ module Solr
|
|
14
12
|
# We want to make sure we send every dataimport request to the same node because this same class
|
15
13
|
# could be used to start a dataimport and to get dataimport progress data afterwards.
|
16
14
|
# To make it consistent we will send dataimport requests only to the first shard leader replica
|
17
|
-
def run
|
15
|
+
def run(runner_options: nil)
|
18
16
|
http_request = Solr::Request::HttpRequest.new(path: PATH, url_params: params, method: :get)
|
19
|
-
|
17
|
+
options = default_runner_options.merge(runner_options || {})
|
18
|
+
Solr::Request::Runner.call(request: http_request, **options)
|
20
19
|
end
|
21
20
|
|
22
|
-
|
23
|
-
|
21
|
+
private
|
22
|
+
|
23
|
+
def default_runner_options
|
24
|
+
{ node_selection_strategy: Solr::Request::LeaderNodeSelectionStrategy }
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
data/lib/solr/delete/request.rb
CHANGED
@@ -12,15 +12,23 @@ module Solr
|
|
12
12
|
@delete_command = { delete: options }
|
13
13
|
end
|
14
14
|
|
15
|
-
def run(commit: false)
|
15
|
+
def run(commit: false, runner_options: nil)
|
16
16
|
http_request = build_http_request(commit)
|
17
|
-
|
17
|
+
options = default_runner_options.merge(runner_options || {})
|
18
|
+
Solr::Request::Runner.call(request: http_request, **options)
|
18
19
|
end
|
19
20
|
|
20
21
|
private
|
21
22
|
|
23
|
+
def default_runner_options
|
24
|
+
{ node_selection_strategy: Solr::Request::LeaderNodeSelectionStrategy }
|
25
|
+
end
|
26
|
+
|
22
27
|
def build_http_request(commit)
|
23
|
-
Solr::Request::HttpRequest.new(path: PATH,
|
28
|
+
Solr::Request::HttpRequest.new(path: PATH,
|
29
|
+
body: delete_command,
|
30
|
+
url_params: { commit: commit },
|
31
|
+
method: :post)
|
24
32
|
end
|
25
33
|
|
26
34
|
def validate_delete_options!(options)
|
@@ -3,7 +3,7 @@ module Solr
|
|
3
3
|
class SolrConnectionFailedError < StandardError
|
4
4
|
def initialize(solr_urls)
|
5
5
|
message = <<~MESSAGE
|
6
|
-
Could not
|
6
|
+
Could not connect to any available solr instance:
|
7
7
|
#{solr_urls.join(', ')}
|
8
8
|
MESSAGE
|
9
9
|
super(message)
|
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'solr/request/http_request'
|
2
|
-
require 'solr/request/leader_node_selection_strategy'
|
3
|
-
|
4
1
|
module Solr
|
5
2
|
module Indexing
|
6
3
|
class Request
|
@@ -12,14 +9,18 @@ module Solr
|
|
12
9
|
@documents = documents
|
13
10
|
end
|
14
11
|
|
15
|
-
def run(commit: false,
|
12
|
+
def run(commit: false, runner_options: nil)
|
16
13
|
http_request = build_http_request(commit)
|
17
|
-
|
18
|
-
Solr::Request::Runner.call(request: http_request, **
|
14
|
+
options = default_runner_options.merge(runner_options || {})
|
15
|
+
Solr::Request::Runner.call(request: http_request, **options)
|
19
16
|
end
|
20
17
|
|
21
18
|
private
|
22
19
|
|
20
|
+
def default_runner_options
|
21
|
+
{ node_selection_strategy: Solr::Request::LeaderNodeSelectionStrategy }
|
22
|
+
end
|
23
|
+
|
23
24
|
def build_http_request(commit)
|
24
25
|
Solr::Request::HttpRequest.new(path: PATH, body: documents, url_params: { commit: commit }, method: :post)
|
25
26
|
end
|
@@ -1,16 +1,6 @@
|
|
1
1
|
module Solr
|
2
2
|
module Request
|
3
|
-
class DefaultNodeSelectionStrategy
|
4
|
-
attr_reader :collection_name
|
5
|
-
|
6
|
-
def self.call(collection_name)
|
7
|
-
new(collection_name).call
|
8
|
-
end
|
9
|
-
|
10
|
-
def initialize(collection_name)
|
11
|
-
@collection_name = collection_name
|
12
|
-
end
|
13
|
-
|
3
|
+
class DefaultNodeSelectionStrategy < NodeSelectionStrategy
|
14
4
|
def call
|
15
5
|
Solr.active_nodes_for(collection: collection_name).shuffle
|
16
6
|
end
|
@@ -1,18 +1,10 @@
|
|
1
1
|
module Solr
|
2
2
|
module Request
|
3
|
-
class FirstShardLeaderNodeSelectionStrategy
|
4
|
-
def self.call(collection_name)
|
5
|
-
new(collection_name).call
|
6
|
-
end
|
7
|
-
|
8
|
-
def initialize(collection_name)
|
9
|
-
@collection_name = collection_name
|
10
|
-
end
|
11
|
-
|
3
|
+
class FirstShardLeaderNodeSelectionStrategy < NodeSelectionStrategy
|
12
4
|
def call
|
13
|
-
|
14
|
-
|
15
|
-
([
|
5
|
+
leader = first_shard_leader_replica_node_for(collection: collection_name)
|
6
|
+
replicas = solr_cloud_active_nodes_urls.shuffle
|
7
|
+
([leader] + replicas).flatten.uniq
|
16
8
|
end
|
17
9
|
|
18
10
|
private
|
@@ -25,7 +17,7 @@ module Solr
|
|
25
17
|
end
|
26
18
|
|
27
19
|
def solr_cloud_active_nodes_urls
|
28
|
-
Solr.active_nodes_for(collection:
|
20
|
+
Solr.active_nodes_for(collection: collection_name)
|
29
21
|
end
|
30
22
|
end
|
31
23
|
end
|
@@ -1,18 +1,8 @@
|
|
1
1
|
module Solr
|
2
2
|
module Request
|
3
|
-
class LeaderNodeSelectionStrategy
|
4
|
-
def self.call(collection_name)
|
5
|
-
new(collection_name).call
|
6
|
-
end
|
7
|
-
|
8
|
-
def initialize(collection_name)
|
9
|
-
@collection_name = collection_name
|
10
|
-
end
|
11
|
-
|
3
|
+
class LeaderNodeSelectionStrategy < NodeSelectionStrategy
|
12
4
|
def call
|
13
|
-
|
14
|
-
|
15
|
-
[leader_replica_node_for(collection: @collection_name)]
|
5
|
+
[leader_replica_node_for(collection: collection_name)]
|
16
6
|
end
|
17
7
|
|
18
8
|
private
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Solr
|
2
|
+
module Request
|
3
|
+
class NodeSelectionStrategy
|
4
|
+
attr_reader :collection_name
|
5
|
+
|
6
|
+
def self.call(collection_name)
|
7
|
+
new(collection_name).call
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(collection_name)
|
11
|
+
@collection_name = collection_name
|
12
|
+
end
|
13
|
+
|
14
|
+
def call
|
15
|
+
raise "Not implemented"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/solr/request/runner.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
+
require 'solr/request/node_selection_strategy'
|
1
2
|
require 'solr/request/default_node_selection_strategy'
|
3
|
+
require 'solr/request/first_shard_leader_node_selection_strategy'
|
4
|
+
require 'solr/request/leader_node_selection_strategy'
|
2
5
|
require 'solr/errors/solr_query_error'
|
3
6
|
require 'solr/errors/solr_connection_failed_error'
|
4
7
|
require 'solr/errors/no_active_solr_nodes_error'
|
data/lib/solr/version.rb
CHANGED
data/lib/solr.rb
CHANGED
@@ -9,6 +9,7 @@ require 'solr/document'
|
|
9
9
|
require 'solr/document_collection'
|
10
10
|
require 'solr/grouped_document_collection'
|
11
11
|
require 'solr/response'
|
12
|
+
require 'solr/request/http_request'
|
12
13
|
require 'solr/request/runner'
|
13
14
|
require 'solr/query/request'
|
14
15
|
require 'solr/indexing/document'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adriano Luz
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-04-
|
13
|
+
date: 2019-04-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: addressable
|
@@ -239,6 +239,7 @@ files:
|
|
239
239
|
- lib/solr/request/first_shard_leader_node_selection_strategy.rb
|
240
240
|
- lib/solr/request/http_request.rb
|
241
241
|
- lib/solr/request/leader_node_selection_strategy.rb
|
242
|
+
- lib/solr/request/node_selection_strategy.rb
|
242
243
|
- lib/solr/request/runner.rb
|
243
244
|
- lib/solr/response.rb
|
244
245
|
- lib/solr/response/header.rb
|