201
204
check_hits(rq, [15,16,17])
207
def test_typed_range_query()
208
rq = TypedRangeQuery.new(:number, :>= => "-1.0", :<= => 1.0)
209
check_hits(rq, [0,1,4,10,15,17])
211
rq = TypedRangeQuery.new(:number, :> => "-1.0", :< => 1.0)
212
check_hits(rq, [0,1,4,15])
216
rq = TypedRangeQuery.new(:number, :> => "1.0", :<= =>"0xa")
217
check_hits(rq, [6,7,9,12])
221
rq = TypedRangeQuery.new(:number, :<= => "0.0")
222
check_hits(rq, [5,11,15,16,17])
225
rq = TypedRangeQuery.new(:number, :> => "0.0")
226
check_hits(rq, [0,1,2,3,4,6,7,8,9,10,12,13,14])
228
# below range - no results
229
rq = TypedRangeQuery.new(:number, :> => "10051006", :< =>"10051010")
232
# above range - no results
233
rq = TypedRangeQuery.new(:number, :> => "-12518421", :< =>"-12518420")
204
237
def test_prefix_query()
205
238
pq = PrefixQuery.new(:category, "cat1")
206
239
check_hits(pq, [0, 1, 2, 3, 4, 13, 14, 15, 16, 17])
358
391
assert_equal("<b>the words</b>...", highlights[0])
359
392
assert_equal("...<b>one</b> <b>two</b>...", highlights[1])
361
# {:dates => '20070505, 20071230, 20060920, 20081111'},
363
395
[RangeQuery.new(:dates, :>= => '20081111'),
364
396
'20070505 20071230 20060920 <b>20081111</b>'],
381
413
#assert_equal("<b>the words</b>...", highlights[0])
382
414
#assert_equal("...<b>one</b> <b>two</b>...", highlights[1])
417
def test_highlighter_with_standard_analyzer()
418
dir = Ferret::Store::RAMDirectory.new
419
iw = Ferret::Index::IndexWriter.new(:dir => dir,
420
:analyzer => Ferret::Analysis::StandardAnalyzer.new())
422
{:field => "field has a url http://ferret.davebalmain.com/trac/ end"},
423
].each {|doc| iw << doc }
426
searcher = Searcher.new(dir)
428
q = TermQuery.new(:field, "ferret.davebalmain.com/trac");
429
highlights = searcher.highlight(q, 0, :field,
430
:excerpt_length => 1000,
432
assert_equal(1, highlights.size)
433
assert_equal("field has a url <b>http://ferret.davebalmain.com/trac/</b> end",