jruby_streaming_update_solr_server 0.1.4 → 0.2.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.
- data/README.rdoc +31 -9
- data/VERSION +1 -1
- data/lib/jruby_streaming_update_solr_server.rb +29 -20
- metadata +66 -53
- data/.document +0 -5
- data/.gitignore +0 -21
data/README.rdoc
CHANGED
@@ -16,22 +16,31 @@ See the class files for more information, documentation, and examples.
|
|
16
16
|
#
|
17
17
|
# suss = StreamingUpdateSolrServer.new(url,queuesize,threads)
|
18
18
|
#
|
19
|
+
# # Explicitly pick to send javabin or XML. The former requires the line
|
20
|
+
# # <requestHandler name="/update/javabin" class="solr.BinaryUpdateRequestHandler" />
|
21
|
+
# # in you solrconfig.xml
|
22
|
+
#
|
23
|
+
# suss.useJavabin!
|
24
|
+
# # or suss.useXML! to get back to the default
|
25
|
+
#
|
19
26
|
# doc = SolrInputDocument.new
|
20
|
-
# doc
|
21
|
-
# doc.add
|
22
|
-
# doc << ['
|
27
|
+
# doc.add 'title', 'This is the title'
|
28
|
+
# doc.add :title, 'Another title' # symbols are automatically cast to strings for field name
|
29
|
+
# doc << ['title', "This is yet another title, added with '<<'"]
|
30
|
+
# doc.add 'id', 1
|
31
|
+
# doc.add 'author', ['Mike', 'Bill', 'Molly'] # adds multiple values at once
|
23
32
|
# suss.add doc # or suss << doc
|
24
33
|
# # repeat as desired
|
25
34
|
# suss.commit
|
26
35
|
#
|
27
36
|
# @example Create and add as a hash
|
28
|
-
# # The "hash" just needs to be an object that responds to each_pair with field,value(s)
|
37
|
+
# # The "hash" just needs to be an object that responds to each_pair with field,value(s) pairs
|
29
38
|
# suss = StreamingUpdateSolrServer.new(url,queuesize,threads)
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
# suss <<
|
39
|
+
# hash = {}
|
40
|
+
# hash['title'] = This is the title'
|
41
|
+
# hash[:id] = 1 # Can also take symbols instead of strings if you like
|
42
|
+
# hash[:author] = ['Bill', 'Mike'] # Note that we can add multiple values at once
|
43
|
+
# suss << hash
|
35
44
|
# # repeat as desired
|
36
45
|
# suss.commit
|
37
46
|
|
@@ -45,11 +54,24 @@ to a queue and have them automatically sent along to Solr by a user-configurable
|
|
45
54
|
These classes open up those Java classes to add some JRuby sugar and make it easy for you to
|
46
55
|
construct Solr documents and send them to Solr all from within the comfort of the JRuby environment.
|
47
56
|
|
57
|
+
Note that you can use threach to multi-thread it all.
|
58
|
+
|
48
59
|
== WARNING: Program hangs on for 60 seconds!
|
49
60
|
|
50
61
|
*WARNING*: After your program ends, the StreamingUpdateSolrServer object hangs on for a full minute, presumably
|
51
62
|
the timeout of the underlying http client object. I haven't figure out how to change this yet.
|
52
63
|
|
64
|
+
== ToDo
|
65
|
+
|
66
|
+
* Figure out why the http client hangs on for so long
|
67
|
+
* Modify SolrInputDocument.add to take a relevancy weight.
|
68
|
+
* More complete examples
|
69
|
+
|
70
|
+
|
71
|
+
=== CHANGES
|
72
|
+
|
73
|
+
2010.07.09 Added #useJavabin!
|
74
|
+
|
53
75
|
== Copyright
|
54
76
|
|
55
77
|
Copyright (c) 2010 Bill Dueber. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
@@ -51,6 +51,16 @@ end
|
|
51
51
|
|
52
52
|
class StreamingUpdateSolrServer
|
53
53
|
|
54
|
+
# Send requests using the Javabin binary format instead of serializing to XML
|
55
|
+
# Requires /update/javabin to be defined in solrconfig.xml as
|
56
|
+
# <requestHandler name="/update/javabin" class="solr.BinaryUpdateRequestHandler" />
|
57
|
+
|
58
|
+
def useJavabin!
|
59
|
+
self.setRequestWriter Java::org.apache.solr.client.solrj.impl.BinaryRequestWriter.new
|
60
|
+
end
|
61
|
+
|
62
|
+
|
63
|
+
|
54
64
|
# Hang onto the java #add for internal use
|
55
65
|
alias_method :sussadd, :add
|
56
66
|
|
@@ -107,32 +117,14 @@ end
|
|
107
117
|
# @author Bill Dueber
|
108
118
|
|
109
119
|
class SolrInputDocument
|
110
|
-
|
111
|
-
# Add a field and value(s) to the document. This is strictly additive; nothing is replaced or removed
|
112
|
-
#
|
113
|
-
# @param [Array<Symbol, String>] fv A two-element array of the form [field, value] or [field, [value1, value2, ...]]
|
114
|
-
# The field name (i.e., fv[0]) is the Solr field name as specified in schema.xml and
|
115
|
-
# must be either a string or a symbol
|
116
|
-
# @return [Array<String>] the list of current values for the field in fv[0]
|
117
|
-
#
|
118
|
-
# @example Add some fields
|
119
|
-
# doc = SolrInputDocument.new
|
120
|
-
# doc << ['title', 'Mein Kopf'] #=> ['Mein Kopf']
|
121
|
-
# doc << ['title', 'My Head!'] #=> ['Mein Kopf', 'My Head!']
|
122
|
-
# doc << ['author', ['Bill', 'Mike', 'Molly']] #=> ['Bill', 'Mike', 'Molly']
|
123
|
-
|
124
|
-
def << fv
|
125
|
-
field = fv[0]
|
126
|
-
value = fv[1]
|
127
|
-
self.add(field, value)
|
128
|
-
end
|
129
|
-
|
120
|
+
|
130
121
|
# Add a value to a field. Will add all elements of an array in turn
|
131
122
|
# @param [Symbol, String] field The field to add a value or values to
|
132
123
|
# @param [String, Numeric, #each] val The value or array-like of values to add.
|
133
124
|
# @return [Array<String,Numeric>] An array of the field's values after this addition
|
134
125
|
|
135
126
|
def add(field, val)
|
127
|
+
return if val == nil
|
136
128
|
if field.is_a?(Symbol)
|
137
129
|
field = field.to_s
|
138
130
|
end
|
@@ -149,6 +141,23 @@ class SolrInputDocument
|
|
149
141
|
end
|
150
142
|
|
151
143
|
|
144
|
+
# An alternate syntax for #add, which will usuall be preferred.
|
145
|
+
#
|
146
|
+
# @param [Array<Symbol, String>] fv A two-element array of the form [field, value] or [field, [value1, value2, ...]]
|
147
|
+
# @return [Array<String>] the list of current values for the field in fv[0]
|
148
|
+
#
|
149
|
+
# @example Add some fields
|
150
|
+
# doc = SolrInputDocument.new
|
151
|
+
# doc << ['title', 'Mein Kopf'] #=> ['Mein Kopf']
|
152
|
+
# doc << ['title', 'My Head!'] #=> ['Mein Kopf', 'My Head!']
|
153
|
+
# doc << ['author', ['Bill', 'Mike', 'Molly']] #=> ['Bill', 'Mike', 'Molly']
|
154
|
+
|
155
|
+
def << fv
|
156
|
+
field = fv[0]
|
157
|
+
value = fv[1]
|
158
|
+
self.add(field, value)
|
159
|
+
end
|
160
|
+
|
152
161
|
# Get a list of the currently-set values for the passed field
|
153
162
|
#
|
154
163
|
# Note that this will always return either nil (not found) or an array, even of one element
|
metadata
CHANGED
@@ -1,37 +1,48 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jruby_streaming_update_solr_server
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 2
|
8
|
+
- 0
|
9
|
+
version: 0.2.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
|
-
- Bill Dueber
|
12
|
+
- Bill Dueber
|
8
13
|
autorequire:
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-07-09 00:00:00 -04:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: thoughtbot-shoulda
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :development
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: yard
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :development
|
45
|
+
version_requirements: *id002
|
35
46
|
description: Some sugar on top of StreamingUpdateSolrServer for use within JRuby
|
36
47
|
email: bill@dueber.com
|
37
48
|
executables: []
|
@@ -39,52 +50,54 @@ executables: []
|
|
39
50
|
extensions: []
|
40
51
|
|
41
52
|
extra_rdoc_files:
|
42
|
-
- LICENSE
|
43
|
-
- README.rdoc
|
53
|
+
- LICENSE
|
54
|
+
- README.rdoc
|
44
55
|
files:
|
45
|
-
-
|
46
|
-
- .
|
47
|
-
-
|
48
|
-
-
|
49
|
-
-
|
50
|
-
-
|
51
|
-
- jars/
|
52
|
-
- jars/commons-
|
53
|
-
- jars/
|
54
|
-
- jars/
|
55
|
-
-
|
56
|
-
-
|
57
|
-
-
|
58
|
-
- test/helper.rb
|
59
|
-
- test/test_jruby_streaming_update_solr_server.rb
|
56
|
+
- LICENSE
|
57
|
+
- README.rdoc
|
58
|
+
- Rakefile
|
59
|
+
- VERSION
|
60
|
+
- jars/apache-solr-solrj-1.5-dev.jar
|
61
|
+
- jars/commons-codec-1.3.jar
|
62
|
+
- jars/commons-httpclient-3.1.jar
|
63
|
+
- jars/commons-logging-1.1.1.jar
|
64
|
+
- jars/slf4j-api-1.5.5.jar
|
65
|
+
- jars/slf4j-jdk14-1.5.5 2.jar
|
66
|
+
- lib/jruby_streaming_update_solr_server.rb
|
67
|
+
- test/helper.rb
|
68
|
+
- test/test_jruby_streaming_update_solr_server.rb
|
60
69
|
has_rdoc: true
|
61
70
|
homepage: http://github.com/billdueber/jruby_streaming_update_solr_server
|
62
71
|
licenses: []
|
63
72
|
|
64
73
|
post_install_message:
|
65
74
|
rdoc_options:
|
66
|
-
- --charset=UTF-8
|
75
|
+
- --charset=UTF-8
|
67
76
|
require_paths:
|
68
|
-
- lib
|
77
|
+
- lib
|
69
78
|
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
70
80
|
requirements:
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
segments:
|
84
|
+
- 0
|
85
|
+
version: "0"
|
75
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
none: false
|
76
88
|
requirements:
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
version: "0"
|
81
94
|
requirements: []
|
82
95
|
|
83
96
|
rubyforge_project:
|
84
|
-
rubygems_version: 1.3.
|
97
|
+
rubygems_version: 1.3.7
|
85
98
|
signing_key:
|
86
99
|
specification_version: 3
|
87
100
|
summary: Simple jruby interface into StreamingUpdateSolrServer
|
88
101
|
test_files:
|
89
|
-
- test/helper.rb
|
90
|
-
- test/test_jruby_streaming_update_solr_server.rb
|
102
|
+
- test/helper.rb
|
103
|
+
- test/test_jruby_streaming_update_solr_server.rb
|
data/.document
DELETED