View | Details | Raw Unified | Return to bug 9819
Collapse All | Expand All

(-)a/C4/Context.pm (-46 lines)
Lines 128-135 C4::Context - Maintain and manipulate the context of a Koha script Link Here
128
128
129
  $Zconn = C4::Context->Zconn;
129
  $Zconn = C4::Context->Zconn;
130
130
131
  $stopwordhash = C4::Context->stopwords;
132
133
=head1 DESCRIPTION
131
=head1 DESCRIPTION
134
132
135
When a Koha script runs, it makes use of a certain number of things:
133
When a Koha script runs, it makes use of a certain number of things:
Lines 365-371 sub new { Link Here
365
    return if !defined($self->{"config"});
363
    return if !defined($self->{"config"});
366
364
367
    $self->{"Zconn"} = undef;    # Zebra Connections
365
    $self->{"Zconn"} = undef;    # Zebra Connections
368
    $self->{"stopwords"} = undef; # stopwords list
369
    $self->{"marcfromkohafield"} = undef; # the hash with relations between koha table fields and MARC field/subfield
366
    $self->{"marcfromkohafield"} = undef; # the hash with relations between koha table fields and MARC field/subfield
370
    $self->{"userenv"} = undef;        # User env
367
    $self->{"userenv"} = undef;        # User env
371
    $self->{"activeuser"} = undef;        # current active user
368
    $self->{"activeuser"} = undef;        # current active user
Lines 908-915 sub marcfromkohafield Link Here
908
}
905
}
909
906
910
# _new_marcfromkohafield
907
# _new_marcfromkohafield
911
# Internal helper function (not a method!). This creates a new
912
# hash with stopwords
913
sub _new_marcfromkohafield
908
sub _new_marcfromkohafield
914
{
909
{
915
    my $dbh = C4::Context->dbh;
910
    my $dbh = C4::Context->dbh;
Lines 923-969 sub _new_marcfromkohafield Link Here
923
    return $marcfromkohafield;
918
    return $marcfromkohafield;
924
}
919
}
925
920
926
=head2 stopwords
927
928
  $dbh = C4::Context->stopwords;
929
930
Returns a hash with stopwords.
931
932
This hash is cached for future use: if you call
933
C<C4::Context-E<gt>stopwords> twice, you will get the same hash without real DB access
934
935
=cut
936
937
#'
938
sub stopwords
939
{
940
    my $retval = {};
941
942
    # If the hash already exists, return it.
943
    return $context->{"stopwords"} if defined($context->{"stopwords"});
944
945
    # No hash. Create one.
946
    $context->{"stopwords"} = &_new_stopwords();
947
948
    return $context->{"stopwords"};
949
}
950
951
# _new_stopwords
952
# Internal helper function (not a method!). This creates a new
953
# hash with stopwords
954
sub _new_stopwords
955
{
956
    my $dbh = C4::Context->dbh;
957
    my $stopwordlist;
958
    my $sth = $dbh->prepare("select word from stopwords");
959
    $sth->execute;
960
    while (my $stopword = $sth->fetchrow_array) {
961
        $stopwordlist->{$stopword} = uc($stopword);
962
    }
963
    $stopwordlist->{A} = "A" unless $stopwordlist;
964
    return $stopwordlist;
965
}
966
967
=head2 userenv
921
=head2 userenv
968
922
969
  C4::Context->userenv;
923
  C4::Context->userenv;
(-)a/C4/Search.pm (-49 / +9 lines)
Lines 911-942 sub pazGetRecords { Link Here
911
    return ( undef, $results_hashref, \@facets_loop );
911
    return ( undef, $results_hashref, \@facets_loop );
912
}
912
}
913
913
914
# STOPWORDS
915
sub _remove_stopwords {
916
    my ( $operand, $index ) = @_;
917
    my @stopwords_removed;
918
919
    # phrase and exact-qualified indexes shouldn't have stopwords removed
920
    if ( $index !~ m/,(phr|ext)/ ) {
921
922
# remove stopwords from operand : parse all stopwords & remove them (case insensitive)
923
#       we use IsAlpha unicode definition, to deal correctly with diacritics.
924
#       otherwise, a French word like "leçon" would be split into "le" "çon", "le"
925
#       is a stopword, we'd get "çon" and wouldn't find anything...
926
#
927
		foreach ( keys %{ C4::Context->stopwords } ) {
928
			next if ( $_ =~ /(and|or|not)/ );    # don't remove operators
929
			if ( my ($matched) = ($operand =~
930
				/([^\X\p{isAlnum}]\Q$_\E[^\X\p{isAlnum}]|[^\X\p{isAlnum}]\Q$_\E$|^\Q$_\E[^\X\p{isAlnum}])/gi))
931
			{
932
				$operand =~ s/\Q$matched\E/ /gi;
933
				push @stopwords_removed, $_;
934
			}
935
		}
936
	}
937
    return ( $operand, \@stopwords_removed );
938
}
939
940
# TRUNCATION
914
# TRUNCATION
941
sub _detect_truncation {
915
sub _detect_truncation {
942
    my ( $operand, $index ) = @_;
916
    my ( $operand, $index ) = @_;
Lines 1416-1425 sub parseQuery { Link Here
1416
$simple_query, $query_cgi,
1390
$simple_query, $query_cgi,
1417
$query_desc, $limit,
1391
$query_desc, $limit,
1418
$limit_cgi, $limit_desc,
1392
$limit_cgi, $limit_desc,
1419
$stopwords_removed, $query_type ) = buildQuery ( $operators, $operands, $indexes, $limits, $sort_by, $scan, $lang);
1393
$query_type ) = buildQuery ( $operators, $operands, $indexes, $limits, $sort_by, $scan, $lang);
1420
1394
1421
Build queries and limits in CCL, CGI, Human,
1395
Build queries and limits in CCL, CGI, Human,
1422
handle truncation, stemming, field weighting, stopwords, fuzziness, etc.
1396
handle truncation, stemming, field weighting, fuzziness, etc.
1423
1397
1424
See verbose embedded documentation.
1398
See verbose embedded documentation.
1425
1399
Lines 1445-1451 sub buildQuery { Link Here
1445
    my $auto_truncation  = C4::Context->preference("QueryAutoTruncate")    || 0;
1419
    my $auto_truncation  = C4::Context->preference("QueryAutoTruncate")    || 0;
1446
    my $weight_fields    = C4::Context->preference("QueryWeightFields")    || 0;
1420
    my $weight_fields    = C4::Context->preference("QueryWeightFields")    || 0;
1447
    my $fuzzy_enabled    = C4::Context->preference("QueryFuzzy")           || 0;
1421
    my $fuzzy_enabled    = C4::Context->preference("QueryFuzzy")           || 0;
1448
    my $remove_stopwords = C4::Context->preference("QueryRemoveStopwords") || 0;
1449
1422
1450
    my $query        = $operands[0];
1423
    my $query        = $operands[0];
1451
    my $simple_query = $operands[0];
1424
    my $simple_query = $operands[0];
Lines 1458-1465 sub buildQuery { Link Here
1458
    my $limit_cgi;
1431
    my $limit_cgi;
1459
    my $limit_desc;
1432
    my $limit_desc;
1460
1433
1461
    my $stopwords_removed;    # flag to determine if stopwords have been removed
1462
1463
    my $cclq       = 0;
1434
    my $cclq       = 0;
1464
    my $cclindexes = getIndexes();
1435
    my $cclindexes = getIndexes();
1465
    if ( $query !~ /\s*(ccl=|pqf=|cql=)/ ) {
1436
    if ( $query !~ /\s*(ccl=|pqf=|cql=)/ ) {
Lines 1503-1509 sub buildQuery { Link Here
1503
#        return (
1474
#        return (
1504
#            undef,              $query, $simple_query, $query_cgi,
1475
#            undef,              $query, $simple_query, $query_cgi,
1505
#            $query,             $limit, $limit_cgi,    $limit_desc,
1476
#            $query,             $limit, $limit_cgi,    $limit_desc,
1506
#            $stopwords_removed, 'ccl'
1477
#            'ccl'
1507
#        );
1478
#        );
1508
#    }
1479
#    }
1509
1480
Lines 1527-1537 sub buildQuery { Link Here
1527
              # A flag to determine whether or not to add the index to the query
1498
              # A flag to determine whether or not to add the index to the query
1528
                my $indexes_set;
1499
                my $indexes_set;
1529
1500
1530
# If the user is sophisticated enough to specify an index, turn off field weighting, stemming, and stopword handling
1501
# If the user is sophisticated enough to specify an index, turn off field weighting, and stemming handling
1531
                if ( $operands[$i] =~ /\w(:|=)/ || $scan ) {
1502
                if ( $operands[$i] =~ /\w(:|=)/ || $scan ) {
1532
                    $weight_fields    = 0;
1503
                    $weight_fields    = 0;
1533
                    $stemming         = 0;
1504
                    $stemming         = 0;
1534
                    $remove_stopwords = 0;
1535
                } else {
1505
                } else {
1536
                    $operands[$i] =~ s/\?/{?}/g; # need to escape question marks
1506
                    $operands[$i] =~ s/\?/{?}/g; # need to escape question marks
1537
                }
1507
                }
Lines 1550-1556 sub buildQuery { Link Here
1550
                    #weight_fields/relevance search causes errors with date ranges
1520
                    #weight_fields/relevance search causes errors with date ranges
1551
                    #In the case of YYYY-, it will only return records with a 'yr' of YYYY (not the range)
1521
                    #In the case of YYYY-, it will only return records with a 'yr' of YYYY (not the range)
1552
                    #In the case of YYYY-YYYY, it will return no results
1522
                    #In the case of YYYY-YYYY, it will return no results
1553
					$stemming = $auto_truncation = $weight_fields = $fuzzy_enabled = $remove_stopwords = 0;
1523
                    $stemming = $auto_truncation = $weight_fields = $fuzzy_enabled = 0;
1554
                }
1524
                }
1555
1525
1556
                # Date of Acquisition
1526
                # Date of Acquisition
Lines 1561-1575 sub buildQuery { Link Here
1561
                    #Fuzzy actually only applies during _build_weighted_query, and is reset there anyway, so
1531
                    #Fuzzy actually only applies during _build_weighted_query, and is reset there anyway, so
1562
                      #irrelevant here
1532
                      #irrelevant here
1563
                    #remove_stopwords doesn't function anymore so is irrelevant
1533
                    #remove_stopwords doesn't function anymore so is irrelevant
1564
					$stemming = $auto_truncation = $weight_fields = $fuzzy_enabled = $remove_stopwords = 0;
1534
                    $stemming = $auto_truncation = $weight_fields = $fuzzy_enabled = 0;
1565
                }
1535
                }
1566
                # ISBN,ISSN,Standard Number, don't need special treatment
1536
                # ISBN,ISSN,Standard Number, don't need special treatment
1567
                elsif ( $index eq 'nb' || $index eq 'ns' ) {
1537
                elsif ( $index eq 'nb' || $index eq 'ns' ) {
1568
                    (
1538
                    (
1569
                        $stemming,      $auto_truncation,
1539
                        $stemming,      $auto_truncation,
1570
                        $weight_fields, $fuzzy_enabled,
1540
                        $weight_fields, $fuzzy_enabled
1571
                        $remove_stopwords
1541
                    ) = ( 0, 0, 0, 0 );
1572
                    ) = ( 0, 0, 0, 0, 0 );
1573
1542
1574
                    if ( $index eq 'nb' ) {
1543
                    if ( $index eq 'nb' ) {
1575
                        if ( C4::Context->preference("SearchWithISBNVariations") ) {
1544
                        if ( C4::Context->preference("SearchWithISBNVariations") ) {
Lines 1594-1608 sub buildQuery { Link Here
1594
                my $index_plus       = $index . $struct_attr . ':';
1563
                my $index_plus       = $index . $struct_attr . ':';
1595
                my $index_plus_comma = $index . $struct_attr . ',';
1564
                my $index_plus_comma = $index . $struct_attr . ',';
1596
1565
1597
                # Remove Stopwords
1598
                if ($remove_stopwords) {
1599
                    ( $operand, $stopwords_removed ) =
1600
                      _remove_stopwords( $operand, $index );
1601
                    warn "OPERAND w/out STOPWORDS: >$operand<" if $DEBUG;
1602
                    warn "REMOVED STOPWORDS: @$stopwords_removed"
1603
                      if ( $stopwords_removed && $DEBUG );
1604
                }
1605
1606
                if ($auto_truncation){
1566
                if ($auto_truncation){
1607
                        unless ( $index =~ /,(st-|phr|ext)/ ) {
1567
                        unless ( $index =~ /,(st-|phr|ext)/ ) {
1608
						#FIXME only valid with LTR scripts
1568
						#FIXME only valid with LTR scripts
Lines 1789-1795 sub buildQuery { Link Here
1789
    return (
1749
    return (
1790
        undef,              $query, $simple_query, $query_cgi,
1750
        undef,              $query, $simple_query, $query_cgi,
1791
        $query_desc,        $limit, $limit_cgi,    $limit_desc,
1751
        $query_desc,        $limit, $limit_cgi,    $limit_desc,
1792
        $stopwords_removed, $query_type
1752
        $query_type
1793
    );
1753
    );
1794
}
1754
}
1795
1755
(-)a/INSTALL.fedora7 (-1 lines)
Lines 1183-1189 MySQL> show tables; Link Here
1183
| sessions |
1183
| sessions |
1184
| special_holidays |
1184
| special_holidays |
1185
| statistics |
1185
| statistics |
1186
| stopwords |
1187
| subscription |
1186
| subscription |
1188
| subscriptionhistory |
1187
| subscriptionhistory |
1189
| subscriptionroutinglist |
1188
| subscriptionroutinglist |
(-)a/admin/stopwords.pl (-96 lines)
Lines 1-96 Link Here
1
#!/usr/bin/perl
2
3
#script to administer the stopwords table
4
#written 20/02/2002 by paul.poulain@free.fr
5
# This software is placed under the gnu General Public License, v2 (http://www.gnu.org/licenses/gpl.html)
6
7
# Copyright 2000-2002 Katipo Communications
8
#
9
# This file is part of Koha.
10
#
11
# Koha is free software; you can redistribute it and/or modify it
12
# under the terms of the GNU General Public License as published by
13
# the Free Software Foundation; either version 3 of the License, or
14
# (at your option) any later version.
15
#
16
# Koha is distributed in the hope that it will be useful, but
17
# WITHOUT ANY WARRANTY; without even the implied warranty of
18
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
# GNU General Public License for more details.
20
#
21
# You should have received a copy of the GNU General Public License
22
# along with Koha; if not, see <http://www.gnu.org/licenses>.
23
24
use strict;
25
use warnings;
26
use CGI qw ( -utf8 );
27
use C4::Context;
28
use C4::Output;
29
use C4::Auth;
30
31
sub StringSearch  {
32
	my $sth = C4::Context->dbh->prepare("
33
		SELECT word FROM stopwords WHERE (word LIKE ?) ORDER BY word
34
	");
35
	$sth->execute((shift || '') . "%");
36
	return $sth->fetchall_arrayref({});
37
}
38
39
my $input = new CGI;
40
my $searchfield = $input->param('searchfield');
41
my $offset      = $input->param('offset') || 0;
42
my $script_name = "/cgi-bin/koha/admin/stopwords.pl";
43
44
my $pagesize = 20;
45
my $op = $input->param('op') || '';
46
47
my ($template, $loggedinuser, $cookie) 
48
    = get_template_and_user({template_name => "admin/stopwords.tt",
49
    query => $input,
50
    type => "intranet",
51
    flagsrequired => {parameters => 'parameters_remaining_permissions'},
52
    authnotrequired => 0,
53
    debug => 1,
54
    });
55
56
$template->param(script_name => $script_name,
57
		 searchfield => $searchfield);
58
59
my $dbh = C4::Context->dbh;
60
if ($op eq 'add_form') {
61
	$template->param(add_form => 1);
62
} elsif ($op eq 'add_validate') {
63
	$template->param(add_validate => 1);
64
	my @tab = split / |,/, $input->param('word');
65
	my $sth=$dbh->prepare("INSERT INTO stopwords (word) VALUES (?)");
66
	foreach my $insert_value (@tab) {
67
		$sth->execute($insert_value);
68
	}
69
} elsif ($op eq 'delete_confirm') {
70
	$template->param(delete_confirm => 1);
71
} elsif ($op eq 'delete_confirmed') {
72
	$template->param(delete_confirmed => 1);
73
	my $sth=$dbh->prepare("delete from stopwords where word=?");
74
	$sth->execute($searchfield);
75
} else { # DEFAULT
76
	$template->param(else => 1);
77
    my $results = StringSearch($searchfield);
78
    my $count = scalar(@$results);
79
	my @loop;
80
    # FIXME: limit and offset should get to the SQL query
81
	for (my $i=$offset; $i < ($offset+$pagesize<$count?$offset+$pagesize:$count); $i++){
82
		push @loop, {word => $results->[$i]{'word'}};
83
	}
84
	$template->param(loop => \@loop);
85
	if ($offset > 0) {
86
		$template->param(offsetgtzero => 1,
87
				 prevpage => $offset-$pagesize);
88
	}
89
	if ($offset+$pagesize < scalar(@$results)) {
90
		$template->param(ltcount => 1,
91
				 nextpage => $offset+$pagesize);
92
	}
93
}
94
95
output_html_with_http_headers $input, $cookie, $template->output;
96
(-)a/catalogue/search.pl (-3 / +2 lines)
Lines 482-493 my $hits; Link Here
482
my $expanded_facet = $params->{'expand'};
482
my $expanded_facet = $params->{'expand'};
483
483
484
# Define some global variables
484
# Define some global variables
485
my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type);
485
my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
486
486
487
my @results;
487
my @results;
488
488
489
## I. BUILD THE QUERY
489
## I. BUILD THE QUERY
490
( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = buildQuery(\@operators,\@operands,\@indexes,\@limits,\@sort_by,$scan,$lang);
490
( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type) = buildQuery(\@operators,\@operands,\@indexes,\@limits,\@sort_by,$scan,$lang);
491
491
492
## parse the query_cgi string and put it into a form suitable for <input>s
492
## parse the query_cgi string and put it into a form suitable for <input>s
493
my @query_inputs;
493
my @query_inputs;
Lines 615-621 for (my $i=0;$i<@servers;$i++) { Link Here
615
            if ($query_desc || $limit_desc) {
615
            if ($query_desc || $limit_desc) {
616
                $template->param(searchdesc => 1);
616
                $template->param(searchdesc => 1);
617
            }
617
            }
618
            $template->param(stopwords_removed => "@$stopwords_removed") if $stopwords_removed;
619
            $template->param(results_per_page =>  $results_per_page);
618
            $template->param(results_per_page =>  $results_per_page);
620
            # must define a value for size if not present in DB
619
            # must define a value for size if not present in DB
621
            # in order to avoid problems generated by the default size value in TT
620
            # in order to avoid problems generated by the default size value in TT
(-)a/cataloguing/addbooks.pl (-2 / +2 lines)
Lines 77-84 if ($query) { Link Here
77
    if ($QParser) {
77
    if ($QParser) {
78
        $builtquery = $query;
78
        $builtquery = $query;
79
    } else {
79
    } else {
80
        my ( $builterror,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type);
80
        my ( $builterror,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
81
        ( $builterror,$builtquery,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = buildQuery(undef,\@operands);
81
        ( $builterror,$builtquery,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type) = buildQuery(undef,\@operands);
82
    }
82
    }
83
83
84
    # find results
84
    # find results
(-)a/installer/data/mysql/de-DE/mandatory/stopwords.sql (-99 lines)
Lines 1-99 Link Here
1
INSERT INTO stopwords VALUES
2
('a'),
3
('about'),
4
('also'),
5
('an'),
6
('and'),
7
('another'),
8
('any'),
9
('are'),
10
('as'),
11
('at'),
12
('back'),
13
('be'),
14
('because'),
15
('been'),
16
('being'),
17
('but'),
18
('by'),
19
('can'),
20
('could'),
21
('did'),
22
('do'),
23
('each'),
24
('end'),
25
('even'),
26
('for'),
27
('from'),
28
('get'),
29
('go'),
30
('had'),
31
('have'),
32
('he'),
33
('her'),
34
('here'),
35
('his'),
36
('how'),
37
('i'),
38
('if'),
39
('in'),
40
('into'),
41
('is'),
42
('it'),
43
('just'),
44
('may'),
45
('me'),
46
('might'),
47
('much'),
48
('must'),
49
('my'),
50
('no'),
51
('not'),
52
('of'),
53
('off'),
54
('on'),
55
('only'),
56
('or'),
57
('other'),
58
('our'),
59
('out'),
60
('should'),
61
('so'),
62
('some'),
63
('still'),
64
('such'),
65
('than'),
66
('that'),
67
('the'),
68
('their'),
69
('them'),
70
('then'),
71
('there'),
72
('these'),
73
('they'),
74
('this'),
75
('those'),
76
('to'),
77
('too'),
78
('try'),
79
('two'),
80
('under'),
81
('up'),
82
('us'),
83
('was'),
84
('we'),
85
('were'),
86
('what'),
87
('when'),
88
('where'),
89
('which'),
90
('while'),
91
('who'),
92
('why'),
93
('will'),
94
('with'),
95
('within'),
96
('without'),
97
('would'),
98
('you'),
99
('your');
(-)a/installer/data/mysql/de-DE/mandatory/stopwords.txt (-1 lines)
Line 1 Link Here
1
Englische Stoppwortliste. Sie können diese nach der Installation ändern.
(-)a/installer/data/mysql/en/mandatory/stopwords.sql (-99 lines)
Lines 1-99 Link Here
1
INSERT INTO stopwords VALUES
2
('a'),
3
('about'),
4
('also'),
5
('an'),
6
('and'),
7
('another'),
8
('any'),
9
('are'),
10
('as'),
11
('at'),
12
('back'),
13
('be'),
14
('because'),
15
('been'),
16
('being'),
17
('but'),
18
('by'),
19
('can'),
20
('could'),
21
('did'),
22
('do'),
23
('each'),
24
('end'),
25
('even'),
26
('for'),
27
('from'),
28
('get'),
29
('go'),
30
('had'),
31
('have'),
32
('he'),
33
('her'),
34
('here'),
35
('his'),
36
('how'),
37
('i'),
38
('if'),
39
('in'),
40
('into'),
41
('is'),
42
('it'),
43
('just'),
44
('may'),
45
('me'),
46
('might'),
47
('much'),
48
('must'),
49
('my'),
50
('no'),
51
('not'),
52
('of'),
53
('off'),
54
('on'),
55
('only'),
56
('or'),
57
('other'),
58
('our'),
59
('out'),
60
('should'),
61
('so'),
62
('some'),
63
('still'),
64
('such'),
65
('than'),
66
('that'),
67
('the'),
68
('their'),
69
('them'),
70
('then'),
71
('there'),
72
('these'),
73
('they'),
74
('this'),
75
('those'),
76
('to'),
77
('too'),
78
('try'),
79
('two'),
80
('under'),
81
('up'),
82
('us'),
83
('was'),
84
('we'),
85
('were'),
86
('what'),
87
('when'),
88
('where'),
89
('which'),
90
('while'),
91
('who'),
92
('why'),
93
('will'),
94
('with'),
95
('within'),
96
('without'),
97
('would'),
98
('you'),
99
('your');
(-)a/installer/data/mysql/en/mandatory/stopwords.txt (-1 lines)
Line 1 Link Here
1
English stop words. You can change this after installation.
(-)a/installer/data/mysql/fr-FR/1-Obligatoire/stopwords.sql (-71 lines)
Lines 1-71 Link Here
1
# phpMyAdmin MySQL-Dump
2
# version 2.2.6-rc1
3
# http://phpwizard.net/phpMyAdmin/
4
# http://phpmyadmin.sourceforge.net/ (download page)
5
#
6
# Host: localhost
7
# Generation Time: Nov 22, 2002 at 11:10 AM
8
# Server version: 3.23.52
9
# PHP Version: 4.2.3
10
# Database : `koha_fr`
11
12
#
13
# Dumping data for table `stopwords`
14
#
15
16
INSERT INTO stopwords VALUES ('AU');
17
INSERT INTO stopwords VALUES ('ÇA');
18
INSERT INTO stopwords VALUES ('CAR');
19
INSERT INTO stopwords VALUES ('CE');
20
INSERT INTO stopwords VALUES ('CELA');
21
INSERT INTO stopwords VALUES ('CES');
22
INSERT INTO stopwords VALUES ('CEUX');
23
INSERT INTO stopwords VALUES ('CI');
24
INSERT INTO stopwords VALUES ('DANS');
25
INSERT INTO stopwords VALUES ('DE');
26
INSERT INTO stopwords VALUES ('DES');
27
INSERT INTO stopwords VALUES ('DU');
28
INSERT INTO stopwords VALUES ('ELLE');
29
INSERT INTO stopwords VALUES ('ELLES');
30
INSERT INTO stopwords VALUES ('EN');
31
INSERT INTO stopwords VALUES ('EST');
32
INSERT INTO stopwords VALUES ('ET');
33
INSERT INTO stopwords VALUES ('EU');
34
INSERT INTO stopwords VALUES ('IL');
35
INSERT INTO stopwords VALUES ('ILS');
36
INSERT INTO stopwords VALUES ('JE');
37
INSERT INTO stopwords VALUES ('LA');
38
INSERT INTO stopwords VALUES ('LE');
39
INSERT INTO stopwords VALUES ('LES');
40
INSERT INTO stopwords VALUES ('LEUR');
41
INSERT INTO stopwords VALUES ('MA');
42
INSERT INTO stopwords VALUES ('MAIS');
43
INSERT INTO stopwords VALUES ('MES');
44
INSERT INTO stopwords VALUES ('MON');
45
INSERT INTO stopwords VALUES ('NI');
46
INSERT INTO stopwords VALUES ('NOTRE');
47
INSERT INTO stopwords VALUES ('NOUS');
48
INSERT INTO stopwords VALUES ('OU');
49
INSERT INTO stopwords VALUES ('PAR');
50
INSERT INTO stopwords VALUES ('PAS');
51
INSERT INTO stopwords VALUES ('PEU');
52
INSERT INTO stopwords VALUES ('PEUT');
53
INSERT INTO stopwords VALUES ('POUR');
54
INSERT INTO stopwords VALUES ('QUE');
55
INSERT INTO stopwords VALUES ('QUI');
56
INSERT INTO stopwords VALUES ('SA');
57
INSERT INTO stopwords VALUES ('SES');
58
INSERT INTO stopwords VALUES ('SI');
59
INSERT INTO stopwords VALUES ('SIEN');
60
INSERT INTO stopwords VALUES ('SON');
61
INSERT INTO stopwords VALUES ('SOUS');
62
INSERT INTO stopwords VALUES ('SUR');
63
INSERT INTO stopwords VALUES ('TA');
64
INSERT INTO stopwords VALUES ('TELS');
65
INSERT INTO stopwords VALUES ('TES');
66
INSERT INTO stopwords VALUES ('TON');
67
INSERT INTO stopwords VALUES ('TU');
68
INSERT INTO stopwords VALUES ('VOTRE');
69
INSERT INTO stopwords VALUES ('VOUS');
70
INSERT INTO stopwords VALUES ('VU');
71
(-)a/installer/data/mysql/fr-FR/1-Obligatoire/stopwords.txt (-1 lines)
Line 1 Link Here
1
Mots vides de la langue française.
(-)a/installer/data/mysql/it-IT/necessari/stopwords.sql (-194 lines)
Lines 1-194 Link Here
1
SET FOREIGN_KEY_CHECKS=0;
2
3
INSERT INTO `stopwords` (`word`) VALUES
4
('a'),
5
('about'),
6
('ad'),
7
('after'),
8
('ai'),
9
('al'),
10
('all'),
11
('alla'),
12
('alle'),
13
('allo'),
14
('also'),
15
('an'),
16
('and'),
17
('another'),
18
('any'),
19
('are'),
20
('as'),
21
('at'),
22
('b'),
23
('back'),
24
('be'),
25
('because'),
26
('been'),
27
('being'),
28
('but'),
29
('by'),
30
('c'),
31
('can'),
32
('ci'),
33
('col'),
34
('con'),
35
('could'),
36
('d'),
37
('da'),
38
('dagli'),
39
('dai'),
40
('dal'),
41
('dall'),
42
('dalla'),
43
('dalle'),
44
('dallo'),
45
('de'),
46
('degli'),
47
('dei'),
48
('del'),
49
('dell'),
50
('della'),
51
('delle'),
52
('dello'),
53
('di'),
54
('did'),
55
('do'),
56
('e'),
57
('each'),
58
('ed'),
59
('end'),
60
('et'),
61
('even'),
62
('f'),
63
('for'),
64
('fra'),
65
('from'),
66
('g'),
67
('get'),
68
('gli'),
69
('go'),
70
('h'),
71
('had'),
72
('have'),
73
('he'),
74
('her'),
75
('here'),
76
('his'),
77
('how'),
78
('however'),
79
('i'),
80
('if'),
81
('il'),
82
('in'),
83
('into'),
84
('is'),
85
('it'),
86
('j'),
87
('just'),
88
('k'),
89
('l'),
90
('la'),
91
('le'),
92
('lo'),
93
('m'),
94
('may'),
95
('me'),
96
('mi'),
97
('might'),
98
('more'),
99
('much'),
100
('must'),
101
('my'),
102
('n'),
103
('ne'),
104
('negli'),
105
('nel'),
106
('nell'),
107
('nella'),
108
('nello'),
109
('no'),
110
('non'),
111
('not'),
112
('o'),
113
('of'),
114
('off'),
115
('on'),
116
('only'),
117
('oppure'),
118
('or'),
119
('other'),
120
('our'),
121
('out'),
122
('over'),
123
('p'),
124
('per'),
125
('q'),
126
('r'),
127
('s'),
128
('saw'),
129
('si'),
130
('since'),
131
('should'),
132
('so'),
133
('some'),
134
('still'),
135
('su'),
136
('such'),
137
('sugli'),
138
('sui'),
139
('sul'),
140
('sull'),
141
('sulla'),
142
('sulle'),
143
('t'),
144
('te'),
145
('than'),
146
('that'),
147
('the'),
148
('their'),
149
('them'),
150
('then'),
151
('there'),
152
('these'),
153
('they'),
154
('this'),
155
('those'),
156
('ti'),
157
('to'),
158
('too'),
159
('tra'),
160
('try'),
161
('two'),
162
('u'),
163
('un'),
164
('una'),
165
('under'),
166
('uno'),
167
('up'),
168
('upon'),
169
('us'),
170
('v'),
171
('vi'),
172
('was'),
173
('we'),
174
('were'),
175
('what'),
176
('when'),
177
('where'),
178
('whether'),
179
('which'),
180
('while'),
181
('who'),
182
('why'),
183
('will'),
184
('with'),
185
('within'),
186
('without'),
187
('would'),
188
('x'),
189
('y'),
190
('you'),
191
('your'),
192
('z');
193
194
SET FOREIGN_KEY_CHECKS=1;
(-)a/installer/data/mysql/it-IT/necessari/stopwords.txt (-1 lines)
Line 1 Link Here
1
Stopword. Possono essere modificate dopo l'installazione.
(-)a/installer/data/mysql/nb-NO/1-Obligatorisk/stopwords.sql (-26 lines)
Lines 1-26 Link Here
1
-- 
2
-- Default classification sources and filing rules
3
-- for Koha.
4
--
5
-- Copyright (C) 2011 Magnus Enger Libriotech
6
--
7
-- This file is part of Koha.
8
--
9
-- Koha is free software; you can redistribute it and/or modify it under the
10
-- terms of the GNU General Public License as published by the Free Software
11
-- Foundation; either version 2 of the License, or (at your option) any later
12
-- version.
13
-- 
14
-- Koha is distributed in the hope that it will be useful, but WITHOUT ANY
15
-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16
-- A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
17
-- 
18
-- You should have received a copy of the GNU General Public License along
19
-- with Koha; if not, write to the Free Software Foundation, Inc.,
20
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
22
INSERT INTO stopwords VALUES
23
('eller'),
24
('en'),
25
('og'), 
26
('som');
(-)a/installer/data/mysql/nb-NO/1-Obligatorisk/stopwords.txt (-1 lines)
Line 1 Link Here
1
Norske stoppord. Du kan endre disse etter at installasjonen er fullført. (NB! Vil ikke bli benyttet dersom du velger Zebra for indeksering.)
(-)a/installer/data/mysql/pl-PL/mandatory/stopwords.sql (-99 lines)
Lines 1-99 Link Here
1
INSERT INTO stopwords VALUES
2
('a'),
3
('about'),
4
('also'),
5
('an'),
6
('and'),
7
('another'),
8
('any'),
9
('are'),
10
('as'),
11
('at'),
12
('back'),
13
('be'),
14
('because'),
15
('been'),
16
('being'),
17
('but'),
18
('by'),
19
('can'),
20
('could'),
21
('did'),
22
('do'),
23
('each'),
24
('end'),
25
('even'),
26
('for'),
27
('from'),
28
('get'),
29
('go'),
30
('had'),
31
('have'),
32
('he'),
33
('her'),
34
('here'),
35
('his'),
36
('how'),
37
('i'),
38
('if'),
39
('in'),
40
('into'),
41
('is'),
42
('it'),
43
('just'),
44
('may'),
45
('me'),
46
('might'),
47
('much'),
48
('must'),
49
('my'),
50
('no'),
51
('not'),
52
('of'),
53
('off'),
54
('on'),
55
('only'),
56
('or'),
57
('other'),
58
('our'),
59
('out'),
60
('should'),
61
('so'),
62
('some'),
63
('still'),
64
('such'),
65
('than'),
66
('that'),
67
('the'),
68
('their'),
69
('them'),
70
('then'),
71
('there'),
72
('these'),
73
('they'),
74
('this'),
75
('those'),
76
('to'),
77
('too'),
78
('try'),
79
('two'),
80
('under'),
81
('up'),
82
('us'),
83
('was'),
84
('we'),
85
('were'),
86
('what'),
87
('when'),
88
('where'),
89
('which'),
90
('while'),
91
('who'),
92
('why'),
93
('will'),
94
('with'),
95
('within'),
96
('without'),
97
('would'),
98
('you'),
99
('your');
(-)a/installer/data/mysql/pl-PL/mandatory/stopwords.txt (-1 lines)
Line 1 Link Here
1
Angielskie stop words. Możesz je zmienić po intalacji.
(-)a/installer/data/mysql/ru-RU/mandatory/stopwords.sql (-21 lines)
Lines 1-21 Link Here
1
TRUNCATE stopwords;
2
3
INSERT INTO stopwords VALUES
4
( 'к'),
5
( 'и'),
6
( 'в'),
7
( 'на'),
8
( 'да'),
9
( 'то'),
10
( 'где'),
11
( 'еле'),
12
( 'это'),
13
( 'что'),
14
( 'ведь'),
15
( 'даже'),
16
( 'почти'),
17
( 'такой'),
18
( 'также'),
19
( 'значит'),
20
( 'немного'),
21
( 'который');
(-)a/installer/data/mysql/ru-RU/mandatory/stopwords.txt (-1 lines)
Line 1 Link Here
1
Несущественные для поиска русские слова. Вы можете корректировать их после установки.
(-)a/installer/data/mysql/uk-UA/mandatory/stopwords.sql (-29 lines)
Lines 1-29 Link Here
1
TRUNCATE stopwords;
2
3
INSERT INTO stopwords VALUES
4
('адже'),
5
('авжеж'),
6
('в'),
7
('де'),
8
('дещо'),
9
('до'),
10
('й'),
11
('ледве'),
12
('майже'),
13
('на'),
14
('навіть'),
15
('отже'),
16
('отож'),
17
('під'),
18
('так'),
19
('такий'),
20
('також'),
21
('те'),
22
('тобто'),
23
('тож'),
24
('тощо'),
25
('у'),
26
('це'),
27
('що'),
28
('як'),
29
('який');
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/prefs-admin-search.inc (-2 / +1 lines)
Lines 1-5 Link Here
1
<div class="gradient">
1
<div class="gradient">
2
<h1 id="logo"><a href="/cgi-bin/koha/mainpage.pl">[% LibraryName %]</a></h1><!-- Begin Stopwords Resident Search Box -->
2
<h1 id="logo"><a href="/cgi-bin/koha/mainpage.pl">[% LibraryName %]</a></h1>
3
<div id="header_search">
3
<div id="header_search">
4
	<div id="syspref_search" class="residentsearch">
4
	<div id="syspref_search" class="residentsearch">
5
	<p class="tip">System preference search:</p>
5
	<p class="tip">System preference search:</p>
Lines 27-30 Link Here
27
			</ul>
27
			</ul>
28
</div>
28
</div>
29
</div>
29
</div>
30
<!-- End Stopwords Resident Search Box -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/stopwords-admin-search.inc (-28 lines)
Lines 1-28 Link Here
1
<div class="gradient">
2
<h1 id="logo"><a href="/cgi-bin/koha/mainpage.pl">[% LibraryName %]</a></h1><!-- Begin Stopwords Resident Search Box -->
3
<div id="header_search">
4
	<div id="stopword_search" class="residentsearch">
5
	<p class="tip">Stop word search:</p>
6
	    <form action="[% script_name %]" method="post">
7
        <input class="head-searchbox" type="text" size="40" name="searchfield" value="[% searchfield %]" />
8
        <input type="submit" name="ok" class="submit" value="Search" />
9
    </form>
10
	</div>
11
    [% INCLUDE 'patron-search-box.inc' %]
12
	[% IF ( CAN_user_catalogue ) %]
13
    <div id="catalog_search" class="residentsearch">
14
	<p class="tip">Enter search keywords:</p>
15
		<form action="/cgi-bin/koha/catalogue/search.pl"  method="get" id="cat-search-block">
16
            <input type="text" name="q" id="search-form" size="40" value="" title="Enter the terms you wish to search for." class="head-searchbox form-text" />
17
				<input type="submit" value="Submit"  class="submit" />
18
		</form>
19
	</div>
20
	[% END %]
21
			<ul>
22
            <li><a onclick="keep_text(0)" href="#stopword_search">Search stop words</a></li>
23
            [% IF ( CAN_user_circulate ) %]<li><a onclick="keep_text(1)" href="#circ_search">Check out</a></li>[% END %]
24
            [% IF ( CAN_user_catalogue ) %]<li><a onclick="keep_text(2)" href="#catalog_search">Search the catalog</a></li>[% END %]
25
			</ul>	
26
</div>
27
</div><!-- /gradient -->
28
<!-- End Stopwords Resident Search Box -->
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/stopwords.tt (-146 lines)
Lines 1-146 Link Here
1
[% INCLUDE 'doc-head-open.inc' %]
2
<title>Koha &rsaquo; System administration &rsaquo; Stop words
3
[% IF ( add_form ) %]&rsaquo; [% IF ( searchfield ) %]Modify[% ELSE %]New[% END %] stop word
4
[% ELSIF ( add_validate ) %]&rsaquo; Data recorded
5
[% ELSIF ( delete_confirm ) %]&rsaquo; Delete stop word '[% searchfield %]' ?
6
[% ELSIF ( delete_confirmed ) %]&rsaquo; Data deleted
7
[% END %]
8
</title>
9
[% INCLUDE 'doc-head-close.inc' %]
10
<script type="text/javascript">
11
//<![CDATA[
12
    $(document).ready(function() {
13
        new YAHOO.widget.Button("newstopword");
14
    });
15
    function Check(f) {
16
        if (f.word.value.length==0) {
17
            alert(_("Form not submitted: word missing"));
18
        } else {
19
            document.Aform.submit();
20
        }
21
    }
22
//]]>
23
</script>
24
</head>
25
<body id="admin_stopwords" class="admin">
26
[% INCLUDE 'header.inc' %]
27
[% INCLUDE 'stopwords-admin-search.inc' %]
28
29
<div id="breadcrumbs">
30
<a href="/cgi-bin/koha/mainpage.pl">Home</a>
31
&rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
32
&rsaquo; <a href="/cgi-bin/koha/admin/stopwords.pl">Stop words</a>
33
[% IF ( add_form ) %]
34
    &rsaquo; [% IF ( searchfield ) %]Modify[% ELSE %]New[% END %] Stop word
35
[% ELSIF ( add_validate ) %]
36
    &rsaquo; Data recorded
37
[% ELSIF ( delete_confirm ) %]
38
    &rsaquo; Delete stop word '[% searchfield %]' ?
39
[% ELSIF ( delete_confirmed ) %]
40
    &rsaquo; Data deleted
41
[% END %]
42
</div>
43
44
<div id="doc3" class="yui-t2">
45
   
46
   <div id="bd">
47
	<div id="yui-main">
48
	<div class="yui-b">
49
50
[% IF ( add_form ) %]
51
        [% IF ( searchfield ) %]
52
            <h1>Modify word</h1>
53
        [% ELSE %]
54
            <h1>New word</h1>
55
        [% END %]
56
        <form action="[% script_name %]" name="Aform" method="post">
57
            <input type="hidden" name="op" value="add_validate" />
58
            <fieldset class="rows">
59
            <ol><li>
60
            [% IF ( searchfield ) %]
61
                <span class="label">Word</span>
62
                    <input type="hidden" name="word" value="[% searchfield %]" />[% searchfield %]
63
            [% ELSE %]
64
                <label for="word">Word</label>
65
                <input type="text" name="word" id="word" size="50" maxlength="250" onblur="toUC(this)" />
66
            [% END %]
67
                </li>
68
            </ol>
69
            </fieldset>
70
            <fieldset class="action">
71
                <input type="button" value="Save" onclick="Check(this.form)" />
72
                <a class="cancel" href="/cgi-bin/koha/admin/stopwords.pl">Cancel</a>
73
            </fieldset>
74
        </form>
75
[% END %]
76
77
[% IF ( add_validate ) %]
78
   <div class="dialog message"> <h3>Data recorded</h3>
79
    <form action="[% script_name %]" method="post">
80
        <input type="submit" value="OK" class="approve" />
81
    </form></div>
82
[% END %]
83
84
[% IF ( delete_confirm ) %]
85
    <div class="dialog alert">
86
    <h3>Delete stop word <span class="ex">'[% searchfield %]'</span></h3>
87
	<form action="[% script_name %]" method="post">
88
        <input type="hidden" name="op" value="delete_confirmed" />
89
        <input type="hidden" name="searchfield" value="[% searchfield %]" />
90
        <input type="submit" value="Yes, delete" class="approve" />
91
    </form>
92
    <form action="[% script_name %]" method="get">
93
        <input type="submit" class="deny" value="No, do not delete" />
94
    </form></div>
95
[% END %]
96
97
[% IF ( delete_confirmed ) %]
98
   <div class="dialog message"> <h3>Data deleted</h3>
99
    <form action="[% script_name %]" method="post">
100
        <input type="submit" value="OK" class="approve" />
101
    </form></div>
102
[% END %]
103
104
[% IF ( else ) %]
105
106
<div id="toolbar">
107
	<ul class="toolbar">
108
    <li><a id="newstopword" href="/cgi-bin/koha/admin/stopwords.pl?op=add_form">New stop word</a></li>
109
</ul></div>
110
111
    <h1>Stop words</h1>
112
    <p class="message">NOTE : if you change something in this table, ask your administrator to run misc/batchRebuildBiblioTables.pl script.</p>
113
114
    [% IF ( searchfield ) %]
115
        <p>You searched for <b>[% searchfield %]</b></p>
116
    [% END %]
117
118
    <table>
119
        <tr><th>Word</th>
120
            <th></th>
121
        </tr>
122
        [% FOREACH loo IN loop %]
123
            <tr>
124
            <td>[% loo.word %]</td>
125
            <td><a href="[% loo.script_name %]?op=delete_confirm&amp;searchfield=[% loo.word %]">Delete</a></td>
126
        </tr>
127
        [% END %]
128
    </table>
129
130
    <div class="pages">
131
        [% IF ( offsetgtzero ) %]
132
            <a href="[% script_name %]?offset=[% prevpage %]">&lt;&lt; Previous</a>
133
        [% END %]
134
        [% IF ( ltcount ) %]
135
            <a href="[% script_name %]?offset=[% nextpage %]">Next &gt;&gt;</a>
136
        [% END %]
137
    </div>
138
[% END %]
139
140
</div>
141
</div>
142
<div class="yui-b">
143
[% INCLUDE 'admin-menu.inc' %]
144
</div>
145
</div>
146
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt (-1 lines)
Lines 368-374 var holdForPatron = function () { Link Here
368
                [% IF ( CAN_user_editcatalogue_edit_catalogue ) %] <div class="btn-group"><a class="btn btn-mini" id="z3950submit" href="#"><i class="fa fa-search"></i> Z39.50/SRU search</a></div>[% END %]
368
                [% IF ( CAN_user_editcatalogue_edit_catalogue ) %] <div class="btn-group"><a class="btn btn-mini" id="z3950submit" href="#"><i class="fa fa-search"></i> Z39.50/SRU search</a></div>[% END %]
369
            </div>
369
            </div>
370
        </div>
370
        </div>
371
    [% IF ( stopwords_removed ) %]<div><p class="tip">Ignored the following common words: "[% stopwords_removed %]"<p></div>[% END %]
372
    [% ELSE %]
371
    [% ELSE %]
373
        <div id="searchheader">
372
        <div id="searchheader">
374
			<form method="post" name="fz3950" class="fz3950bigrpad">
373
			<form method="post" name="fz3950" class="fz3950bigrpad">
(-)a/misc/batchRebuildBiblioTables.pl (-1 / +1 lines)
Lines 53-59 $starttime = gettimeofday; Link Here
53
53
54
#1st of all, find item MARC tag.
54
#1st of all, find item MARC tag.
55
my ($tagfield,$tagsubfield) = &GetMarcFromKohaField("items.itemnumber",'');
55
my ($tagfield,$tagsubfield) = &GetMarcFromKohaField("items.itemnumber",'');
56
# $dbh->do("lock tables biblio write, biblioitems write, items write, marc_biblio write, marc_subfield_table write, marc_blob_subfield write, marc_word write, marc_subfield_structure write, stopwords write");
56
# $dbh->do("lock tables biblio write, biblioitems write, items write, marc_biblio write, marc_subfield_table write, marc_blob_subfield write, marc_word write, marc_subfield_structure write");
57
my $sth = $dbh->prepare("SELECT biblionumber FROM biblio");
57
my $sth = $dbh->prepare("SELECT biblionumber FROM biblio");
58
$sth->execute;
58
$sth->execute;
59
# my ($biblionumbermax) =  $sth->fetchrow;
59
# my ($biblionumbermax) =  $sth->fetchrow;
(-)a/opac/opac-search.pl (-3 / +2 lines)
Lines 517-528 my $hits; Link Here
517
my $expanded_facet = $params->{'expand'};
517
my $expanded_facet = $params->{'expand'};
518
518
519
# Define some global variables
519
# Define some global variables
520
my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type);
520
my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
521
521
522
my @results;
522
my @results;
523
523
524
## I. BUILD THE QUERY
524
## I. BUILD THE QUERY
525
( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = buildQuery(\@operators,\@operands,\@indexes,\@limits,\@sort_by, 0, $lang);
525
( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type) = buildQuery(\@operators,\@operands,\@indexes,\@limits,\@sort_by, 0, $lang);
526
526
527
sub _input_cgi_parse {
527
sub _input_cgi_parse {
528
    my @elements;
528
    my @elements;
Lines 777-783 for (my $i=0;$i<@servers;$i++) { Link Here
777
            if ($query_desc || $limit_desc) {
777
            if ($query_desc || $limit_desc) {
778
                $template->param(searchdesc => 1);
778
                $template->param(searchdesc => 1);
779
            }
779
            }
780
            $template->param(stopwords_removed => "@$stopwords_removed") if $stopwords_removed;
781
            $template->param(results_per_page =>  $results_per_page);
780
            $template->param(results_per_page =>  $results_per_page);
782
            my $hide = C4::Context->preference('OpacHiddenItems');
781
            my $hide = C4::Context->preference('OpacHiddenItems');
783
            $hide = ($hide =~ m/\S/) if $hide; # Just in case it has some spaces/new lines
782
            $hide = ($hide =~ m/\S/) if $hide; # Just in case it has some spaces/new lines
(-)a/t/db_dependent/Search.t (-57 / +40 lines)
Lines 92-98 our $QueryStemming = 0; Link Here
92
our $QueryAutoTruncate = 0;
92
our $QueryAutoTruncate = 0;
93
our $QueryWeightFields = 0;
93
our $QueryWeightFields = 0;
94
our $QueryFuzzy = 0;
94
our $QueryFuzzy = 0;
95
our $QueryRemoveStopwords = 0;
96
our $UseQueryParser = 0;
95
our $UseQueryParser = 0;
97
our $marcflavour = 'MARC21';
96
our $marcflavour = 'MARC21';
98
our $contextmodule = new Test::MockModule('C4::Context');
97
our $contextmodule = new Test::MockModule('C4::Context');
Lines 108-115 $contextmodule->mock('preference', sub { Link Here
108
        return $QueryWeightFields;
107
        return $QueryWeightFields;
109
    } elsif ($pref eq 'QueryFuzzy') {
108
    } elsif ($pref eq 'QueryFuzzy') {
110
        return $QueryFuzzy;
109
        return $QueryFuzzy;
111
    } elsif ($pref eq 'QueryRemoveStopwords') {
112
        return $QueryRemoveStopwords;
113
    } elsif ($pref eq 'UseQueryParser') {
110
    } elsif ($pref eq 'UseQueryParser') {
114
        return $UseQueryParser;
111
        return $UseQueryParser;
115
    } elsif ($pref eq 'maxRecordsForFacets') {
112
    } elsif ($pref eq 'maxRecordsForFacets') {
Lines 212-233 sub run_marc21_search_tests { Link Here
212
    $QueryAutoTruncate = 0;
209
    $QueryAutoTruncate = 0;
213
    $QueryWeightFields = 0;
210
    $QueryWeightFields = 0;
214
    $QueryFuzzy = 0;
211
    $QueryFuzzy = 0;
215
    $QueryRemoveStopwords = 0;
216
    $UseQueryParser = 0;
212
    $UseQueryParser = 0;
217
    $marcflavour = 'MARC21';
213
    $marcflavour = 'MARC21';
218
214
219
    foreach my $string ("Leçon","modèles") {
220
        my @results=C4::Search::_remove_stopwords($string,"kw");
221
        $debug && warn "$string ",Dump(@results);
222
        ok($results[0] eq $string,"$string is not modified");
223
    }
224
225
    foreach my $string ("A book about the stars") {
226
        my @results=C4::Search::_remove_stopwords($string,"kw");
227
        $debug && warn "$string ",Dump(@results);
228
        ok($results[0] ne $string,"$results[0] from $string");
229
    }
230
231
    my $indexes = C4::Search::getIndexes();
215
    my $indexes = C4::Search::getIndexes();
232
    is(scalar(grep(/^ti$/, @$indexes)), 1, "Title index supported");
216
    is(scalar(grep(/^ti$/, @$indexes)), 1, "Title index supported");
233
217
Lines 434-443 if ( $indexing_mode eq 'dom' ) { Link Here
434
418
435
    my ( $query, $simple_query, $query_cgi,
419
    my ( $query, $simple_query, $query_cgi,
436
    $query_desc, $limit, $limit_cgi, $limit_desc,
420
    $query_desc, $limit, $limit_cgi, $limit_desc,
437
    $stopwords_removed, $query_type );
421
    $query_type );
438
    ( $error, $query, $simple_query, $query_cgi,
422
    ( $error, $query, $simple_query, $query_cgi,
439
    $query_desc, $limit, $limit_cgi, $limit_desc,
423
    $query_desc, $limit, $limit_cgi, $limit_desc,
440
    $stopwords_removed, $query_type ) = buildQuery([], [ 'salud' ], [], [], [], 0, 'en');
424
    $query_type ) = buildQuery([], [ 'salud' ], [], [], [], 0, 'en');
441
    like($query, qr/kw\W.*salud/, "Built CCL keyword query");
425
    like($query, qr/kw\W.*salud/, "Built CCL keyword query");
442
426
443
    ($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);
Lines 449-455 if ( $indexing_mode eq 'dom' ) { Link Here
449
433
450
    ( $error, $query, $simple_query, $query_cgi,
434
    ( $error, $query, $simple_query, $query_cgi,
451
    $query_desc, $limit, $limit_cgi, $limit_desc,
435
    $query_desc, $limit, $limit_cgi, $limit_desc,
452
    $stopwords_removed, $query_type ) = buildQuery([ 'and' ], [ 'salud', 'higiene' ], [], [], [], 0, 'en');
436
    $query_type ) = buildQuery([ 'and' ], [ 'salud', 'higiene' ], [], [], [], 0, 'en');
453
    like($query, qr/kw\W.*salud\W.*and.*kw\W.*higiene/, "Built composed explicit-and CCL keyword query");
437
    like($query, qr/kw\W.*salud\W.*and.*kw\W.*higiene/, "Built composed explicit-and CCL keyword query");
454
438
455
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
439
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
Lines 457-463 if ( $indexing_mode eq 'dom' ) { Link Here
457
441
458
    ( $error, $query, $simple_query, $query_cgi,
442
    ( $error, $query, $simple_query, $query_cgi,
459
    $query_desc, $limit, $limit_cgi, $limit_desc,
443
    $query_desc, $limit, $limit_cgi, $limit_desc,
460
    $stopwords_removed, $query_type ) = buildQuery([ 'or' ], [ 'salud', 'higiene' ], [], [], [], 0, 'en');
444
    $query_type ) = buildQuery([ 'or' ], [ 'salud', 'higiene' ], [], [], [], 0, 'en');
461
    like($query, qr/kw\W.*salud\W.*or.*kw\W.*higiene/, "Built composed explicit-or CCL keyword query");
445
    like($query, qr/kw\W.*salud\W.*or.*kw\W.*higiene/, "Built composed explicit-or CCL keyword query");
462
446
463
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
447
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
Lines 465-471 if ( $indexing_mode eq 'dom' ) { Link Here
465
449
466
    ( $error, $query, $simple_query, $query_cgi,
450
    ( $error, $query, $simple_query, $query_cgi,
467
    $query_desc, $limit, $limit_cgi, $limit_desc,
451
    $query_desc, $limit, $limit_cgi, $limit_desc,
468
    $stopwords_removed, $query_type ) = buildQuery([], [ 'salud', 'higiene' ], [], [], [], 0, 'en');
452
    $query_type ) = buildQuery([], [ 'salud', 'higiene' ], [], [], [], 0, 'en');
469
    like($query, qr/kw\W.*salud\W.*and.*kw\W.*higiene/, "Built composed implicit-and CCL keyword query");
453
    like($query, qr/kw\W.*salud\W.*and.*kw\W.*higiene/, "Built composed implicit-and CCL keyword query");
470
454
471
    ($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);
Lines 473-479 if ( $indexing_mode eq 'dom' ) { Link Here
473
457
474
    ( $error, $query, $simple_query, $query_cgi,
458
    ( $error, $query, $simple_query, $query_cgi,
475
    $query_desc, $limit, $limit_cgi, $limit_desc,
459
    $query_desc, $limit, $limit_cgi, $limit_desc,
476
    $stopwords_removed, $query_type ) = buildQuery([], [ 'salud' ], [ 'kw' ], [ 'su-to:Laboratorios' ], [], 0, 'en');
460
    $query_type ) = buildQuery([], [ 'salud' ], [ 'kw' ], [ 'su-to:Laboratorios' ], [], 0, 'en');
477
    like($query, qr/kw\W.*salud\W*and\W*su-to\W.*Laboratorios/, "Faceted query generated correctly");
461
    like($query, qr/kw\W.*salud\W*and\W*su-to\W.*Laboratorios/, "Faceted query generated correctly");
478
    unlike($query_desc, qr/Laboratorios/, "Facets not included in query description");
462
    unlike($query_desc, qr/Laboratorios/, "Facets not included in query description");
479
463
Lines 483-489 if ( $indexing_mode eq 'dom' ) { Link Here
483
467
484
    ( $error, $query, $simple_query, $query_cgi,
468
    ( $error, $query, $simple_query, $query_cgi,
485
    $query_desc, $limit, $limit_cgi, $limit_desc,
469
    $query_desc, $limit, $limit_cgi, $limit_desc,
486
    $stopwords_removed, $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'mc-itype:MP', 'mc-itype:MU' ], [], 0, 'en');
470
    $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'mc-itype:MP', 'mc-itype:MU' ], [], 0, 'en');
487
471
488
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
472
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
489
    is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated mc-faceted search matched right number of records");
473
    is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated mc-faceted search matched right number of records");
Lines 491-504 if ( $indexing_mode eq 'dom' ) { Link Here
491
475
492
    ( $error, $query, $simple_query, $query_cgi,
476
    ( $error, $query, $simple_query, $query_cgi,
493
    $query_desc, $limit, $limit_cgi, $limit_desc,
477
    $query_desc, $limit, $limit_cgi, $limit_desc,
494
    $stopwords_removed, $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'mc-loc:GEN', 'branch:FFL' ], [], 0, 'en');
478
    $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'mc-loc:GEN', 'branch:FFL' ], [], 0, 'en');
495
479
496
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
480
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
497
    is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated multi-faceted search matched right number of records");
481
    is($results_hashref->{biblioserver}->{hits}, 2, "getRecords generated multi-faceted search matched right number of records");
498
482
499
    ( $error, $query, $simple_query, $query_cgi,
483
    ( $error, $query, $simple_query, $query_cgi,
500
    $query_desc, $limit, $limit_cgi, $limit_desc,
484
    $query_desc, $limit, $limit_cgi, $limit_desc,
501
    $stopwords_removed, $query_type ) = buildQuery([], [ 'NEKLS' ], [ 'Code-institution' ], [], [], 0, 'en');
485
    $query_type ) = buildQuery([], [ 'NEKLS' ], [ 'Code-institution' ], [], [], 0, 'en');
502
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
486
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
503
    is($results_hashref->{biblioserver}->{hits}, 12,
487
    is($results_hashref->{biblioserver}->{hits}, 12,
504
       'search using index whose name contains "ns" returns expected results (bug 10271)');
488
       'search using index whose name contains "ns" returns expected results (bug 10271)');
Lines 506-517 if ( $indexing_mode eq 'dom' ) { Link Here
506
    $UseQueryParser = 1;
490
    $UseQueryParser = 1;
507
    ( $error, $query, $simple_query, $query_cgi,
491
    ( $error, $query, $simple_query, $query_cgi,
508
    $query_desc, $limit, $limit_cgi, $limit_desc,
492
    $query_desc, $limit, $limit_cgi, $limit_desc,
509
    $stopwords_removed, $query_type ) = buildQuery([], [ 'book' ], [ 'kw' ], [], [], 0, 'en');
493
    $query_type ) = buildQuery([], [ 'book' ], [ 'kw' ], [], [], 0, 'en');
510
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
494
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
511
    is($results_hashref->{biblioserver}->{hits}, 101, "Search for 'book' with index set to 'kw' returns 101 hits");
495
    is($results_hashref->{biblioserver}->{hits}, 101, "Search for 'book' with index set to 'kw' returns 101 hits");
512
    ( $error, $query, $simple_query, $query_cgi,
496
    ( $error, $query, $simple_query, $query_cgi,
513
    $query_desc, $limit, $limit_cgi, $limit_desc,
497
    $query_desc, $limit, $limit_cgi, $limit_desc,
514
    $stopwords_removed, $query_type ) = buildQuery([ 'and' ], [ 'book', 'another' ], [ 'kw', 'kw' ], [], [], 0, 'en');
498
    $query_type ) = buildQuery([ 'and' ], [ 'book', 'another' ], [ 'kw', 'kw' ], [], [], 0, 'en');
515
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
499
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
516
    is($results_hashref->{biblioserver}->{hits}, 1, "Search for 'kw:book && kw:another' returns 1 hit");
500
    is($results_hashref->{biblioserver}->{hits}, 1, "Search for 'kw:book && kw:another' returns 1 hit");
517
    $UseQueryParser = 0;
501
    $UseQueryParser = 0;
Lines 520-526 if ( $indexing_mode eq 'dom' ) { Link Here
520
    # are just checking that it behaves consistently
504
    # are just checking that it behaves consistently
521
    ( $error, $query, $simple_query, $query_cgi,
505
    ( $error, $query, $simple_query, $query_cgi,
522
    $query_desc, $limit, $limit_cgi, $limit_desc,
506
    $query_desc, $limit, $limit_cgi, $limit_desc,
523
    $stopwords_removed, $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'available' ], [], 0, 'en');
507
    $query_type ) = buildQuery([], [ '' ], [ 'kw' ], [ 'available' ], [], 0, 'en');
524
508
525
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
509
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
526
    is($results_hashref->{biblioserver}->{hits}, 26, "getRecords generated availability-limited search matched right number of records");
510
    is($results_hashref->{biblioserver}->{hits}, 26, "getRecords generated availability-limited search matched right number of records");
Lines 536-572 if ( $indexing_mode eq 'dom' ) { Link Here
536
520
537
    ( $error, $query, $simple_query, $query_cgi,
521
    ( $error, $query, $simple_query, $query_cgi,
538
    $query_desc, $limit, $limit_cgi, $limit_desc,
522
    $query_desc, $limit, $limit_cgi, $limit_desc,
539
    $stopwords_removed, $query_type ) = buildQuery([], [ 'pqf=@attr 1=_ALLRECORDS @attr 2=103 ""' ], [], [], [], 0, 'en');
523
    $query_type ) = buildQuery([], [ 'pqf=@attr 1=_ALLRECORDS @attr 2=103 ""' ], [], [], [], 0, 'en');
540
524
541
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
525
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
542
    is($results_hashref->{biblioserver}->{hits}, 180, "getRecords on _ALLRECORDS PQF returned all records");
526
    is($results_hashref->{biblioserver}->{hits}, 180, "getRecords on _ALLRECORDS PQF returned all records");
543
527
544
    ( $error, $query, $simple_query, $query_cgi,
528
    ( $error, $query, $simple_query, $query_cgi,
545
    $query_desc, $limit, $limit_cgi, $limit_desc,
529
    $query_desc, $limit, $limit_cgi, $limit_desc,
546
    $stopwords_removed, $query_type ) = buildQuery([], [ 'pqf=@attr 1=1016 "Lessig"' ], [], [], [], 0, 'en');
530
    $query_type ) = buildQuery([], [ 'pqf=@attr 1=1016 "Lessig"' ], [], [], [], 0, 'en');
547
531
548
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
532
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
549
    is($results_hashref->{biblioserver}->{hits}, 4, "getRecords PQF author search for Lessig returned proper number of matches");
533
    is($results_hashref->{biblioserver}->{hits}, 4, "getRecords PQF author search for Lessig returned proper number of matches");
550
534
551
    ( $error, $query, $simple_query, $query_cgi,
535
    ( $error, $query, $simple_query, $query_cgi,
552
    $query_desc, $limit, $limit_cgi, $limit_desc,
536
    $query_desc, $limit, $limit_cgi, $limit_desc,
553
    $stopwords_removed, $query_type ) = buildQuery([], [ 'ccl=au:Lessig' ], [], [], [], 0, 'en');
537
    $query_type ) = buildQuery([], [ 'ccl=au:Lessig' ], [], [], [], 0, 'en');
554
538
555
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
539
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
556
    is($results_hashref->{biblioserver}->{hits}, 4, "getRecords CCL author search for Lessig returned proper number of matches");
540
    is($results_hashref->{biblioserver}->{hits}, 4, "getRecords CCL author search for Lessig returned proper number of matches");
557
541
558
    ( $error, $query, $simple_query, $query_cgi,
542
    ( $error, $query, $simple_query, $query_cgi,
559
    $query_desc, $limit, $limit_cgi, $limit_desc,
543
    $query_desc, $limit, $limit_cgi, $limit_desc,
560
    $stopwords_removed, $query_type ) = buildQuery([], [ 'cql=dc.author any lessig' ], [], [], [], 0, 'en');
544
    $query_type ) = buildQuery([], [ 'cql=dc.author any lessig' ], [], [], [], 0, 'en');
561
545
562
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
546
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
563
    is($results_hashref->{biblioserver}->{hits}, 4, "getRecords CQL author search for Lessig returned proper number of matches");
547
    is($results_hashref->{biblioserver}->{hits}, 4, "getRecords CQL author search for Lessig returned proper number of matches");
564
548
565
    $QueryStemming = $QueryAutoTruncate = $QueryFuzzy = $QueryRemoveStopwords = 0;
549
    $QueryStemming = $QueryAutoTruncate = $QueryFuzzy = 0;
566
    $QueryWeightFields = 1;
550
    $QueryWeightFields = 1;
567
    ( $error, $query, $simple_query, $query_cgi,
551
    ( $error, $query, $simple_query, $query_cgi,
568
    $query_desc, $limit, $limit_cgi, $limit_desc,
552
    $query_desc, $limit, $limit_cgi, $limit_desc,
569
    $stopwords_removed, $query_type ) = buildQuery([], [ 'salud' ], [ 'kw' ], [], [], 0, 'en');
553
    $query_type ) = buildQuery([], [ 'salud' ], [ 'kw' ], [], [], 0, 'en');
570
554
571
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
555
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
572
    is($results_hashref->{biblioserver}->{hits}, 19, "Weighted query returned correct number of results");
556
    is($results_hashref->{biblioserver}->{hits}, 19, "Weighted query returned correct number of results");
Lines 577-640 if ( $indexing_mode eq 'dom' ) { Link Here
577
        is(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first");
561
        is(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first");
578
    }
562
    }
579
563
580
    $QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryRemoveStopwords = 0;
564
    $QueryStemming = $QueryWeightFields = $QueryFuzzy = 0;
581
    $QueryAutoTruncate = 1;
565
    $QueryAutoTruncate = 1;
582
    ( $error, $query, $simple_query, $query_cgi,
566
    ( $error, $query, $simple_query, $query_cgi,
583
    $query_desc, $limit, $limit_cgi, $limit_desc,
567
    $query_desc, $limit, $limit_cgi, $limit_desc,
584
    $stopwords_removed, $query_type ) = buildQuery([], [ 'medic' ], [ 'kw' ], [], [], 0, 'en');
568
    $query_type ) = buildQuery([], [ 'medic' ], [ 'kw' ], [], [], 0, 'en');
585
569
586
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
570
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
587
    is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic' returns matches  with automatic truncation on");
571
    is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic' returns matches  with automatic truncation on");
588
572
589
    ( $error, $query, $simple_query, $query_cgi,
573
    ( $error, $query, $simple_query, $query_cgi,
590
    $query_desc, $limit, $limit_cgi, $limit_desc,
574
    $query_desc, $limit, $limit_cgi, $limit_desc,
591
    $stopwords_removed, $query_type ) = buildQuery([], [ 'medic*' ], [ 'kw' ], [], [], 0, 'en');
575
    $query_type ) = buildQuery([], [ 'medic*' ], [ 'kw' ], [], [], 0, 'en');
592
576
593
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
577
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
594
    is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic*' returns matches with automatic truncation on");
578
    is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic*' returns matches with automatic truncation on");
595
579
596
    $QueryStemming = $QueryFuzzy = $QueryRemoveStopwords = $QueryAutoTruncate = 0;
580
    $QueryStemming = $QueryFuzzy = $QueryAutoTruncate = 0;
597
    $QueryWeightFields = 1;
581
    $QueryWeightFields = 1;
598
    ( $error, $query, $simple_query, $query_cgi,
582
    ( $error, $query, $simple_query, $query_cgi,
599
    $query_desc, $limit, $limit_cgi, $limit_desc,
583
    $query_desc, $limit, $limit_cgi, $limit_desc,
600
    $stopwords_removed, $query_type ) = buildQuery([], [ 'web application' ], [ 'kw' ], [], [], 0, 'en');
584
    $query_type ) = buildQuery([], [ 'web application' ], [ 'kw' ], [], [], 0, 'en');
601
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
585
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
602
    is($results_hashref->{biblioserver}->{hits}, 1, "Search for 'web application' returns one hit with QueryWeightFields on");
586
    is($results_hashref->{biblioserver}->{hits}, 1, "Search for 'web application' returns one hit with QueryWeightFields on");
603
587
604
    ( $error, $query, $simple_query, $query_cgi,
588
    ( $error, $query, $simple_query, $query_cgi,
605
    $query_desc, $limit, $limit_cgi, $limit_desc,
589
    $query_desc, $limit, $limit_cgi, $limit_desc,
606
    $stopwords_removed, $query_type ) = buildQuery([], [ 'web "application' ], [ 'kw' ], [], [], 0, 'en');
590
    $query_type ) = buildQuery([], [ 'web "application' ], [ 'kw' ], [], [], 0, 'en');
607
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
591
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
608
    is($results_hashref->{biblioserver}->{hits}, 1, "Search for 'web \"application' returns one hit with QueryWeightFields on (bug 7518)");
592
    is($results_hashref->{biblioserver}->{hits}, 1, "Search for 'web \"application' returns one hit with QueryWeightFields on (bug 7518)");
609
593
610
    $QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryRemoveStopwords = $QueryAutoTruncate = 0;
594
    $QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryAutoTruncate = 0;
611
    ( $error, $query, $simple_query, $query_cgi,
595
    ( $error, $query, $simple_query, $query_cgi,
612
    $query_desc, $limit, $limit_cgi, $limit_desc,
596
    $query_desc, $limit, $limit_cgi, $limit_desc,
613
    $stopwords_removed, $query_type ) = buildQuery([], [ 'medic' ], [ 'kw' ], [], [], 0, 'en');
597
    $query_type ) = buildQuery([], [ 'medic' ], [ 'kw' ], [], [], 0, 'en');
614
598
615
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
599
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
616
    is($results_hashref->{biblioserver}->{hits}, undef, "Search for 'medic' returns no matches with automatic truncation off");
600
    is($results_hashref->{biblioserver}->{hits}, undef, "Search for 'medic' returns no matches with automatic truncation off");
617
601
618
    ( $error, $query, $simple_query, $query_cgi,
602
    ( $error, $query, $simple_query, $query_cgi,
619
    $query_desc, $limit, $limit_cgi, $limit_desc,
603
    $query_desc, $limit, $limit_cgi, $limit_desc,
620
    $stopwords_removed, $query_type ) = buildQuery([], [ 'medic*' ], [ 'kw' ], [], [], 0, 'en');
604
    $query_type ) = buildQuery([], [ 'medic*' ], [ 'kw' ], [], [], 0, 'en');
621
605
622
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
606
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
623
    is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic*' returns matches with automatic truncation off");
607
    is($results_hashref->{biblioserver}->{hits}, 5, "Search for 'medic*' returns matches with automatic truncation off");
624
608
625
    $QueryStemming = $QueryWeightFields = 1;
609
    $QueryStemming = $QueryWeightFields = 1;
626
    $QueryFuzzy = $QueryRemoveStopwords = $QueryAutoTruncate = 0;
610
    $QueryFuzzy = $QueryAutoTruncate = 0;
627
    ( $error, $query, $simple_query, $query_cgi,
611
    ( $error, $query, $simple_query, $query_cgi,
628
    $query_desc, $limit, $limit_cgi, $limit_desc,
612
    $query_desc, $limit, $limit_cgi, $limit_desc,
629
    $stopwords_removed, $query_type ) = buildQuery([], [ 'pressed' ], [ 'kw' ], [], [], 0, 'en');
613
    $query_type ) = buildQuery([], [ 'pressed' ], [ 'kw' ], [], [], 0, 'en');
630
614
631
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
615
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
632
    is($results_hashref->{biblioserver}->{hits}, 7, "Search for 'pressed' returns matches when stemming (and query weighting) is on");
616
    is($results_hashref->{biblioserver}->{hits}, 7, "Search for 'pressed' returns matches when stemming (and query weighting) is on");
633
617
634
    $QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryRemoveStopwords = $QueryAutoTruncate = 0;
618
    $QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryAutoTruncate = 0;
635
    ( $error, $query, $simple_query, $query_cgi,
619
    ( $error, $query, $simple_query, $query_cgi,
636
    $query_desc, $limit, $limit_cgi, $limit_desc,
620
    $query_desc, $limit, $limit_cgi, $limit_desc,
637
    $stopwords_removed, $query_type ) = buildQuery([], [ 'pressed' ], [ 'kw' ], [], [], 0, 'en');
621
    $query_type ) = buildQuery([], [ 'pressed' ], [ 'kw' ], [], [], 0, 'en');
638
622
639
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
623
    ($error, $results_hashref, $facets_loop) = getRecords($query,$simple_query,[ ], [ 'biblioserver' ],20,0,undef,\%branches,\%itemtypes,$query_type,0);
640
    is($results_hashref->{biblioserver}->{hits}, undef, "Search for 'pressed' returns no matches when stemming is off");
624
    is($results_hashref->{biblioserver}->{hits}, undef, "Search for 'pressed' returns no matches when stemming is off");
Lines 718-766 if ( $indexing_mode eq 'dom' ) { Link Here
718
    $term = 'Arizona';
702
    $term = 'Arizona';
719
    ( $error, $query, $simple_query, $query_cgi,
703
    ( $error, $query, $simple_query, $query_cgi,
720
    $query_desc, $limit, $limit_cgi, $limit_desc,
704
    $query_desc, $limit, $limit_cgi, $limit_desc,
721
    $stopwords_removed, $query_type ) = buildQuery([], [ $term ], [ 'su-br' ], [  ], [], 0, 'en');
705
    $query_type ) = buildQuery([], [ $term ], [ 'su-br' ], [  ], [], 0, 'en');
722
    matchesExplodedTerms("Advanced search for broader subjects", $query, 'Arizona', 'United States');
706
    matchesExplodedTerms("Advanced search for broader subjects", $query, 'Arizona', 'United States');
723
707
724
    ( $error, $query, $simple_query, $query_cgi,
708
    ( $error, $query, $simple_query, $query_cgi,
725
    $query_desc, $limit, $limit_cgi, $limit_desc,
709
    $query_desc, $limit, $limit_cgi, $limit_desc,
726
    $stopwords_removed, $query_type ) = buildQuery([], [ $term ], [ 'su-na' ], [  ], [], 0, 'en');
710
    $query_type ) = buildQuery([], [ $term ], [ 'su-na' ], [  ], [], 0, 'en');
727
    matchesExplodedTerms("Advanced search for narrower subjects", $query, 'Arizona', 'Maricopa County', 'Navajo County', 'Pima County');
711
    matchesExplodedTerms("Advanced search for narrower subjects", $query, 'Arizona', 'Maricopa County', 'Navajo County', 'Pima County');
728
712
729
    ( $error, $query, $simple_query, $query_cgi,
713
    ( $error, $query, $simple_query, $query_cgi,
730
    $query_desc, $limit, $limit_cgi, $limit_desc,
714
    $query_desc, $limit, $limit_cgi, $limit_desc,
731
    $stopwords_removed, $query_type ) = buildQuery([], [ $term ], [ 'su-rl' ], [  ], [], 0, 'en');
715
    $query_type ) = buildQuery([], [ $term ], [ 'su-rl' ], [  ], [], 0, 'en');
732
    matchesExplodedTerms("Advanced search for related subjects", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County');
716
    matchesExplodedTerms("Advanced search for related subjects", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County');
733
717
734
    ( $error, $query, $simple_query, $query_cgi,
718
    ( $error, $query, $simple_query, $query_cgi,
735
    $query_desc, $limit, $limit_cgi, $limit_desc,
719
    $query_desc, $limit, $limit_cgi, $limit_desc,
736
    $stopwords_removed, $query_type ) = buildQuery([], [ "$term", 'history' ], [ 'su-rl', 'kw' ], [  ], [], 0, 'en');
720
    $query_type ) = buildQuery([], [ "$term", 'history' ], [ 'su-rl', 'kw' ], [  ], [], 0, 'en');
737
    matchesExplodedTerms("Advanced search for related subjects and keyword 'history' searches related subjects", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County');
721
    matchesExplodedTerms("Advanced search for related subjects and keyword 'history' searches related subjects", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County');
738
    like($query, qr/history/, "Advanced search for related subjects and keyword 'history' searches for 'history'");
722
    like($query, qr/history/, "Advanced search for related subjects and keyword 'history' searches for 'history'");
739
723
740
    ( $error, $query, $simple_query, $query_cgi,
724
    ( $error, $query, $simple_query, $query_cgi,
741
    $query_desc, $limit, $limit_cgi, $limit_desc,
725
    $query_desc, $limit, $limit_cgi, $limit_desc,
742
    $stopwords_removed, $query_type ) = buildQuery([], [ 'history', "$term" ], [ 'kw', 'su-rl' ], [  ], [], 0, 'en');
726
    $query_type ) = buildQuery([], [ 'history', "$term" ], [ 'kw', 'su-rl' ], [  ], [], 0, 'en');
743
    matchesExplodedTerms("Order of terms doesn't matter for advanced search", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County');
727
    matchesExplodedTerms("Order of terms doesn't matter for advanced search", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County');
744
    like($query, qr/history/, "Order of terms doesn't matter for advanced search");
728
    like($query, qr/history/, "Order of terms doesn't matter for advanced search");
745
729
746
    ( $error, $query, $simple_query, $query_cgi,
730
    ( $error, $query, $simple_query, $query_cgi,
747
    $query_desc, $limit, $limit_cgi, $limit_desc,
731
    $query_desc, $limit, $limit_cgi, $limit_desc,
748
    $stopwords_removed, $query_type ) = buildQuery([], [ "su-br($term)" ], [  ], [  ], [], 0, 'en');
732
    $query_type ) = buildQuery([], [ "su-br($term)" ], [  ], [  ], [], 0, 'en');
749
    matchesExplodedTerms("Simple search for broader subjects", $query, 'Arizona', 'United States');
733
    matchesExplodedTerms("Simple search for broader subjects", $query, 'Arizona', 'United States');
750
734
751
    ( $error, $query, $simple_query, $query_cgi,
735
    ( $error, $query, $simple_query, $query_cgi,
752
    $query_desc, $limit, $limit_cgi, $limit_desc,
736
    $query_desc, $limit, $limit_cgi, $limit_desc,
753
    $stopwords_removed, $query_type ) = buildQuery([], [ "su-na($term)" ], [  ], [  ], [], 0, 'en');
737
    $query_type ) = buildQuery([], [ "su-na($term)" ], [  ], [  ], [], 0, 'en');
754
    matchesExplodedTerms("Simple search for narrower subjects", $query, 'Arizona', 'Maricopa County', 'Navajo County', 'Pima County');
738
    matchesExplodedTerms("Simple search for narrower subjects", $query, 'Arizona', 'Maricopa County', 'Navajo County', 'Pima County');
755
739
756
    ( $error, $query, $simple_query, $query_cgi,
740
    ( $error, $query, $simple_query, $query_cgi,
757
    $query_desc, $limit, $limit_cgi, $limit_desc,
741
    $query_desc, $limit, $limit_cgi, $limit_desc,
758
    $stopwords_removed, $query_type ) = buildQuery([], [ "su-rl($term)" ], [  ], [  ], [], 0, 'en');
742
    $query_type ) = buildQuery([], [ "su-rl($term)" ], [  ], [  ], [], 0, 'en');
759
    matchesExplodedTerms("Simple search for related subjects", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County');
743
    matchesExplodedTerms("Simple search for related subjects", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County');
760
744
761
    ( $error, $query, $simple_query, $query_cgi,
745
    ( $error, $query, $simple_query, $query_cgi,
762
    $query_desc, $limit, $limit_cgi, $limit_desc,
746
    $query_desc, $limit, $limit_cgi, $limit_desc,
763
    $stopwords_removed, $query_type ) = buildQuery([], [ "history && su-rl($term)" ], [  ], [  ], [], 0, 'en');
747
    $query_type ) = buildQuery([], [ "history && su-rl($term)" ], [  ], [  ], [], 0, 'en');
764
    matchesExplodedTerms("Simple search for related subjects and keyword 'history' searches related subjects", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County');
748
    matchesExplodedTerms("Simple search for related subjects and keyword 'history' searches related subjects", $query, 'Arizona', 'United States', 'Maricopa County', 'Navajo County', 'Pima County');
765
    like($query, qr/history/, "Simple search for related subjects and keyword 'history' searches for 'history'");
749
    like($query, qr/history/, "Simple search for related subjects and keyword 'history' searches for 'history'");
766
750
Lines 907-913 sub run_unimarc_search_tests { Link Here
907
    $QueryAutoTruncate = 0;
891
    $QueryAutoTruncate = 0;
908
    $QueryWeightFields = 0;
892
    $QueryWeightFields = 0;
909
    $QueryFuzzy = 0;
893
    $QueryFuzzy = 0;
910
    $QueryRemoveStopwords = 0;
911
    $UseQueryParser = 0;
894
    $UseQueryParser = 0;
912
    $marcflavour = 'UNIMARC';
895
    $marcflavour = 'UNIMARC';
913
896
(-)a/test/search.pl (-5 lines)
Lines 37-43 foreach ( @SEARCH ) { Link Here
37
        $limit,
37
        $limit,
38
        $limit_cgi,
38
        $limit_cgi,
39
        $limit_desc,
39
        $limit_desc,
40
        $stopwords_removed,
41
        $query_type )
40
        $query_type )
42
      = buildQuery( $_->{operators}, $_->{operands}, $_->{indexes}, $_->{limits}, $_->{sort_by}, 0,  $_->{lang} );
41
      = buildQuery( $_->{operators}, $_->{operands}, $_->{indexes}, $_->{limits}, $_->{sort_by}, 0,  $_->{lang} );
43
42
Lines 64-72 foreach ( @SEARCH ) { Link Here
64
    $expected = $_->{limit_desc};
63
    $expected = $_->{limit_desc};
65
    push @mismatch, "Limit desc: $limit_desc (not: $expected)" unless $limit_desc eq $expected;
64
    push @mismatch, "Limit desc: $limit_desc (not: $expected)" unless $limit_desc eq $expected;
66
65
67
    $expected = $_->{stopwords_removed};
68
    push @mismatch, "Stopwords removed: $stopwords_removed (not: $expected)" unless $stopwords_removed eq $expected;
69
70
    $expected = $_->{query_type};
66
    $expected = $_->{query_type};
71
    push @mismatch, "Query Type: $query_type (not: $expected)" unless $query_type eq $expected;
67
    push @mismatch, "Query Type: $query_type (not: $expected)" unless $query_type eq $expected;
72
68
73
- 

Return to bug 9819