Lines 12-18
use YAML;
Link Here
|
12 |
use C4::Debug; |
12 |
use C4::Debug; |
13 |
require C4::Context; |
13 |
require C4::Context; |
14 |
|
14 |
|
15 |
use Test::More tests => 78; |
15 |
use Test::More tests => 75; |
16 |
use Test::MockModule; |
16 |
use Test::MockModule; |
17 |
use MARC::Record; |
17 |
use MARC::Record; |
18 |
use File::Spec; |
18 |
use File::Spec; |
Lines 31-37
my $QueryStemming = 0;
Link Here
|
31 |
my $QueryAutoTruncate = 0; |
31 |
my $QueryAutoTruncate = 0; |
32 |
my $QueryWeightFields = 0; |
32 |
my $QueryWeightFields = 0; |
33 |
my $QueryFuzzy = 0; |
33 |
my $QueryFuzzy = 0; |
34 |
my $QueryRemoveStopwords = 0; |
|
|
35 |
my $UseQueryParser = 0; |
34 |
my $UseQueryParser = 0; |
36 |
my $contextmodule = new Test::MockModule('C4::Context'); |
35 |
my $contextmodule = new Test::MockModule('C4::Context'); |
37 |
$contextmodule->mock('_new_dbh', sub { |
36 |
$contextmodule->mock('_new_dbh', sub { |
Lines 50-57
$contextmodule->mock('preference', sub {
Link Here
|
50 |
return $QueryWeightFields; |
49 |
return $QueryWeightFields; |
51 |
} elsif ($pref eq 'QueryFuzzy') { |
50 |
} elsif ($pref eq 'QueryFuzzy') { |
52 |
return $QueryFuzzy; |
51 |
return $QueryFuzzy; |
53 |
} elsif ($pref eq 'QueryRemoveStopwords') { |
|
|
54 |
return $QueryRemoveStopwords; |
55 |
} elsif ($pref eq 'UseQueryParser') { |
52 |
} elsif ($pref eq 'UseQueryParser') { |
56 |
return $UseQueryParser; |
53 |
return $UseQueryParser; |
57 |
} elsif ($pref eq 'maxRecordsForFacets') { |
54 |
} elsif ($pref eq 'maxRecordsForFacets') { |
Lines 120-137
$context->set_context();
Link Here
|
120 |
|
117 |
|
121 |
use_ok('C4::Search'); |
118 |
use_ok('C4::Search'); |
122 |
|
119 |
|
123 |
foreach my $string ("Leçon","modèles") { |
|
|
124 |
my @results=C4::Search::_remove_stopwords($string,"kw"); |
125 |
$debug && warn "$string ",Dump(@results); |
126 |
ok($results[0] eq $string,"$string is not modified"); |
127 |
} |
128 |
|
129 |
foreach my $string ("A book about the stars") { |
130 |
my @results=C4::Search::_remove_stopwords($string,"kw"); |
131 |
$debug && warn "$string ",Dump(@results); |
132 |
ok($results[0] ne $string,"$results[0] from $string"); |
133 |
} |
134 |
|
135 |
my $indexes = C4::Search::getIndexes(); |
120 |
my $indexes = C4::Search::getIndexes(); |
136 |
is(scalar(grep(/^ti$/, @$indexes)), 1, "Title index supported"); |
121 |
is(scalar(grep(/^ti$/, @$indexes)), 1, "Title index supported"); |
137 |
|
122 |
|
Lines 321-332
is($record->subfield('100', 'a'), 2, "Scan returned correct number of records ma
Link Here
|
321 |
|
306 |
|
322 |
# Time to test buildQuery and searchResults too. |
307 |
# Time to test buildQuery and searchResults too. |
323 |
|
308 |
|
324 |
my ( $query, $simple_query, $query_cgi, |
309 |
my ( $query, $simple_query, $query_cgi, $query_desc, |
325 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
310 |
$limit, $limit_cgi, $limit_desc, $query_type ); |
326 |
$stopwords_removed, $query_type ); |
311 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, |
327 |
( $error, $query, $simple_query, $query_cgi, |
312 |
$limit_cgi, $limit_desc, $query_type ) = buildQuery([], [ 'salud' ], [], [], [], 0, 'en'); |
328 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
|
|
329 |
$stopwords_removed, $query_type ) = buildQuery([], [ 'salud' ], [], [], [], 0, 'en'); |
330 |
like($query, qr/kw\W.*salud/, "Built CCL keyword query"); |
313 |
like($query, qr/kw\W.*salud/, "Built CCL keyword query"); |
331 |
|
314 |
|
332 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
315 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
Lines 336-368
my @newresults = searchResults('opac', $query_desc, $results_hashref->{'bibliose
Link Here
|
336 |
$results_hashref->{'biblioserver'}->{"RECORDS"}); |
319 |
$results_hashref->{'biblioserver'}->{"RECORDS"}); |
337 |
is(scalar @newresults,18, "searchResults returns requested number of hits"); |
320 |
is(scalar @newresults,18, "searchResults returns requested number of hits"); |
338 |
|
321 |
|
339 |
( $error, $query, $simple_query, $query_cgi, |
322 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
340 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
323 |
$limit_desc, $query_type ) = buildQuery([ 'and' ], [ 'salud', 'higiene' ], [], [], [], 0, 'en'); |
341 |
$stopwords_removed, $query_type ) = buildQuery([ 'and' ], [ 'salud', 'higiene' ], [], [], [], 0, 'en'); |
|
|
342 |
like($query, qr/kw\W.*salud\W.*and.*kw\W.*higiene/, "Built composed explicit-and CCL keyword query"); |
324 |
like($query, qr/kw\W.*salud\W.*and.*kw\W.*higiene/, "Built composed explicit-and CCL keyword query"); |
343 |
|
325 |
|
344 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
326 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
345 |
is($results_hashref->{biblioserver}->{hits}, 3, "getRecords generated composed keyword search for 'salud' explicit-and 'higiene' matched right number of records"); |
327 |
is($results_hashref->{biblioserver}->{hits}, 3, "getRecords generated composed keyword search for 'salud' explicit-and 'higiene' matched right number of records"); |
346 |
|
328 |
|
347 |
( $error, $query, $simple_query, $query_cgi, |
329 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
348 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
330 |
$limit_desc, $query_type ) = buildQuery([ 'or' ], [ 'salud', 'higiene' ], [], [], [], 0, 'en'); |
349 |
$stopwords_removed, $query_type ) = buildQuery([ 'or' ], [ 'salud', 'higiene' ], [], [], [], 0, 'en'); |
|
|
350 |
like($query, qr/kw\W.*salud\W.*or.*kw\W.*higiene/, "Built composed explicit-or CCL keyword query"); |
331 |
like($query, qr/kw\W.*salud\W.*or.*kw\W.*higiene/, "Built composed explicit-or CCL keyword query"); |
351 |
|
332 |
|
352 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
333 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
353 |
is($results_hashref->{biblioserver}->{hits}, 20, "getRecords generated composed keyword search for 'salud' explicit-or 'higiene' matched right number of records"); |
334 |
is($results_hashref->{biblioserver}->{hits}, 20, "getRecords generated composed keyword search for 'salud' explicit-or 'higiene' matched right number of records"); |
354 |
|
335 |
|
355 |
( $error, $query, $simple_query, $query_cgi, |
336 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
356 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
337 |
$limit_desc, $query_type ) = buildQuery([], [ 'salud', 'higiene' ], [], [], [], 0, 'en'); |
357 |
$stopwords_removed, $query_type ) = buildQuery([], [ 'salud', 'higiene' ], [], [], [], 0, 'en'); |
|
|
358 |
like($query, qr/kw\W.*salud\W.*and.*kw\W.*higiene/, "Built composed implicit-and CCL keyword query"); |
338 |
like($query, qr/kw\W.*salud\W.*and.*kw\W.*higiene/, "Built composed implicit-and CCL keyword query"); |
359 |
|
339 |
|
360 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
340 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
361 |
is($results_hashref->{biblioserver}->{hits}, 3, "getRecords generated composed keyword search for 'salud' implicit-and 'higiene' matched right number of records"); |
341 |
is($results_hashref->{biblioserver}->{hits}, 3, "getRecords generated composed keyword search for 'salud' implicit-and 'higiene' matched right number of records"); |
362 |
|
342 |
|
363 |
( $error, $query, $simple_query, $query_cgi, |
343 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
364 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
344 |
$limit_desc, $query_type ) = buildQuery([], [ 'salud' ], [ 'kw' ], [ 'su-to:Laboratorios' ], [], 0, 'en'); |
365 |
$stopwords_removed, $query_type ) = buildQuery([], [ 'salud' ], [ 'kw' ], [ 'su-to:Laboratorios' ], [], 0, 'en'); |
|
|
366 |
like($query, qr/kw\W.*salud\W*and\W*su-to\W.*Laboratorios/, "Faceted query generated correctly"); |
345 |
like($query, qr/kw\W.*salud\W*and\W*su-to\W.*Laboratorios/, "Faceted query generated correctly"); |
367 |
unlike($query_desc, qr/Laboratorios/, "Facets not included in query description"); |
346 |
unlike($query_desc, qr/Laboratorios/, "Facets not included in query description"); |
368 |
|
347 |
|
Lines 370-386
unlike($query_desc, qr/Laboratorios/, "Facets not included in query description"
Link Here
|
370 |
is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated faceted search matched right number of records"); |
349 |
is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated faceted search matched right number of records"); |
371 |
|
350 |
|
372 |
|
351 |
|
373 |
( $error, $query, $simple_query, $query_cgi, |
352 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
374 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
353 |
$limit_desc, $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'mc-itype:MP', 'mc-itype:MU' ], [], 0, 'en'); |
375 |
$stopwords_removed, $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'mc-itype:MP', 'mc-itype:MU' ], [], 0, 'en'); |
|
|
376 |
|
354 |
|
377 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
355 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
378 |
is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated mc-faceted search matched right number of records"); |
356 |
is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated mc-faceted search matched right number of records"); |
379 |
|
357 |
|
380 |
|
358 |
|
381 |
( $error, $query, $simple_query, $query_cgi, |
359 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
382 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
360 |
$limit_desc, $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'mc-loc:GEN', 'branch:FFL' ], [], 0, 'en'); |
383 |
$stopwords_removed, $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'mc-loc:GEN', 'branch:FFL' ], [], 0, 'en'); |
|
|
384 |
|
361 |
|
385 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
362 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
386 |
is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated multi-faceted search matched right number of records"); |
363 |
is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated multi-faceted search matched right number of records"); |
Lines 388-396
is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated multi-face
Link Here
|
388 |
|
365 |
|
389 |
# FIXME: the availability limit does not actually work, so for the moment we |
366 |
# FIXME: the availability limit does not actually work, so for the moment we |
390 |
# are just checking that it behaves consistently |
367 |
# are just checking that it behaves consistently |
391 |
( $error, $query, $simple_query, $query_cgi, |
368 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, |
392 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
369 |
$limit_cgi, $limit_desc, $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'available' ], [], 0, 'en'); |
393 |
$stopwords_removed, $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'available' ], [], 0, 'en'); |
|
|
394 |
|
370 |
|
395 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
371 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
396 |
is($results_hashref->{biblioserver}->{hits}, 26, "getRecords generated availability-limited search matched right number of records"); |
372 |
is($results_hashref->{biblioserver}->{hits}, 26, "getRecords generated availability-limited search matched right number of records"); |
Lines 404-491
foreach my $result (@newresults) {
Link Here
|
404 |
is ($allavailable, 'true', 'All records have at least one item available'); |
380 |
is ($allavailable, 'true', 'All records have at least one item available'); |
405 |
|
381 |
|
406 |
|
382 |
|
407 |
( $error, $query, $simple_query, $query_cgi, |
383 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
408 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
384 |
$limit_desc, $query_type ) = buildQuery([], [ 'pqf=@attr 1=_ALLRECORDS @attr 2=103 ""' ], [], [], [], 0, 'en'); |
409 |
$stopwords_removed, $query_type ) = buildQuery([], [ 'pqf=@attr 1=_ALLRECORDS @attr 2=103 ""' ], [], [], [], 0, 'en'); |
|
|
410 |
|
385 |
|
411 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
386 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
412 |
is($results_hashref->{biblioserver}->{hits}, 178, "getRecords on _ALLRECORDS PQF returned all records"); |
387 |
is($results_hashref->{biblioserver}->{hits}, 178, "getRecords on _ALLRECORDS PQF returned all records"); |
413 |
|
388 |
|
414 |
( $error, $query, $simple_query, $query_cgi, |
389 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
415 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
390 |
$limit_desc, $query_type ) = buildQuery([], [ 'pqf=@attr 1=1016 "Lessig"' ], [], [], [], 0, 'en'); |
416 |
$stopwords_removed, $query_type ) = buildQuery([], [ 'pqf=@attr 1=1016 "Lessig"' ], [], [], [], 0, 'en'); |
|
|
417 |
|
391 |
|
418 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
392 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
419 |
is($results_hashref->{biblioserver}->{hits}, 4, "getRecords PQF author search for Lessig returned proper number of matches"); |
393 |
is($results_hashref->{biblioserver}->{hits}, 4, "getRecords PQF author search for Lessig returned proper number of matches"); |
420 |
|
394 |
|
421 |
( $error, $query, $simple_query, $query_cgi, |
395 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
422 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
396 |
$limit_desc, $query_type ) = buildQuery([], [ 'ccl=au:Lessig' ], [], [], [], 0, 'en'); |
423 |
$stopwords_removed, $query_type ) = buildQuery([], [ 'ccl=au:Lessig' ], [], [], [], 0, 'en'); |
|
|
424 |
|
397 |
|
425 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
398 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
426 |
is($results_hashref->{biblioserver}->{hits}, 4, "getRecords CCL author search for Lessig returned proper number of matches"); |
399 |
is($results_hashref->{biblioserver}->{hits}, 4, "getRecords CCL author search for Lessig returned proper number of matches"); |
427 |
|
400 |
|
428 |
( $error, $query, $simple_query, $query_cgi, |
401 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
429 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
402 |
$limit_desc, $query_type ) = buildQuery([], [ 'cql=dc.author any lessig' ], [], [], [], 0, 'en'); |
430 |
$stopwords_removed, $query_type ) = buildQuery([], [ 'cql=dc.author any lessig' ], [], [], [], 0, 'en'); |
|
|
431 |
|
403 |
|
432 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
404 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
433 |
is($results_hashref->{biblioserver}->{hits}, 4, "getRecords CQL author search for Lessig returned proper number of matches"); |
405 |
is($results_hashref->{biblioserver}->{hits}, 4, "getRecords CQL author search for Lessig returned proper number of matches"); |
434 |
|
406 |
|
435 |
$QueryStemming = $QueryAutoTruncate = $QueryFuzzy = $QueryRemoveStopwords = 0; |
407 |
$QueryStemming = $QueryAutoTruncate = $QueryFuzzy = 0; |
436 |
$QueryWeightFields = 1; |
408 |
$QueryWeightFields = 1; |
437 |
( $error, $query, $simple_query, $query_cgi, |
409 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
438 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
410 |
$limit_desc, $query_type ) = buildQuery([], [ 'salud' ], [ 'kw' ], [], [], 0, 'en'); |
439 |
$stopwords_removed, $query_type ) = buildQuery([], [ 'salud' ], [ 'kw' ], [], [], 0, 'en'); |
|
|
440 |
|
411 |
|
441 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
412 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
442 |
is($results_hashref->{biblioserver}->{hits}, 19, "Weighted query returned correct number of results"); |
413 |
is($results_hashref->{biblioserver}->{hits}, 19, "Weighted query returned correct number of results"); |
443 |
is(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first"); |
414 |
is(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first"); |
444 |
|
415 |
|
445 |
$QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryRemoveStopwords = 0; |
416 |
$QueryStemming = $QueryWeightFields = $QueryFuzzy = 0; |
446 |
$QueryAutoTruncate = 1; |
417 |
$QueryAutoTruncate = 1; |
447 |
( $error, $query, $simple_query, $query_cgi, |
418 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
448 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
419 |
$limit_desc, $query_type ) = buildQuery([], [ 'medic' ], [ 'kw' ], [], [], 0, 'en'); |
449 |
$stopwords_removed, $query_type ) = buildQuery([], [ 'medic' ], [ 'kw' ], [], [], 0, 'en'); |
|
|
450 |
|
420 |
|
451 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
421 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
452 |
is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic' returns matches with automatic truncation on"); |
422 |
is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic' returns matches with automatic truncation on"); |
453 |
|
423 |
|
454 |
( $error, $query, $simple_query, $query_cgi, |
424 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
455 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
425 |
$limit_desc, $query_type ) = buildQuery([], [ 'medic*' ], [ 'kw' ], [], [], 0, 'en'); |
456 |
$stopwords_removed, $query_type ) = buildQuery([], [ 'medic*' ], [ 'kw' ], [], [], 0, 'en'); |
|
|
457 |
|
426 |
|
458 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
427 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
459 |
is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic*' returns matches with automatic truncation on"); |
428 |
is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic*' returns matches with automatic truncation on"); |
460 |
|
429 |
|
461 |
$QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryRemoveStopwords = $QueryAutoTruncate = 0; |
430 |
$QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryAutoTruncate = 0; |
462 |
( $error, $query, $simple_query, $query_cgi, |
431 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
463 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
432 |
$limit_desc, $query_type ) = buildQuery([], [ 'medic' ], [ 'kw' ], [], [], 0, 'en'); |
464 |
$stopwords_removed, $query_type ) = buildQuery([], [ 'medic' ], [ 'kw' ], [], [], 0, 'en'); |
|
|
465 |
|
433 |
|
466 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
434 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
467 |
is($results_hashref->{biblioserver}->{hits}, undef, "Search for 'medic' returns no matches with automatic truncation off"); |
435 |
is($results_hashref->{biblioserver}->{hits}, undef, "Search for 'medic' returns no matches with automatic truncation off"); |
468 |
|
436 |
|
469 |
( $error, $query, $simple_query, $query_cgi, |
437 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
470 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
438 |
$limit_desc, $query_type ) = buildQuery([], [ 'medic*' ], [ 'kw' ], [], [], 0, 'en'); |
471 |
$stopwords_removed, $query_type ) = buildQuery([], [ 'medic*' ], [ 'kw' ], [], [], 0, 'en'); |
|
|
472 |
|
439 |
|
473 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
440 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
474 |
is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic*' returns matches with automatic truncation off"); |
441 |
is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic*' returns matches with automatic truncation off"); |
475 |
|
442 |
|
476 |
$QueryStemming = $QueryWeightFields = 1; |
443 |
$QueryStemming = $QueryWeightFields = 1; |
477 |
$QueryFuzzy = $QueryRemoveStopwords = $QueryAutoTruncate = 0; |
444 |
$QueryFuzzy = $QueryAutoTruncate = 0; |
478 |
( $error, $query, $simple_query, $query_cgi, |
445 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
479 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
446 |
$limit_desc, $query_type ) = buildQuery([], [ 'pressed' ], [ 'kw' ], [], [], 0, 'en'); |
480 |
$stopwords_removed, $query_type ) = buildQuery([], [ 'pressed' ], [ 'kw' ], [], [], 0, 'en'); |
|
|
481 |
|
447 |
|
482 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
448 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
483 |
is($results_hashref->{biblioserver}->{hits}, 7, "Search for 'pressed' returns matches when stemming (and query weighting) is on"); |
449 |
is($results_hashref->{biblioserver}->{hits}, 7, "Search for 'pressed' returns matches when stemming (and query weighting) is on"); |
484 |
|
450 |
|
485 |
$QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryRemoveStopwords = $QueryAutoTruncate = 0; |
451 |
$QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryAutoTruncate = 0; |
486 |
( $error, $query, $simple_query, $query_cgi, |
452 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
487 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
453 |
$limit_desc, $query_type ) = buildQuery([], [ 'pressed' ], [ 'kw' ], [], [], 0, 'en'); |
488 |
$stopwords_removed, $query_type ) = buildQuery([], [ 'pressed' ], [ 'kw' ], [], [], 0, 'en'); |
|
|
489 |
|
454 |
|
490 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
455 |
($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0); |
491 |
is($results_hashref->{biblioserver}->{hits}, undef, "Search for 'pressed' returns no matches when stemming is off"); |
456 |
is($results_hashref->{biblioserver}->{hits}, undef, "Search for 'pressed' returns no matches when stemming is off"); |
Lines 546-596
$searchmodule->mock('SimpleSearch', sub {
Link Here
|
546 |
|
511 |
|
547 |
$UseQueryParser = 1; |
512 |
$UseQueryParser = 1; |
548 |
$term = 'Arizona'; |
513 |
$term = 'Arizona'; |
549 |
( $error, $query, $simple_query, $query_cgi, |
514 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
550 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
515 |
$limit_desc, $query_type ) = buildQuery([], [ $term ], [ 'su-br' ], [ ], [], 0, 'en'); |
551 |
$stopwords_removed, $query_type ) = buildQuery([], [ $term ], [ 'su-br' ], [ ], [], 0, 'en'); |
|
|
552 |
matchesExplodedTerms("Advanced search for broader subjects", $query, 'Arizona', 'United States'); |
516 |
matchesExplodedTerms("Advanced search for broader subjects", $query, 'Arizona', 'United States'); |
553 |
|
517 |
|
554 |
( $error, $query, $simple_query, $query_cgi, |
518 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
555 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
519 |
$limit_desc, $query_type ) = buildQuery([], [ $term ], [ 'su-na' ], [ ], [], 0, 'en'); |
556 |
$stopwords_removed, $query_type ) = buildQuery([], [ $term ], [ 'su-na' ], [ ], [], 0, 'en'); |
|
|
557 |
matchesExplodedTerms("Advanced search for narrower subjects", $query, 'Arizona', 'Maricopa County', 'Navajo County', 'Pima County'); |
520 |
matchesExplodedTerms("Advanced search for narrower subjects", $query, 'Arizona', 'Maricopa County', 'Navajo County', 'Pima County'); |
558 |
|
521 |
|
559 |
( $error, $query, $simple_query, $query_cgi, |
522 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
560 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
523 |
$limit_desc, $query_type ) = buildQuery([], [ $term ], [ 'su-rl' ], [ ], [], 0, 'en'); |
561 |
$stopwords_removed, $query_type ) = buildQuery([], [ $term ], [ 'su-rl' ], [ ], [], 0, 'en'); |
|
|
562 |
matchesExplodedTerms("Advanced search for related subjects", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County'); |
524 |
matchesExplodedTerms("Advanced search for related subjects", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County'); |
563 |
|
525 |
|
564 |
( $error, $query, $simple_query, $query_cgi, |
526 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
565 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
527 |
$limit_desc, $query_type ) = buildQuery([], [ "$term", 'history' ], [ 'su-rl', 'kw' ], [ ], [], 0, 'en'); |
566 |
$stopwords_removed, $query_type ) = buildQuery([], [ "$term", 'history' ], [ 'su-rl', 'kw' ], [ ], [], 0, 'en'); |
|
|
567 |
matchesExplodedTerms("Advanced search for related subjects and keyword 'history' searches related subjects", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County'); |
528 |
matchesExplodedTerms("Advanced search for related subjects and keyword 'history' searches related subjects", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County'); |
568 |
like($query, qr/history/, "Advanced search for related subjects and keyword 'history' searches for 'history'"); |
529 |
like($query, qr/history/, "Advanced search for related subjects and keyword 'history' searches for 'history'"); |
569 |
|
530 |
|
570 |
( $error, $query, $simple_query, $query_cgi, |
531 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
571 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
532 |
$limit_desc, $query_type ) = buildQuery([], [ 'history', "$term" ], [ 'kw', 'su-rl' ], [ ], [], 0, 'en'); |
572 |
$stopwords_removed, $query_type ) = buildQuery([], [ 'history', "$term" ], [ 'kw', 'su-rl' ], [ ], [], 0, 'en'); |
|
|
573 |
matchesExplodedTerms("Order of terms doesn't matter for advanced search", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County'); |
533 |
matchesExplodedTerms("Order of terms doesn't matter for advanced search", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County'); |
574 |
like($query, qr/history/, "Order of terms doesn't matter for advanced search"); |
534 |
like($query, qr/history/, "Order of terms doesn't matter for advanced search"); |
575 |
|
535 |
|
576 |
( $error, $query, $simple_query, $query_cgi, |
536 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
577 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
537 |
$limit_desc, $query_type ) = buildQuery([], [ "su-br($term)" ], [ ], [ ], [], 0, 'en'); |
578 |
$stopwords_removed, $query_type ) = buildQuery([], [ "su-br($term)" ], [ ], [ ], [], 0, 'en'); |
|
|
579 |
matchesExplodedTerms("Simple search for broader subjects", $query, 'Arizona', 'United States'); |
538 |
matchesExplodedTerms("Simple search for broader subjects", $query, 'Arizona', 'United States'); |
580 |
|
539 |
|
581 |
( $error, $query, $simple_query, $query_cgi, |
540 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
582 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
541 |
$limit_desc, $query_type ) = buildQuery([], [ "su-na($term)" ], [ ], [ ], [], 0, 'en'); |
583 |
$stopwords_removed, $query_type ) = buildQuery([], [ "su-na($term)" ], [ ], [ ], [], 0, 'en'); |
|
|
584 |
matchesExplodedTerms("Simple search for narrower subjects", $query, 'Arizona', 'Maricopa County', 'Navajo County', 'Pima County'); |
542 |
matchesExplodedTerms("Simple search for narrower subjects", $query, 'Arizona', 'Maricopa County', 'Navajo County', 'Pima County'); |
585 |
|
543 |
|
586 |
( $error, $query, $simple_query, $query_cgi, |
544 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
587 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
545 |
$limit_desc, $query_type ) = buildQuery([], [ "su-rl($term)" ], [ ], [ ], [], 0, 'en'); |
588 |
$stopwords_removed, $query_type ) = buildQuery([], [ "su-rl($term)" ], [ ], [ ], [], 0, 'en'); |
|
|
589 |
matchesExplodedTerms("Simple search for related subjects", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County'); |
546 |
matchesExplodedTerms("Simple search for related subjects", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County'); |
590 |
|
547 |
|
591 |
( $error, $query, $simple_query, $query_cgi, |
548 |
( $error, $query, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, |
592 |
$query_desc, $limit, $limit_cgi, $limit_desc, |
549 |
$limit_desc, $query_type ) = buildQuery([], [ "history && su-rl($term)" ], [ ], [ ], [], 0, 'en'); |
593 |
$stopwords_removed, $query_type ) = buildQuery([], [ "history && su-rl($term)" ], [ ], [ ], [], 0, 'en'); |
|
|
594 |
matchesExplodedTerms("Simple search for related subjects and keyword 'history' searches related subjects", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County'); |
550 |
matchesExplodedTerms("Simple search for related subjects and keyword 'history' searches related subjects", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County'); |
595 |
like($query, qr/history/, "Simple search for related subjects and keyword 'history' searches for 'history'"); |
551 |
like($query, qr/history/, "Simple search for related subjects and keyword 'history' searches for 'history'"); |
596 |
|
552 |
|