discovery-indexer 0.10.0 → 0.10.1
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/lib/version.rb +1 -1
- data/lib/writer/solr_client.rb +24 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41c0aca7bebdf8eea7c07d8c2d48944e8bcc88c4
|
4
|
+
data.tar.gz: 5d0b42289e313ea24e32b4f0f66dc762c8475efa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d030fb91ba3fec33475e4c5fdd59aaed19e94b6178b6de53b4513be85f94655e420bb8c467bfcb8738f1e943e39b66856e10c7069a9513263d69b8eecaba2db
|
7
|
+
data.tar.gz: 7c489649c3b0b34332108f05e80b75646863b8251a5a431ed8557dad955b5efe58ca0e6edab9326800b7c2a7021b04ccbc4e5e6c9a9283ace69f691c44d3f31e
|
data/lib/version.rb
CHANGED
data/lib/writer/solr_client.rb
CHANGED
@@ -70,20 +70,22 @@ module DiscoveryIndexer
|
|
70
70
|
response['response']['numFound'] == 1
|
71
71
|
end
|
72
72
|
|
73
|
+
# @param solr_connector [RSolr::Client] is an open connection with the solr core
|
74
|
+
# send hard commit to solr
|
75
|
+
def self.commit(solr_connector)
|
76
|
+
RestClient.post self.solr_url(solr_connector), {},:content_type => :json, :accept=>:json
|
77
|
+
end
|
78
|
+
|
73
79
|
# It is an internal method that updates the solr doc instead of adding a new one.
|
80
|
+
# @param id [String] the document id, usually it will be druid.
|
81
|
+
# @param solr_doc [Hash] is the solr doc in hash format
|
82
|
+
# @param solr_connector [RSolr::Client] is an open connection with the solr core
|
74
83
|
def self.update_solr_doc(id, solr_doc, solr_connector)
|
75
84
|
# update_solr_doc can't used RSolr because updating hash doc is not supported
|
76
85
|
# so we need to build the json input manually
|
77
|
-
solr_url = solr_connector.options[:url]
|
78
|
-
if solr_url.end_with?('/')
|
79
|
-
url = "#{solr_connector.options[:url]}update?commit=true"
|
80
|
-
else
|
81
|
-
url = "#{solr_connector.options[:url]}/update?commit=true"
|
82
|
-
end
|
83
|
-
|
84
86
|
params = "[{\"id\":\"#{id}\","
|
85
87
|
solr_doc.each do |field_name, new_values|
|
86
|
-
next
|
88
|
+
next if field_name == :id
|
87
89
|
params += "\"#{field_name}\":"
|
88
90
|
new_values = [new_values] unless new_values.class == Array
|
89
91
|
new_values = new_values.map { |s| s.to_s.gsub('\\', '\\\\\\').gsub('"', '\"').strip } # strip leading/trailing spaces and escape quotes for each value
|
@@ -91,8 +93,21 @@ module DiscoveryIndexer
|
|
91
93
|
end
|
92
94
|
params.chomp!(',')
|
93
95
|
params += '}]'
|
94
|
-
RestClient.post
|
96
|
+
RestClient.post self.solr_url(solr_connector), params, content_type: :json, accept: :json
|
95
97
|
end
|
98
|
+
|
99
|
+
# adjust the solr_url so it works with or without a trailing /
|
100
|
+
# @param solr_connector [RSolr::Client] is an open connection with the solr core
|
101
|
+
# @return [String] the solr URL
|
102
|
+
def self.solr_url(solr_connector)
|
103
|
+
solr_url = solr_connector.options[:url]
|
104
|
+
if solr_url.end_with?('/')
|
105
|
+
"#{solr_url}update?commit=true"
|
106
|
+
else
|
107
|
+
"#{solr_url}/update?commit=true"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
96
111
|
end
|
97
112
|
end
|
98
113
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discovery-indexer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ahmed AlSum
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-11-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|