jruby_streaming_update_solr_server 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/jars/apache-solr-solrj-1.5-dev.jar +0 -0
- data/lib/jruby_streaming_update_solr_server.rb +50 -19
- metadata +50 -50
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.3
|
Binary file
|
@@ -52,7 +52,7 @@ end
|
|
52
52
|
class StreamingUpdateSolrServer
|
53
53
|
|
54
54
|
# Hang onto the java #add for internal use
|
55
|
-
alias_method :sussadd, :add
|
55
|
+
alias_method :sussadd, :add
|
56
56
|
|
57
57
|
# Add a document to the SUSS
|
58
58
|
# @param [SolrInputDocument, #each_pair] doc The SolrInputDocument or hash (or hash-like object
|
@@ -86,7 +86,7 @@ class StreamingUpdateSolrServer
|
|
86
86
|
|
87
87
|
def add doc
|
88
88
|
if doc.is_a? org.apache.solr.common.SolrInputDocument
|
89
|
-
|
89
|
+
sussadd doc
|
90
90
|
elsif doc.respond_to? :each_pair
|
91
91
|
newdoc = SolrInputDocument.new
|
92
92
|
doc.each_pair do |f,v|
|
@@ -124,21 +124,31 @@ class SolrInputDocument
|
|
124
124
|
def << fv
|
125
125
|
field = fv[0]
|
126
126
|
value = fv[1]
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
127
|
+
self.add(field, value)
|
128
|
+
end
|
129
|
+
|
130
|
+
# Add a value to a field. Will add all elements of an array in turn
|
131
|
+
# @param [Symbol, String] field The field to add a value or values to
|
132
|
+
# @param [String, Numeric, #each] val The value or array-like of values to add.
|
133
|
+
# @return [Array<String,Numeric>] An array of the field's values after this addition
|
133
134
|
|
134
135
|
def add(field, val)
|
135
136
|
if field.is_a?(Symbol)
|
136
137
|
field = field.to_s
|
137
138
|
end
|
138
|
-
|
139
|
+
if val.is_a? String or val.is_a? Numeric
|
140
|
+
self.addField(field, val)
|
141
|
+
else
|
142
|
+
begin
|
143
|
+
val.each {|v| self.add(field, v)}
|
144
|
+
rescue NoMethodError => e
|
145
|
+
raise NoMethodError, "SolrInputDocument values must be a string, numeric, or an array-like (responds to #each) of same, not #{val.inspect}"
|
146
|
+
end
|
147
|
+
end
|
139
148
|
self[field]
|
140
149
|
end
|
141
150
|
|
151
|
+
|
142
152
|
# Get a list of the currently-set values for the passed field
|
143
153
|
#
|
144
154
|
# Note that this will always return either nil (not found) or an array, even of one element
|
@@ -152,13 +162,7 @@ class SolrInputDocument
|
|
152
162
|
end
|
153
163
|
f = self.get(field)
|
154
164
|
return nil if (f == nil)
|
155
|
-
|
156
|
-
v = f.value
|
157
|
-
if v.class == Java::JavaUtil::ArrayList
|
158
|
-
return v.to_a
|
159
|
-
else
|
160
|
-
return [v]
|
161
|
-
end
|
165
|
+
return f.values.to_a
|
162
166
|
end
|
163
167
|
|
164
168
|
# Set the value(s) for the given field, destroying any values that were already in there
|
@@ -180,8 +184,8 @@ class SolrInputDocument
|
|
180
184
|
if field.is_a?(Symbol)
|
181
185
|
field = field.to_s
|
182
186
|
end
|
183
|
-
self.
|
184
|
-
self
|
187
|
+
self.removeField(field)
|
188
|
+
self.add(field, value)
|
185
189
|
end
|
186
190
|
|
187
191
|
|
@@ -208,9 +212,36 @@ class SolrInputDocument
|
|
208
212
|
raise ArgumentError, "Argument must respond to #each_pair"
|
209
213
|
end
|
210
214
|
h.each_pair do |k,v|
|
211
|
-
self
|
215
|
+
self.add(k, v)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
# pretty-print
|
220
|
+
# @return A string representation of the fields and values
|
221
|
+
def to_s
|
222
|
+
return "SolrInputDocument #{self.object_id}\n " + (self.keys.map {|k| "#{k} => #{self[k].inspect}"}).join("\n ")
|
223
|
+
end
|
224
|
+
|
225
|
+
|
226
|
+
# Get the list of keys for this document
|
227
|
+
# @return [Array<String>] The list of keys
|
228
|
+
|
229
|
+
def keys
|
230
|
+
return self.keySet.to_a
|
231
|
+
end
|
232
|
+
|
233
|
+
# Does this doc contain the given key?
|
234
|
+
# @param [Symbol, String] field The field whose presence you want to check
|
235
|
+
# @return [Boolean] True if the key is present
|
236
|
+
|
237
|
+
def has_key? field
|
238
|
+
if field.is_a?(Symbol)
|
239
|
+
field = field.to_s
|
212
240
|
end
|
241
|
+
return self.containsKey(field)
|
213
242
|
end
|
243
|
+
|
244
|
+
|
214
245
|
end
|
215
246
|
|
216
247
|
|
metadata
CHANGED
@@ -1,37 +1,37 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jruby_streaming_update_solr_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
|
7
|
+
- Bill Dueber
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-04-27 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: thoughtbot-shoulda
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: yard
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
35
|
description: Some sugar on top of StreamingUpdateSolrServer for use within JRuby
|
36
36
|
email: bill@dueber.com
|
37
37
|
executables: []
|
@@ -39,44 +39,44 @@ executables: []
|
|
39
39
|
extensions: []
|
40
40
|
|
41
41
|
extra_rdoc_files:
|
42
|
-
|
43
|
-
|
42
|
+
- LICENSE
|
43
|
+
- README.rdoc
|
44
44
|
files:
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
45
|
+
- .document
|
46
|
+
- .gitignore
|
47
|
+
- LICENSE
|
48
|
+
- README.rdoc
|
49
|
+
- Rakefile
|
50
|
+
- VERSION
|
51
|
+
- jars/apache-solr-solrj-1.5-dev.jar
|
52
|
+
- jars/commons-codec-1.3.jar
|
53
|
+
- jars/commons-httpclient-3.1.jar
|
54
|
+
- jars/commons-logging-1.1.1.jar
|
55
|
+
- jars/slf4j-api-1.5.5.jar
|
56
|
+
- jars/slf4j-jdk14-1.5.5 2.jar
|
57
|
+
- lib/jruby_streaming_update_solr_server.rb
|
58
|
+
- test/helper.rb
|
59
|
+
- test/test_jruby_streaming_update_solr_server.rb
|
60
60
|
has_rdoc: true
|
61
61
|
homepage: http://github.com/billdueber/jruby_streaming_update_solr_server
|
62
62
|
licenses: []
|
63
63
|
|
64
64
|
post_install_message:
|
65
65
|
rdoc_options:
|
66
|
-
|
66
|
+
- --charset=UTF-8
|
67
67
|
require_paths:
|
68
|
-
|
68
|
+
- lib
|
69
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
70
|
requirements:
|
71
|
-
|
72
|
-
|
73
|
-
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: "0"
|
74
74
|
version:
|
75
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
76
76
|
requirements:
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: "0"
|
80
80
|
version:
|
81
81
|
requirements: []
|
82
82
|
|
@@ -86,5 +86,5 @@ signing_key:
|
|
86
86
|
specification_version: 3
|
87
87
|
summary: Simple jruby interface into StreamingUpdateSolrServer
|
88
88
|
test_files:
|
89
|
-
|
90
|
-
|
89
|
+
- test/helper.rb
|
90
|
+
- test/test_jruby_streaming_update_solr_server.rb
|