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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 152d6f36a7ce16df4e9e791f8e1206852ee885f3
4
- data.tar.gz: 0c80c8ae274eee2c2f96d47181f65efb67e22fb8
3
+ metadata.gz: 41c0aca7bebdf8eea7c07d8c2d48944e8bcc88c4
4
+ data.tar.gz: 5d0b42289e313ea24e32b4f0f66dc762c8475efa
5
5
  SHA512:
6
- metadata.gz: 22ba3f685782f0ec1dcb74908f021af03e8c9fbd4555b98b1447ef3ebd38186d0940c70232aa7bc46b59f5712a17443e7b3eebfc8bd6a31e21a3b097e2785726
7
- data.tar.gz: 173f1fccc8782fd3293dbff428b4af8b1d01997e3d577924ecdf2ab35695b7800dc52c8efabe8ad3f4959222e04b7c7dd12f79aff99f62f3af89d26f7c99786c
6
+ metadata.gz: 6d030fb91ba3fec33475e4c5fdd59aaed19e94b6178b6de53b4513be85f94655e420bb8c467bfcb8738f1e943e39b66856e10c7069a9513263d69b8eecaba2db
7
+ data.tar.gz: 7c489649c3b0b34332108f05e80b75646863b8251a5a431ed8557dad955b5efe58ca0e6edab9326800b7c2a7021b04ccbc4e5e6c9a9283ace69f691c44d3f31e
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DiscoveryIndexer
2
- VERSION = '0.10.0'
2
+ VERSION = '0.10.1'
3
3
  end
@@ -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 unless field_name == :id
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 url, params, content_type: :json, accept: :json
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.0
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-10-23 00:00:00.000000000 Z
12
+ date: 2015-11-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri