solr-ruby 0.0.6 → 0.0.7
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/lib/solr.rb +0 -0
- data/lib/solr/connection.rb +0 -0
- data/lib/solr/importer.rb +0 -0
- data/lib/solr/importer/array_mapper.rb +0 -0
- data/lib/solr/importer/delimited_file_source.rb +0 -0
- data/lib/solr/importer/mapper.rb +0 -0
- data/lib/solr/importer/solr_source.rb +0 -0
- data/lib/solr/importer/xpath_mapper.rb +0 -0
- data/lib/solr/indexer.rb +0 -0
- data/lib/solr/request.rb +0 -0
- data/lib/solr/request/custom.rb +50 -0
- data/lib/solr/request/index_info.rb +0 -0
- data/lib/solr/request/modify_document.rb +0 -0
- data/lib/solr/request/optimize.rb +0 -0
- data/lib/solr/request/select.rb +1 -1
- data/lib/solr/request/standard.rb +251 -12
- data/lib/solr/response.rb +0 -0
- data/lib/solr/response/index_info.rb +0 -0
- data/lib/solr/response/modify_document.rb +0 -0
- data/lib/solr/response/optimize.rb +0 -0
- data/lib/solr/response/select.rb +0 -0
- data/lib/solr/solrtasks.rb +0 -0
- data/lib/solr/util.rb +0 -0
- data/test/unit/array_mapper_test.rb +0 -0
- data/test/unit/changes_yaml_test.rb +0 -0
- data/test/unit/connection_test.rb +0 -0
- data/test/unit/data_mapper_test.rb +0 -0
- data/test/unit/delimited_file_source_test.rb +0 -0
- data/test/unit/indexer_test.rb +0 -0
- data/test/unit/modify_document_test.rb +0 -0
- data/test/unit/request_test.rb +0 -0
- data/test/unit/select_test.rb +0 -0
- data/test/unit/solr_mock_base.rb +0 -0
- data/test/unit/standard_request_test.rb +177 -7
- data/test/unit/suite.rb +0 -0
- data/test/unit/tab_delimited.txt +0 -0
- data/test/unit/util_test.rb +0 -0
- data/test/unit/xpath_mapper_test.rb +0 -0
- metadata +41 -33
data/lib/solr.rb
CHANGED
File without changes
|
data/lib/solr/connection.rb
CHANGED
File without changes
|
data/lib/solr/importer.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/lib/solr/importer/mapper.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
data/lib/solr/indexer.rb
CHANGED
File without changes
|
data/lib/solr/request.rb
CHANGED
File without changes
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# The ASF licenses this file to You under the Apache License, Version 2.0
|
2
|
+
# (the "License"); you may not use this file except in compliance with
|
3
|
+
# the License. You may obtain a copy of the License at
|
4
|
+
#
|
5
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software
|
8
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
9
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
10
|
+
# See the License for the specific language governing permissions and
|
11
|
+
# limitations under the License.
|
12
|
+
|
13
|
+
require 'erb'
|
14
|
+
|
15
|
+
# "Abstract" base class, only useful with subclasses that add parameters
|
16
|
+
class Solr::Request::Custom < Solr::Request::Select
|
17
|
+
|
18
|
+
def initialize(qt=nil, params={}, content_type='application/x-www-form-urlencoded; charset=utf-8')
|
19
|
+
super(qt,params)
|
20
|
+
@content_type = content_type
|
21
|
+
end
|
22
|
+
|
23
|
+
def handler
|
24
|
+
@query_type.starts_with('/') ? qt.remove_first('/') : 'select'
|
25
|
+
end
|
26
|
+
|
27
|
+
def content_type
|
28
|
+
@content_type
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_hash
|
32
|
+
return {:qt => query_type, :wt => 'ruby'}.merge(@select_params)
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_s
|
36
|
+
raw_params = self.to_hash
|
37
|
+
|
38
|
+
http_params = []
|
39
|
+
raw_params.each do |key,value|
|
40
|
+
if value.respond_to? :each
|
41
|
+
value.each { |v| http_params << "#{key}=#{ERB::Util::url_encode(v)}" unless v.nil?}
|
42
|
+
else
|
43
|
+
http_params << "#{key}=#{ERB::Util::url_encode(value)}" unless value.nil?
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
http_params.join("&")
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
data/lib/solr/request/select.rb
CHANGED
@@ -43,7 +43,7 @@ class Solr::Request::Select < Solr::Request::Base
|
|
43
43
|
|
44
44
|
http_params = []
|
45
45
|
raw_params.each do |key,value|
|
46
|
-
if value.respond_to?
|
46
|
+
if value.respond_to?(:each) && !value.is_a?(String)
|
47
47
|
value.each { |v| http_params << "#{key}=#{ERB::Util::url_encode(v)}" unless v.nil?}
|
48
48
|
else
|
49
49
|
http_params << "#{key}=#{ERB::Util::url_encode(value)}" unless value.nil?
|
@@ -75,6 +75,7 @@ class Solr::Request::Standard < Solr::Request::Select
|
|
75
75
|
hash["facet.mincount"] = @params[:facets][:mincount]
|
76
76
|
hash["facet.prefix"] = @params[:facets][:prefix]
|
77
77
|
hash["facet.offset"] = @params[:facets][:offset]
|
78
|
+
hash["facet.method"] = @params[:facets][:method] if @params[:facets][:method]
|
78
79
|
if @params[:facets][:fields] # facet fields are optional (could be facet.query only)
|
79
80
|
@params[:facets][:fields].each do |f|
|
80
81
|
if f.kind_of? Hash
|
@@ -95,25 +96,263 @@ class Solr::Request::Standard < Solr::Request::Select
|
|
95
96
|
end
|
96
97
|
|
97
98
|
# highlighting parameter processing - http://wiki.apache.org/solr/HighlightingParameters
|
98
|
-
#TODO need to add per-field overriding to snippets, fragsize, requiredFieldMatch, formatting, and simple.pre/post
|
99
99
|
if @params[:highlighting]
|
100
100
|
hash[:hl] = true
|
101
101
|
hash["hl.fl"] = @params[:highlighting][:field_list].join(',') if @params[:highlighting][:field_list]
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
102
|
+
|
103
|
+
snippets = @params[:highlighting][:max_snippets]
|
104
|
+
if snippets
|
105
|
+
if snippets.kind_of? Hash
|
106
|
+
if snippets[:default]
|
107
|
+
hash["hl.snippets"] = snippets[:default]
|
108
|
+
end
|
109
|
+
if snippets[:fields]
|
110
|
+
snippets[:fields].each do |k,v|
|
111
|
+
hash["f.#{k}.hl.snippets"] = v
|
112
|
+
end
|
113
|
+
end
|
114
|
+
else
|
115
|
+
hash["hl.snippets"] = snippets
|
110
116
|
end
|
111
117
|
end
|
112
|
-
|
113
|
-
|
114
|
-
|
118
|
+
|
119
|
+
fragsize = @params[:highlighting][:fragment_size]
|
120
|
+
if fragsize
|
121
|
+
if fragsize.kind_of? Hash
|
122
|
+
if fragsize[:default]
|
123
|
+
hash["hl.fragsize"] = fragsize[:default]
|
124
|
+
end
|
125
|
+
if fragsize[:fields]
|
126
|
+
fragsize[:fields].each do |k,v|
|
127
|
+
hash["f.#{k}.hl.fragsize"] = v
|
128
|
+
end
|
129
|
+
end
|
130
|
+
else
|
131
|
+
hash["hl.fragsize"] = fragsize
|
115
132
|
end
|
116
133
|
end
|
134
|
+
|
135
|
+
rfm = @params[:highlighting][:require_field_match]
|
136
|
+
if nil != rfm
|
137
|
+
if rfm.kind_of? Hash
|
138
|
+
if nil != rfm[:default]
|
139
|
+
hash["hl.requireFieldMatch"] = rfm[:default]
|
140
|
+
end
|
141
|
+
if rfm[:fields]
|
142
|
+
rfm[:fields].each do |k,v|
|
143
|
+
hash["f.#{k}.hl.requireFieldMatch"] = v
|
144
|
+
end
|
145
|
+
end
|
146
|
+
else
|
147
|
+
hash["hl.requireFieldMatch"] = rfm
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
mac = @params[:highlighting][:max_analyzed_chars]
|
152
|
+
if mac
|
153
|
+
if mac.kind_of? Hash
|
154
|
+
if mac[:default]
|
155
|
+
hash["hl.maxAnalyzedChars"] = mac[:default]
|
156
|
+
end
|
157
|
+
if mac[:fields]
|
158
|
+
mac[:fields].each do |k,v|
|
159
|
+
hash["f.#{k}.hl.maxAnalyzedChars"] = v
|
160
|
+
end
|
161
|
+
end
|
162
|
+
else
|
163
|
+
hash["hl.maxAnalyzedChars"] = mac
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
prefix = @params[:highlighting][:prefix]
|
168
|
+
if prefix
|
169
|
+
if prefix.kind_of? Hash
|
170
|
+
if prefix[:default]
|
171
|
+
hash["hl.simple.pre"] = prefix[:default]
|
172
|
+
end
|
173
|
+
if prefix[:fields]
|
174
|
+
prefix[:fields].each do |k,v|
|
175
|
+
hash["f.#{k}.hl.simple.pre"] = v
|
176
|
+
end
|
177
|
+
end
|
178
|
+
else
|
179
|
+
hash["hl.simple.pre"] = prefix
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
suffix = @params[:highlighting][:suffix]
|
184
|
+
if suffix
|
185
|
+
if suffix.kind_of? Hash
|
186
|
+
if suffix[:default]
|
187
|
+
hash["hl.simple.post"] = suffix[:default]
|
188
|
+
end
|
189
|
+
if suffix[:fields]
|
190
|
+
suffix[:fields].each do |k,v|
|
191
|
+
hash["f.#{k}.hl.simple.post"] = v
|
192
|
+
end
|
193
|
+
end
|
194
|
+
else
|
195
|
+
hash["hl.simple.post"] = suffix
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
formatter = @params[:highlighting][:formatter]
|
200
|
+
if formatter
|
201
|
+
if formatter.kind_of? Hash
|
202
|
+
if formatter[:default]
|
203
|
+
hash["hl.formatter"] = formatter[:default]
|
204
|
+
end
|
205
|
+
if formatter[:fields]
|
206
|
+
formatter[:fields].each do |k,v|
|
207
|
+
hash["f.#{k}.hl.formatter"] = v
|
208
|
+
end
|
209
|
+
end
|
210
|
+
else
|
211
|
+
hash["hl.formatter"] = formatter
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
fragmenter = @params[:highlighting][:fragmenter]
|
216
|
+
if fragmenter
|
217
|
+
if fragmenter.kind_of? Hash
|
218
|
+
if fragmenter[:default]
|
219
|
+
hash["hl.fragmenter"] = fragmenter[:default]
|
220
|
+
end
|
221
|
+
if fragmenter[:fields]
|
222
|
+
fragmenter[:fields].each do |k,v|
|
223
|
+
hash["f.#{k}.hl.fragmenter"] = v
|
224
|
+
end
|
225
|
+
end
|
226
|
+
else
|
227
|
+
hash["hl.fragmenter"] = fragmenter
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
merge_contiguous = @params[:highlighting][:merge_contiguous]
|
232
|
+
if nil != merge_contiguous
|
233
|
+
if merge_contiguous.kind_of? Hash
|
234
|
+
if nil != merge_contiguous[:default]
|
235
|
+
hash["hl.mergeContiguous"] = merge_contiguous[:default]
|
236
|
+
end
|
237
|
+
if merge_contiguous[:fields]
|
238
|
+
merge_contiguous[:fields].each do |k,v|
|
239
|
+
hash["f.#{k}.hl.mergeContiguous"] = v
|
240
|
+
end
|
241
|
+
end
|
242
|
+
else
|
243
|
+
hash["hl.mergeContiguous"] = merge_contiguous
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
increment = @params[:highlighting][:increment]
|
248
|
+
if increment
|
249
|
+
if increment.kind_of? Hash
|
250
|
+
if increment[:default]
|
251
|
+
hash["hl.increment"] = increment[:default]
|
252
|
+
end
|
253
|
+
if increment[:fields]
|
254
|
+
increment[:fields].each do |k,v|
|
255
|
+
hash["f.#{k}.hl.increment"] = v
|
256
|
+
end
|
257
|
+
end
|
258
|
+
else
|
259
|
+
hash["hl.increment"] = increment
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
# support "old style"
|
264
|
+
alternate_fields = @params[:highlighting][:alternate_fields]
|
265
|
+
if alternate_fields
|
266
|
+
alternate_fields.each do |f,v|
|
267
|
+
hash["f.#{f}.hl.alternateField"] = v
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
alternate_field = @params[:highlighting][:alternate_field]
|
272
|
+
if alternate_field
|
273
|
+
if alternate_field.kind_of? Hash
|
274
|
+
if alternate_field[:default]
|
275
|
+
hash["hl.alternateField"] = alternate_field[:default]
|
276
|
+
end
|
277
|
+
if alternate_field[:fields]
|
278
|
+
alternate_field[:fields].each do |k,v|
|
279
|
+
hash["f.#{k}.hl.alternateField"] = v
|
280
|
+
end
|
281
|
+
end
|
282
|
+
else
|
283
|
+
hash["hl.alternateField"] = alternate_field
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
mafl = @params[:highlighting][:max_alternate_field_length]
|
288
|
+
if mafl
|
289
|
+
if mafl.kind_of? Hash
|
290
|
+
if mafl[:default]
|
291
|
+
hash["hl.maxAlternateFieldLength"] = mafl[:default]
|
292
|
+
end
|
293
|
+
if mafl[:fields]
|
294
|
+
mafl[:fields].each do |k,v|
|
295
|
+
hash["f.#{k}.hl.maxAlternateFieldLength"] = v
|
296
|
+
end
|
297
|
+
else
|
298
|
+
# support "old style"
|
299
|
+
mafl.each do |k,v|
|
300
|
+
hash["f.#{k}.hl.maxAlternateFieldLength"] = v
|
301
|
+
end
|
302
|
+
end
|
303
|
+
else
|
304
|
+
hash["hl.maxAlternateFieldLength"] = mafl
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
hash["hl.usePhraseHighlighter"] = @params[:highlighting][:use_phrase_highlighter]
|
309
|
+
|
310
|
+
regex = @params[:highlighting][:regex]
|
311
|
+
if regex
|
312
|
+
if regex[:slop]
|
313
|
+
if regex[:slop].kind_of? Hash
|
314
|
+
if regex[:slop][:default]
|
315
|
+
hash["hl.regex.slop"] = regex[:slop][:default]
|
316
|
+
end
|
317
|
+
if regex[:slop][:fields]
|
318
|
+
regex[:slop][:fields].each do |k,v|
|
319
|
+
hash["f.#{k}.hl.regex.slop"] = v
|
320
|
+
end
|
321
|
+
end
|
322
|
+
else
|
323
|
+
hash["hl.regex.slop"] = regex[:slop]
|
324
|
+
end
|
325
|
+
end
|
326
|
+
if regex[:pattern]
|
327
|
+
if regex[:pattern].kind_of? Hash
|
328
|
+
if regex[:pattern][:default]
|
329
|
+
hash["hl.regex.pattern"] = regex[:pattern][:default]
|
330
|
+
end
|
331
|
+
if regex[:pattern][:fields]
|
332
|
+
regex[:pattern][:fields].each do |k,v|
|
333
|
+
hash["f.#{k}.hl.regex.pattern"] = v
|
334
|
+
end
|
335
|
+
end
|
336
|
+
else
|
337
|
+
hash["hl.regex.pattern"] = regex[:pattern]
|
338
|
+
end
|
339
|
+
end
|
340
|
+
if regex[:max_analyzed_chars]
|
341
|
+
if regex[:max_analyzed_chars].kind_of? Hash
|
342
|
+
if regex[:max_analyzed_chars][:default]
|
343
|
+
hash["hl.regex.maxAnalyzedChars"] = regex[:max_analyzed_chars][:default]
|
344
|
+
end
|
345
|
+
if regex[:max_analyzed_chars][:fields]
|
346
|
+
regex[:max_analyzed_chars][:fields].each do |k,v|
|
347
|
+
hash["f.#{k}.hl.regex.maxAnalyzedChars"] = v
|
348
|
+
end
|
349
|
+
end
|
350
|
+
else
|
351
|
+
hash["hl.regex.maxAnalyzedChars"] = regex[:max_analyzed_chars]
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
117
356
|
end
|
118
357
|
|
119
358
|
if @params[:mlt]
|
data/lib/solr/response.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/solr/response/select.rb
CHANGED
File without changes
|
data/lib/solr/solrtasks.rb
CHANGED
File without changes
|
data/lib/solr/util.rb
CHANGED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/unit/indexer_test.rb
CHANGED
File without changes
|
File without changes
|
data/test/unit/request_test.rb
CHANGED
File without changes
|
data/test/unit/select_test.rb
CHANGED
File without changes
|
data/test/unit/solr_mock_base.rb
CHANGED
File without changes
|
@@ -103,27 +103,197 @@ class StandardRequestTest < Test::Unit::TestCase
|
|
103
103
|
request = Solr::Request::Standard.new(:query => 'query',
|
104
104
|
:highlighting => {
|
105
105
|
:field_list => ['title', 'author'],
|
106
|
-
:
|
107
|
-
:
|
106
|
+
:merge_contiguous => true,
|
107
|
+
:increment => 100,
|
108
108
|
:max_snippets => 3,
|
109
109
|
:require_field_match => true,
|
110
110
|
:prefix => "<blink>",
|
111
111
|
:suffix => "</blink>",
|
112
|
-
:fragment_size => 300
|
112
|
+
:fragment_size => 300,
|
113
|
+
:max_analyzed_chars => 102400,
|
114
|
+
:formatter => 'myFormatter',
|
115
|
+
:fragmenter => 'myFragmenter',
|
116
|
+
:use_phrase_highlighter => true
|
113
117
|
}
|
114
118
|
)
|
115
119
|
|
116
120
|
hash = request.to_hash
|
117
121
|
assert_equal true, hash[:hl]
|
118
122
|
assert_equal "title,author", hash["hl.fl"]
|
119
|
-
assert_equal
|
120
|
-
assert_equal
|
121
|
-
assert_equal
|
122
|
-
assert_equal 20, hash["f.author.hl.maxAlternateFieldLength"]
|
123
|
+
assert_equal true, hash["hl.mergeContiguous"]
|
124
|
+
assert_equal 100, hash["hl.increment"]
|
125
|
+
assert_equal 3, hash["hl.snippets"]
|
123
126
|
assert_equal true, hash["hl.requireFieldMatch"]
|
124
127
|
assert_equal "<blink>", hash["hl.simple.pre"]
|
125
128
|
assert_equal "</blink>", hash["hl.simple.post"]
|
126
129
|
assert_equal 300, hash["hl.fragsize"]
|
130
|
+
assert_equal 102400, hash["hl.maxAnalyzedChars"]
|
131
|
+
assert_equal "myFormatter", hash["hl.formatter"]
|
132
|
+
assert_equal "myFragmenter", hash["hl.fragmenter"]
|
133
|
+
assert_equal true, hash["hl.usePhraseHighlighter"]
|
134
|
+
end
|
135
|
+
|
136
|
+
def test_highlighting2
|
137
|
+
request = Solr::Request::Standard.new(:query => 'query',
|
138
|
+
:highlighting => {
|
139
|
+
:field_list => ['title', 'author'],
|
140
|
+
:merge_contiguous => {
|
141
|
+
:default=>false, :fields=>{'author'=>true}
|
142
|
+
},
|
143
|
+
:increment => {
|
144
|
+
:default=>100, :fields=>{'author'=>200}
|
145
|
+
},
|
146
|
+
:max_snippets => {
|
147
|
+
:default=>2,:fields=>{'author'=>3}
|
148
|
+
},
|
149
|
+
:prefix => {
|
150
|
+
:default=>"<em>", :fields=>{'author'=>"<blink>"},
|
151
|
+
},
|
152
|
+
:suffix => {
|
153
|
+
:default=>"</em>", :fields=>{'author'=>"</blink>"},
|
154
|
+
},
|
155
|
+
:fragment_size => {
|
156
|
+
:default=>300,:fields=>{'author'=>200}
|
157
|
+
},
|
158
|
+
:max_analyzed_chars => {
|
159
|
+
:default=>102400,:fields=>{'author'=>51200}
|
160
|
+
},
|
161
|
+
:require_field_match => {
|
162
|
+
:default=>false, :fields=>{'author'=>true}
|
163
|
+
},
|
164
|
+
:formatter => {
|
165
|
+
:default=>'defaultFormatter', :fields=>{'title'=>'titleFormatter'}
|
166
|
+
},
|
167
|
+
:fragmenter => {
|
168
|
+
:default=>'defaultFragmenter',:fields=>{'title'=>'titleFragmenter'}
|
169
|
+
},
|
170
|
+
}
|
171
|
+
)
|
172
|
+
|
173
|
+
hash = request.to_hash
|
174
|
+
assert_equal true, hash[:hl]
|
175
|
+
assert_equal "title,author", hash["hl.fl"]
|
176
|
+
assert_equal false, hash["hl.mergeContiguous"]
|
177
|
+
assert_equal true, hash["f.author.hl.mergeContiguous"]
|
178
|
+
assert_equal 100, hash["hl.increment"]
|
179
|
+
assert_equal 200, hash["f.author.hl.increment"]
|
180
|
+
assert_equal 2, hash["hl.snippets"]
|
181
|
+
assert_equal 3, hash["f.author.hl.snippets"]
|
182
|
+
assert_equal "<em>", hash["hl.simple.pre"]
|
183
|
+
assert_equal "<blink>", hash["f.author.hl.simple.pre"]
|
184
|
+
assert_equal "</em>", hash["hl.simple.post"]
|
185
|
+
assert_equal "</blink>", hash["f.author.hl.simple.post"]
|
186
|
+
assert_equal 300, hash["hl.fragsize"]
|
187
|
+
assert_equal 200, hash["f.author.hl.fragsize"]
|
188
|
+
assert_equal 102400, hash["hl.maxAnalyzedChars"]
|
189
|
+
assert_equal 51200, hash["f.author.hl.maxAnalyzedChars"]
|
190
|
+
assert_equal false, hash["hl.requireFieldMatch"]
|
191
|
+
assert_equal true, hash["f.author.hl.requireFieldMatch"]
|
192
|
+
assert_equal 'defaultFormatter', hash["hl.formatter"]
|
193
|
+
assert_equal 'titleFormatter', hash["f.title.hl.formatter"]
|
194
|
+
assert_equal 'defaultFragmenter', hash["hl.fragmenter"]
|
195
|
+
assert_equal 'titleFragmenter', hash["f.title.hl.fragmenter"]
|
196
|
+
end
|
197
|
+
|
198
|
+
def test_highlighting_regex
|
199
|
+
request = Solr::Request::Standard.new(:query => 'query',
|
200
|
+
:highlighting => {
|
201
|
+
:field_list => ['title', 'author'],
|
202
|
+
:regex => {
|
203
|
+
:slop => 0.8,
|
204
|
+
:pattern => '\w',
|
205
|
+
:max_analyzed_chars => 10000
|
206
|
+
}
|
207
|
+
}
|
208
|
+
)
|
209
|
+
|
210
|
+
hash = request.to_hash
|
211
|
+
assert_equal true, hash[:hl]
|
212
|
+
assert_equal "title,author", hash["hl.fl"]
|
213
|
+
assert_equal 0.8, hash["hl.regex.slop"]
|
214
|
+
assert_equal '\w', hash["hl.regex.pattern"]
|
215
|
+
assert_equal 10000, hash["hl.regex.maxAnalyzedChars"]
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_highlighting_regex2
|
219
|
+
request = Solr::Request::Standard.new(:query => 'query',
|
220
|
+
:highlighting => {
|
221
|
+
:field_list => ['title', 'author'],
|
222
|
+
:regex => {
|
223
|
+
:slop => { :default=>0.5, :fields=>{'author'=>0.8} },
|
224
|
+
:pattern => { :default=>'\w', :fields=>{'author'=>'\n'} },
|
225
|
+
:max_analyzed_chars => { :default=>10000, :fields=>{'author'=>20000} }
|
226
|
+
}
|
227
|
+
}
|
228
|
+
)
|
229
|
+
|
230
|
+
hash = request.to_hash
|
231
|
+
assert_equal true, hash[:hl]
|
232
|
+
assert_equal "title,author", hash["hl.fl"]
|
233
|
+
assert_equal 0.5, hash["hl.regex.slop"]
|
234
|
+
assert_equal 0.8, hash["f.author.hl.regex.slop"]
|
235
|
+
assert_equal '\w', hash["hl.regex.pattern"]
|
236
|
+
assert_equal '\n', hash["f.author.hl.regex.pattern"]
|
237
|
+
assert_equal 10000, hash["hl.regex.maxAnalyzedChars"]
|
238
|
+
assert_equal 20000, hash["f.author.hl.regex.maxAnalyzedChars"]
|
239
|
+
end
|
240
|
+
|
241
|
+
def test_highlighting_alternate_field
|
242
|
+
request = Solr::Request::Standard.new(:query => 'query',
|
243
|
+
:highlighting => {
|
244
|
+
:field_list => ['title', 'author'],
|
245
|
+
:alternate_field => 'title',
|
246
|
+
:max_alternate_field_length => 30
|
247
|
+
}
|
248
|
+
)
|
249
|
+
|
250
|
+
hash = request.to_hash
|
251
|
+
assert_equal true, hash[:hl]
|
252
|
+
assert_equal "title,author", hash["hl.fl"]
|
253
|
+
assert_equal "title", hash["hl.alternateField"]
|
254
|
+
assert_equal 30, hash["hl.maxAlternateFieldLength"]
|
255
|
+
end
|
256
|
+
|
257
|
+
def test_highlighting_alternate_field2
|
258
|
+
request = Solr::Request::Standard.new(:query => 'query',
|
259
|
+
:highlighting => {
|
260
|
+
:field_list => ['title', 'author'],
|
261
|
+
:alternate_field => {
|
262
|
+
:default=>'default', :fields=>{'title'=>'title', 'author'=>'author'}
|
263
|
+
},
|
264
|
+
:max_alternate_field_length => {
|
265
|
+
:default=>10, :fields=>{'title'=>30, 'author'=>20}
|
266
|
+
}
|
267
|
+
}
|
268
|
+
)
|
269
|
+
|
270
|
+
hash = request.to_hash
|
271
|
+
assert_equal true, hash[:hl]
|
272
|
+
assert_equal "title,author", hash["hl.fl"]
|
273
|
+
assert_equal "default", hash["hl.alternateField"]
|
274
|
+
assert_equal "title", hash["f.title.hl.alternateField"]
|
275
|
+
assert_equal "author", hash["f.author.hl.alternateField"]
|
276
|
+
assert_equal 10, hash["hl.maxAlternateFieldLength"]
|
277
|
+
assert_equal 30, hash["f.title.hl.maxAlternateFieldLength"]
|
278
|
+
assert_equal 20, hash["f.author.hl.maxAlternateFieldLength"]
|
279
|
+
end
|
280
|
+
|
281
|
+
def test_highlighting_alternate_field_old_style
|
282
|
+
request = Solr::Request::Standard.new(:query => 'query',
|
283
|
+
:highlighting => {
|
284
|
+
:field_list => ['title', 'author'],
|
285
|
+
:alternate_fields => {'title'=>'title', 'author'=>'author'},
|
286
|
+
:max_alternate_field_length => {'title'=>30, 'author'=>20}
|
287
|
+
}
|
288
|
+
)
|
289
|
+
|
290
|
+
hash = request.to_hash
|
291
|
+
assert_equal true, hash[:hl]
|
292
|
+
assert_equal "title,author", hash["hl.fl"]
|
293
|
+
assert_equal "title", hash["f.title.hl.alternateField"]
|
294
|
+
assert_equal "author", hash["f.author.hl.alternateField"]
|
295
|
+
assert_equal 30, hash["f.title.hl.maxAlternateFieldLength"]
|
296
|
+
assert_equal 20, hash["f.author.hl.maxAlternateFieldLength"]
|
127
297
|
end
|
128
298
|
|
129
299
|
def test_mlt
|
data/test/unit/suite.rb
CHANGED
File without changes
|
data/test/unit/tab_delimited.txt
CHANGED
File without changes
|
data/test/unit/util_test.rb
CHANGED
File without changes
|
File without changes
|
metadata
CHANGED
@@ -1,33 +1,26 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: solr-ruby
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.0.
|
7
|
-
date: 2008-07-14 00:00:00 -04:00
|
8
|
-
summary: Ruby library for working with Apache Solr
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: ruby-dev@lucene.apache.org
|
12
|
-
homepage: http://wiki.apache.org/solr/solr-ruby
|
13
|
-
rubyforge_project:
|
14
|
-
description:
|
15
|
-
autorequire: solr
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.0.7
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Apache Solr
|
8
|
+
autorequire: solr
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-05 00:00:00 -05:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: ruby-dev@lucene.apache.org
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
31
24
|
files:
|
32
25
|
- lib/solr
|
33
26
|
- lib/solr/connection.rb
|
@@ -47,6 +40,7 @@ files:
|
|
47
40
|
- lib/solr/request/add_document.rb
|
48
41
|
- lib/solr/request/base.rb
|
49
42
|
- lib/solr/request/commit.rb
|
43
|
+
- lib/solr/request/custom.rb
|
50
44
|
- lib/solr/request/delete.rb
|
51
45
|
- lib/solr/request/dismax.rb
|
52
46
|
- lib/solr/request/index_info.rb
|
@@ -107,17 +101,31 @@ files:
|
|
107
101
|
- test/unit/util_test.rb
|
108
102
|
- test/unit/xpath_mapper_test.rb
|
109
103
|
- test/unit/xpath_test_file.xml
|
110
|
-
|
111
|
-
|
104
|
+
has_rdoc: true
|
105
|
+
homepage: http://wiki.apache.org/solr/solr-ruby
|
106
|
+
post_install_message:
|
112
107
|
rdoc_options: []
|
113
108
|
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - ">="
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: "0"
|
116
|
+
version:
|
117
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - ">="
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: "0"
|
122
|
+
version:
|
120
123
|
requirements: []
|
121
124
|
|
122
|
-
|
125
|
+
rubyforge_project:
|
126
|
+
rubygems_version: 1.3.1
|
127
|
+
signing_key:
|
128
|
+
specification_version: 2
|
129
|
+
summary: Ruby library for working with Apache Solr
|
130
|
+
test_files: []
|
123
131
|
|