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

(-)a/C4/Context.pm (-46 lines)
Lines 125-132 C4::Context - Maintain and manipulate the context of a Koha script Link Here
125
125
126
  $Zconn = C4::Context->Zconn;
126
  $Zconn = C4::Context->Zconn;
127
127
128
  $stopwordhash = C4::Context->stopwords;
129
130
=head1 DESCRIPTION
128
=head1 DESCRIPTION
131
129
132
When a Koha script runs, it makes use of a certain number of things:
130
When a Koha script runs, it makes use of a certain number of things:
Lines 393-399 sub new { Link Here
393
391
394
    $self->{"dbh"} = undef;        # Database handle
392
    $self->{"dbh"} = undef;        # Database handle
395
    $self->{"Zconn"} = undef;    # Zebra Connections
393
    $self->{"Zconn"} = undef;    # Zebra Connections
396
    $self->{"stopwords"} = undef; # stopwords list
397
    $self->{"marcfromkohafield"} = undef; # the hash with relations between koha table fields and MARC field/subfield
394
    $self->{"marcfromkohafield"} = undef; # the hash with relations between koha table fields and MARC field/subfield
398
    $self->{"userenv"} = undef;        # User env
395
    $self->{"userenv"} = undef;        # User env
399
    $self->{"activeuser"} = undef;        # current active user
396
    $self->{"activeuser"} = undef;        # current active user
Lines 1013-1020 sub marcfromkohafield Link Here
1013
}
1010
}
1014
1011
1015
# _new_marcfromkohafield
1012
# _new_marcfromkohafield
1016
# Internal helper function (not a method!). This creates a new
1017
# hash with stopwords
1018
sub _new_marcfromkohafield
1013
sub _new_marcfromkohafield
1019
{
1014
{
1020
    my $dbh = C4::Context->dbh;
1015
    my $dbh = C4::Context->dbh;
Lines 1028-1074 sub _new_marcfromkohafield Link Here
1028
    return $marcfromkohafield;
1023
    return $marcfromkohafield;
1029
}
1024
}
1030
1025
1031
=head2 stopwords
1032
1033
  $dbh = C4::Context->stopwords;
1034
1035
Returns a hash with stopwords.
1036
1037
This hash is cached for future use: if you call
1038
C<C4::Context-E<gt>stopwords> twice, you will get the same hash without real DB access
1039
1040
=cut
1041
1042
#'
1043
sub stopwords
1044
{
1045
    my $retval = {};
1046
1047
    # If the hash already exists, return it.
1048
    return $context->{"stopwords"} if defined($context->{"stopwords"});
1049
1050
    # No hash. Create one.
1051
    $context->{"stopwords"} = &_new_stopwords();
1052
1053
    return $context->{"stopwords"};
1054
}
1055
1056
# _new_stopwords
1057
# Internal helper function (not a method!). This creates a new
1058
# hash with stopwords
1059
sub _new_stopwords
1060
{
1061
    my $dbh = C4::Context->dbh;
1062
    my $stopwordlist;
1063
    my $sth = $dbh->prepare("select word from stopwords");
1064
    $sth->execute;
1065
    while (my $stopword = $sth->fetchrow_array) {
1066
        $stopwordlist->{$stopword} = uc($stopword);
1067
    }
1068
    $stopwordlist->{A} = "A" unless $stopwordlist;
1069
    return $stopwordlist;
1070
}
1071
1072
=head2 userenv
1026
=head2 userenv
1073
1027
1074
  C4::Context->userenv;
1028
  C4::Context->userenv;
(-)a/C4/Search.pm (-49 / +9 lines)
Lines 744-775 sub pazGetRecords { Link Here
744
    return ( undef, $results_hashref, \@facets_loop );
744
    return ( undef, $results_hashref, \@facets_loop );
745
}
745
}
746
746
747
# STOPWORDS
748
sub _remove_stopwords {
749
    my ( $operand, $index ) = @_;
750
    my @stopwords_removed;
751
752
    # phrase and exact-qualified indexes shouldn't have stopwords removed
753
    if ( $index !~ m/phr|ext/ ) {
754
755
# remove stopwords from operand : parse all stopwords & remove them (case insensitive)
756
#       we use IsAlpha unicode definition, to deal correctly with diacritics.
757
#       otherwise, a French word like "leçon" woudl be split into "le" "çon", "le"
758
#       is a stopword, we'd get "çon" and wouldn't find anything...
759
#
760
		foreach ( keys %{ C4::Context->stopwords } ) {
761
			next if ( $_ =~ /(and|or|not)/ );    # don't remove operators
762
			if ( my ($matched) = ($operand =~
763
				/([^\X\p{isAlnum}]\Q$_\E[^\X\p{isAlnum}]|[^\X\p{isAlnum}]\Q$_\E$|^\Q$_\E[^\X\p{isAlnum}])/gi))
764
			{
765
				$operand =~ s/\Q$matched\E/ /gi;
766
				push @stopwords_removed, $_;
767
			}
768
		}
769
	}
770
    return ( $operand, \@stopwords_removed );
771
}
772
773
# TRUNCATION
747
# TRUNCATION
774
sub _detect_truncation {
748
sub _detect_truncation {
775
    my ( $operand, $index ) = @_;
749
    my ( $operand, $index ) = @_;
Lines 1229-1238 sub parseQuery { Link Here
1229
$simple_query, $query_cgi,
1203
$simple_query, $query_cgi,
1230
$query_desc, $limit,
1204
$query_desc, $limit,
1231
$limit_cgi, $limit_desc,
1205
$limit_cgi, $limit_desc,
1232
$stopwords_removed, $query_type ) = buildQuery ( $operators, $operands, $indexes, $limits, $sort_by, $scan, $lang);
1206
$query_type ) = buildQuery ( $operators, $operands, $indexes, $limits, $sort_by, $scan, $lang);
1233
1207
1234
Build queries and limits in CCL, CGI, Human,
1208
Build queries and limits in CCL, CGI, Human,
1235
handle truncation, stemming, field weighting, stopwords, fuzziness, etc.
1209
handle truncation, stemming, field weighting, fuzziness, etc.
1236
1210
1237
See verbose embedded documentation.
1211
See verbose embedded documentation.
1238
1212
Lines 1258-1264 sub buildQuery { Link Here
1258
    my $auto_truncation  = C4::Context->preference("QueryAutoTruncate")    || 0;
1232
    my $auto_truncation  = C4::Context->preference("QueryAutoTruncate")    || 0;
1259
    my $weight_fields    = C4::Context->preference("QueryWeightFields")    || 0;
1233
    my $weight_fields    = C4::Context->preference("QueryWeightFields")    || 0;
1260
    my $fuzzy_enabled    = C4::Context->preference("QueryFuzzy")           || 0;
1234
    my $fuzzy_enabled    = C4::Context->preference("QueryFuzzy")           || 0;
1261
    my $remove_stopwords = C4::Context->preference("QueryRemoveStopwords") || 0;
1262
1235
1263
    my $query        = $operands[0];
1236
    my $query        = $operands[0];
1264
    my $simple_query = $operands[0];
1237
    my $simple_query = $operands[0];
Lines 1271-1278 sub buildQuery { Link Here
1271
    my $limit_cgi;
1244
    my $limit_cgi;
1272
    my $limit_desc;
1245
    my $limit_desc;
1273
1246
1274
    my $stopwords_removed;    # flag to determine if stopwords have been removed
1275
1276
    my $cclq       = 0;
1247
    my $cclq       = 0;
1277
    my $cclindexes = getIndexes();
1248
    my $cclindexes = getIndexes();
1278
    if ( $query !~ /\s*ccl=/ ) {
1249
    if ( $query !~ /\s*ccl=/ ) {
Lines 1316-1322 sub buildQuery { Link Here
1316
#        return (
1287
#        return (
1317
#            undef,              $query, $simple_query, $query_cgi,
1288
#            undef,              $query, $simple_query, $query_cgi,
1318
#            $query,             $limit, $limit_cgi,    $limit_desc,
1289
#            $query,             $limit, $limit_cgi,    $limit_desc,
1319
#            $stopwords_removed, 'ccl'
1290
#            'ccl'
1320
#        );
1291
#        );
1321
#    }
1292
#    }
1322
1293
Lines 1340-1350 sub buildQuery { Link Here
1340
              # A flag to determine whether or not to add the index to the query
1311
              # A flag to determine whether or not to add the index to the query
1341
                my $indexes_set;
1312
                my $indexes_set;
1342
1313
1343
# If the user is sophisticated enough to specify an index, turn off field weighting, stemming, and stopword handling
1314
# If the user is sophisticated enough to specify an index, turn off field weighting, and stemming handling
1344
                if ( $operands[$i] =~ /\w(:|=)/ || $scan ) {
1315
                if ( $operands[$i] =~ /\w(:|=)/ || $scan ) {
1345
                    $weight_fields    = 0;
1316
                    $weight_fields    = 0;
1346
                    $stemming         = 0;
1317
                    $stemming         = 0;
1347
                    $remove_stopwords = 0;
1348
                } else {
1318
                } else {
1349
                    $operands[$i] =~ s/\?/{?}/g; # need to escape question marks
1319
                    $operands[$i] =~ s/\?/{?}/g; # need to escape question marks
1350
                }
1320
                }
Lines 1356-1377 sub buildQuery { Link Here
1356
                if ( $index eq 'yr' ) {
1326
                if ( $index eq 'yr' ) {
1357
                    $index .= ",st-numeric";
1327
                    $index .= ",st-numeric";
1358
                    $indexes_set++;
1328
                    $indexes_set++;
1359
					$stemming = $auto_truncation = $weight_fields = $fuzzy_enabled = $remove_stopwords = 0;
1329
                    $stemming = $auto_truncation = $weight_fields = $fuzzy_enabled = 0;
1360
                }
1330
                }
1361
1331
1362
                # Date of Acquisition
1332
                # Date of Acquisition
1363
                elsif ( $index eq 'acqdate' ) {
1333
                elsif ( $index eq 'acqdate' ) {
1364
                    $index .= ",st-date-normalized";
1334
                    $index .= ",st-date-normalized";
1365
                    $indexes_set++;
1335
                    $indexes_set++;
1366
					$stemming = $auto_truncation = $weight_fields = $fuzzy_enabled = $remove_stopwords = 0;
1336
                    $stemming = $auto_truncation = $weight_fields = $fuzzy_enabled = 0;
1367
                }
1337
                }
1368
                # ISBN,ISSN,Standard Number, don't need special treatment
1338
                # ISBN,ISSN,Standard Number, don't need special treatment
1369
                elsif ( $index eq 'nb' || $index eq 'ns' ) {
1339
                elsif ( $index eq 'nb' || $index eq 'ns' ) {
1370
                    (
1340
                    (
1371
                        $stemming,      $auto_truncation,
1341
                        $stemming,      $auto_truncation,
1372
                        $weight_fields, $fuzzy_enabled,
1342
                        $weight_fields, $fuzzy_enabled
1373
                        $remove_stopwords
1343
                    ) = ( 0, 0, 0, 0 );
1374
                    ) = ( 0, 0, 0, 0, 0 );
1375
1344
1376
                }
1345
                }
1377
1346
Lines 1389-1403 sub buildQuery { Link Here
1389
                my $index_plus       = $index . $struct_attr . ':';
1358
                my $index_plus       = $index . $struct_attr . ':';
1390
                my $index_plus_comma = $index . $struct_attr . ',';
1359
                my $index_plus_comma = $index . $struct_attr . ',';
1391
1360
1392
                # Remove Stopwords
1393
                if ($remove_stopwords) {
1394
                    ( $operand, $stopwords_removed ) =
1395
                      _remove_stopwords( $operand, $index );
1396
                    warn "OPERAND w/out STOPWORDS: >$operand<" if $DEBUG;
1397
                    warn "REMOVED STOPWORDS: @$stopwords_removed"
1398
                      if ( $stopwords_removed && $DEBUG );
1399
                }
1400
1401
                if ($auto_truncation){
1361
                if ($auto_truncation){
1402
					unless ( $index =~ /(st-|phr|ext)/ ) {
1362
					unless ( $index =~ /(st-|phr|ext)/ ) {
1403
						#FIXME only valid with LTR scripts
1363
						#FIXME only valid with LTR scripts
Lines 1604-1610 sub buildQuery { Link Here
1604
    return (
1564
    return (
1605
        undef,              $query, $simple_query, $query_cgi,
1565
        undef,              $query, $simple_query, $query_cgi,
1606
        $query_desc,        $limit, $limit_cgi,    $limit_desc,
1566
        $query_desc,        $limit, $limit_cgi,    $limit_desc,
1607
        $stopwords_removed, $query_type
1567
        $query_type
1608
    );
1568
    );
1609
}
1569
}
1610
1570
(-)a/INSTALL.fedora7 (-1 lines)
Lines 1185-1191 MySQL> show tables; Link Here
1185
| sessions |
1185
| sessions |
1186
| special_holidays |
1186
| special_holidays |
1187
| statistics |
1187
| statistics |
1188
| stopwords |
1189
| subscription |
1188
| subscription |
1190
| subscriptionhistory |
1189
| subscriptionhistory |
1191
| subscriptionroutinglist |
1190
| 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 under the
12
# terms of the GNU General Public License as published by the Free Software
13
# Foundation; either version 2 of the License, or (at your option) any later
14
# version.
15
#
16
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19
#
20
# You should have received a copy of the GNU General Public License along
21
# with Koha; if not, write to the Free Software Foundation, Inc.,
22
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
24
use strict;
25
use warnings;
26
use CGI;
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.tmpl",
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 470-481 my $hits; Link Here
470
my $expanded_facet = $params->{'expand'};
470
my $expanded_facet = $params->{'expand'};
471
471
472
# Define some global variables
472
# Define some global variables
473
my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type);
473
my ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
474
474
475
my @results;
475
my @results;
476
476
477
## I. BUILD THE QUERY
477
## I. BUILD THE QUERY
478
( $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);
478
( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type) = buildQuery(\@operators,\@operands,\@indexes,\@limits,\@sort_by,$scan,$lang);
479
479
480
## parse the query_cgi string and put it into a form suitable for <input>s
480
## parse the query_cgi string and put it into a form suitable for <input>s
481
my @query_inputs;
481
my @query_inputs;
Lines 577-583 for (my $i=0;$i<@servers;$i++) { Link Here
577
            if ($query_desc || $limit_desc) {
577
            if ($query_desc || $limit_desc) {
578
                $template->param(searchdesc => 1);
578
                $template->param(searchdesc => 1);
579
            }
579
            }
580
            $template->param(stopwords_removed => "@$stopwords_removed") if $stopwords_removed;
581
            $template->param(results_per_page =>  $results_per_page);
580
            $template->param(results_per_page =>  $results_per_page);
582
            # must define a value for size if not present in DB
581
            # must define a value for size if not present in DB
583
            # in order to avoid problems generated by the default size value in TT
582
            # in order to avoid problems generated by the default size value in TT
(-)a/cataloguing/addbooks.pl (-1 / +1 lines)
Lines 74-80 if ($query) { Link Here
74
    my $QParser;
74
    my $QParser;
75
    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
75
    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
76
    unless ($QParser) {
76
    unless ($QParser) {
77
        my ( $builterror,$builtquery,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = buildQuery(undef,\@operands);
77
        my ( $builterror,$builtquery,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type) = buildQuery(undef,\@operands);
78
        $query = $builtquery;
78
        $query = $builtquery;
79
    }
79
    }
80
80
(-)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/sample_only_param_tables.sql (-15 lines)
Lines 130-150 INSERT INTO printers VALUES( 'Foxton Issue', 'foxlp', 'docket'); Link Here
130
INSERT INTO printers VALUES( 'No Printer', 'nulllp', '');
130
INSERT INTO printers VALUES( 'No Printer', 'nulllp', '');
131
INSERT INTO printers VALUES( 'Laser Printer', 'lp', '');
131
INSERT INTO printers VALUES( 'Laser Printer', 'lp', '');
132
132
133
INSERT INTO stopwords VALUES( 'A');
134
INSERT INTO stopwords VALUES( 'AND');
135
INSERT INTO stopwords VALUES( 'ASSOC');
136
INSERT INTO stopwords VALUES( 'ASSOCIATES');
137
INSERT INTO stopwords VALUES( 'CO');
138
INSERT INTO stopwords VALUES( 'COMPANY');
139
INSERT INTO stopwords VALUES( 'CORP');
140
INSERT INTO stopwords VALUES( 'CORPORATION');
141
INSERT INTO stopwords VALUES( 'INC');
142
INSERT INTO stopwords VALUES( 'INCORPORATED');
143
INSERT INTO stopwords VALUES( 'LTD');
144
INSERT INTO stopwords VALUES( 'OF');
145
INSERT INTO stopwords VALUES( 'THE');
146
INSERT INTO stopwords VALUES( 'THIS');
147
148
INSERT INTO users VALUES( 'C', 'Levin', 'engido', '1');
133
INSERT INTO users VALUES( 'C', 'Levin', 'engido', '1');
149
INSERT INTO users VALUES( 'S', 'Shannon', 'xeyangu', '1');
134
INSERT INTO users VALUES( 'S', 'Shannon', 'xeyangu', '1');
150
INSERT INTO users VALUES( 'F', 'Foxton', 'thoochi', '1');
135
INSERT INTO users VALUES( 'F', 'Foxton', 'thoochi', '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 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="form-text" />
17
				<input type="submit" value="Submit"  class="submit" />
18
		</form>
19
	</div>
20
	[% END %]
21
			<ul>
22
            <li><a href="#stopword_search">Search stop words</a></li>
23
            [% IF ( CAN_user_circulate ) %]<li><a href="#circ_search">Check out</a></li>[% END %]
24
            [% IF ( CAN_user_catalogue ) %]<li><a 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 (-153 lines)
Lines 1-153 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 toUC(f) {
16
        var x=f.value.toUpperCase();
17
        f.value=x;
18
        return true;
19
    }
20
    function Check(f) {
21
        if (f.word.value.length==0) {
22
            alert(_("Form not submitted: word missing"));
23
        } else {
24
            document.Aform.submit();
25
        }
26
    }
27
//]]>
28
</script>
29
</head>
30
<body id="admin_stopwords" class="admin">
31
[% INCLUDE 'header.inc' %]
32
[% INCLUDE 'stopwords-admin-search.inc' %]
33
34
<div id="breadcrumbs">
35
<a href="/cgi-bin/koha/mainpage.pl">Home</a>
36
&rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
37
&rsaquo; <a href="/cgi-bin/koha/admin/stopwords.pl">Stop words</a>
38
[% IF ( add_form ) %]
39
    &rsaquo; [% IF ( searchfield ) %]Modify[% ELSE %]New[% END %] Stop word
40
[% ELSIF ( add_validate ) %]
41
    &rsaquo; Data recorded
42
[% ELSIF ( delete_confirm ) %]
43
    &rsaquo; Delete stop word '[% searchfield %]' ?
44
[% ELSIF ( delete_confirmed ) %]
45
    &rsaquo; Data deleted
46
[% END %]
47
</div>
48
49
<div id="doc3" class="yui-t2">
50
   
51
   <div id="bd">
52
	<div id="yui-main">
53
	<div class="yui-b">
54
55
[% IF ( add_form ) %]
56
        [% IF ( searchfield ) %]
57
            <h1>Modify word</h1>
58
        [% ELSE %]
59
            <h1>New word</h1>
60
        [% END %]
61
        <form action="[% script_name %]" name="Aform" method="post">
62
            <input type="hidden" name="op" value="add_validate" />
63
            <fieldset class="rows">
64
            <ol><li>
65
            [% IF ( searchfield ) %]
66
                <span class="label">Word</span>
67
                    <input type="hidden" name="word" value="[% searchfield %]" />[% searchfield %]
68
            [% ELSE %]
69
                <label for="word">Word</label>
70
                <input type="text" name="word" id="word" size="50" maxlength="250" onblur="toUC(this)" />
71
            [% END %]
72
                </li>
73
            </ol>
74
            </fieldset>
75
            <fieldset class="action">
76
                <input type="button" value="Save" onclick="Check(this.form)" />
77
                <a class="cancel" href="/cgi-bin/koha/admin/stopwords.pl">Cancel</a>
78
            </fieldset>
79
        </form>
80
[% END %]
81
82
[% IF ( add_validate ) %]
83
   <div class="dialog message"> <h3>Data recorded</h3>
84
    <form action="[% script_name %]" method="post">
85
        <input type="submit" value="OK" class="approve" />
86
    </form></div>
87
[% END %]
88
89
[% IF ( delete_confirm ) %]
90
    <div class="dialog alert">
91
    <h3>Delete stop word <span class="ex">'[% searchfield %]'</span></h3>
92
	<form action="[% script_name %]" method="post">
93
        <input type="hidden" name="op" value="delete_confirmed" />
94
        <input type="hidden" name="searchfield" value="[% searchfield %]" />
95
        <input type="submit" value="Yes, Delete" class="approve" />
96
    </form>
97
    <form action="[% script_name %]" method="get">
98
        <input type="submit" class="deny" value="No, Do Not Delete" />
99
    </form></div>
100
[% END %]
101
102
[% IF ( delete_confirmed ) %]
103
   <div class="dialog message"> <h3>Data deleted</h3>
104
    <form action="[% script_name %]" method="post">
105
        <input type="submit" value="OK" class="approve" />
106
    </form></div>
107
[% END %]
108
109
[% IF ( else ) %]
110
111
<div id="toolbar">
112
	<ul class="toolbar">
113
    <li><a id="newstopword" href="/cgi-bin/koha/admin/stopwords.pl?op=add_form">New stop word</a></li>
114
</ul></div>
115
116
    <h1>Stop words</h1>
117
    <p class="message">NOTE : if you change something in this table, ask your administrator to run misc/batchRebuildBiblioTables.pl script.</p>
118
119
    [% IF ( searchfield ) %]
120
        <p>You searched for <b>[% searchfield %]</b></p>
121
    [% END %]
122
123
    <table>
124
        <tr><th>Word</th>
125
            <th></th>
126
        </tr>
127
        [% FOREACH loo IN loop %]
128
           [% IF ( loop.odd ) %]<tr>
129
           [% ELSE %]<tr class="highlight">
130
           [% END %]
131
            <td>[% loo.word %]</td>
132
            <td><a href="[% loo.script_name %]?op=delete_confirm&amp;searchfield=[% loo.word %]">Delete</a></td>
133
        </tr>
134
        [% END %]
135
    </table>
136
137
    <div class="pages">
138
        [% IF ( offsetgtzero ) %]
139
            <a href="[% script_name %]?offset=[% prevpage %]">&lt;&lt; Previous</a>
140
        [% END %]
141
        [% IF ( ltcount ) %]
142
            <a href="[% script_name %]?offset=[% nextpage %]">Next &gt;&gt;</a>
143
        [% END %]
144
    </div>
145
[% END %]
146
147
</div>
148
</div>
149
<div class="yui-b">
150
[% INCLUDE 'admin-menu.inc' %]
151
</div>
152
</div>
153
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt (-1 lines)
Lines 306-312 var holdForPatron = function () { Link Here
306
                [% IF ( CAN_user_editcatalogue_edit_catalogue ) %] <div class="btn-group"><a class="btn btn-mini" id="z3950submit" href="#"><i class="icon-search"></i> Z39.50 search</a></div>[% END %]
306
                [% IF ( CAN_user_editcatalogue_edit_catalogue ) %] <div class="btn-group"><a class="btn btn-mini" id="z3950submit" href="#"><i class="icon-search"></i> Z39.50 search</a></div>[% END %]
307
            </div>
307
            </div>
308
        </div>
308
        </div>
309
    [% IF ( stopwords_removed ) %]<div><p class="tip">Ignored the following common words: "[% stopwords_removed %]"<p></div>[% END %]
310
    [% ELSE %]
309
    [% ELSE %]
311
        <div id="searchheader">
310
        <div id="searchheader">
312
			<form method="post" name="fz3950" class="fz3950bigrpad">
311
			<form method="post" name="fz3950" class="fz3950bigrpad">
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/help/admin/stopwords.tt (-15 lines)
Lines 1-15 Link Here
1
[% INCLUDE 'help-top.inc' %]
2
3
<h1>Stop Words</h1>
4
5
<p>Stop words are words that you want the search system to ignore.</p>
6
7
<p>Koha comes with a standard list of stop words that can be edited by visiting the Stop Word administration area.</p>
8
9
<p>To add a new stop word to the list, click the 'New Stop Word' button and add the word you'd like ignored</p>
10
11
<p style="color: #990000">Important: If you change something in this table, ask your administrator to run misc/batchRebuildBiblioTables.pl script.</p>
12
13
<p><strong>See the full documentation for Stop Words in the <a href="http://manual.koha-community.org/3.10/en/additionaladmin.html#stopwordsadmin">manual</a> (online).</strong></p>
14
15
[% INCLUDE 'help-bottom.inc' %]
(-)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 440-451 my $hits; Link Here
440
my $expanded_facet = $params->{'expand'};
440
my $expanded_facet = $params->{'expand'};
441
441
442
# Define some global variables
442
# Define some global variables
443
my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type);
443
my ($error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
444
444
445
my @results;
445
my @results;
446
446
447
## I. BUILD THE QUERY
447
## I. BUILD THE QUERY
448
( $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);
448
( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type) = buildQuery(\@operators,\@operands,\@indexes,\@limits,\@sort_by, 0, $lang);
449
449
450
sub _input_cgi_parse {
450
sub _input_cgi_parse {
451
    my @elements;
451
    my @elements;
Lines 711-717 for (my $i=0;$i<@servers;$i++) { Link Here
711
            if ($query_desc || $limit_desc) {
711
            if ($query_desc || $limit_desc) {
712
                $template->param(searchdesc => 1);
712
                $template->param(searchdesc => 1);
713
            }
713
            }
714
            $template->param(stopwords_removed => "@$stopwords_removed") if $stopwords_removed;
715
            $template->param(results_per_page =>  $results_per_page);
714
            $template->param(results_per_page =>  $results_per_page);
716
            my $hide = C4::Context->preference('OpacHiddenItems');
715
            my $hide = C4::Context->preference('OpacHiddenItems');
717
            $hide = ($hide =~ m/\S/) if $hide; # Just in case it has some spaces/new lines
716
            $hide = ($hide =~ m/\S/) if $hide; # Just in case it has some spaces/new lines
(-)a/t/db_dependent/Search.t (-108 / +64 lines)
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
(-)a/t/db_dependent/lib/KohaTest.pm (-1 lines)
Lines 166-172 sub startup_15_truncate_tables : Test( startup => 1 ) { Link Here
166
#                               sessions
166
#                               sessions
167
#                               special_holidays
167
#                               special_holidays
168
#                               statistics
168
#                               statistics
169
#                               stopwords
170
#                               subscription
169
#                               subscription
171
#                               subscriptionhistory
170
#                               subscriptionhistory
172
#                               subscriptionroutinglist
171
#                               subscriptionroutinglist
(-)a/t/db_dependent/lib/KohaTest/Context.pm (-2 lines)
Lines 34-47 sub methods : Test( 1 ) { Link Here
34
                        set_dbh
34
                        set_dbh
35
                        set_shelves_userenv
35
                        set_shelves_userenv
36
                        set_userenv
36
                        set_userenv
37
                        stopwords
38
                        userenv
37
                        userenv
39
                        Zconn
38
                        Zconn
40
                        zebraconfig
39
                        zebraconfig
41
                        _common_config
40
                        _common_config
42
                        _new_dbh
41
                        _new_dbh
43
                        _new_marcfromkohafield
42
                        _new_marcfromkohafield
44
                        _new_stopwords
45
                        _new_userenv
43
                        _new_userenv
46
                        _new_Zconn
44
                        _new_Zconn
47
                        _unset_userenv
45
                        _unset_userenv
(-)a/t/db_dependent/lib/KohaTest/Search.pm (-1 lines)
Lines 17-23 sub methods : Test( 1 ) { Link Here
17
                      SimpleSearch
17
                      SimpleSearch
18
                      getRecords
18
                      getRecords
19
                      pazGetRecords
19
                      pazGetRecords
20
                      _remove_stopwords
21
                      _detect_truncation
20
                      _detect_truncation
22
                      _build_stemmed_operand
21
                      _build_stemmed_operand
23
                      _build_weighted_query
22
                      _build_weighted_query
(-)a/t/searchengine/003_query/buildquery.t (-1 / +1 lines)
Lines 35-41 set_zebra; Link Here
35
$se = Koha::SearchEngine->new;
35
$se = Koha::SearchEngine->new;
36
is( $se->name, "Zebra", "Test searchengine name eq Zebra" );
36
is( $se->name, "Zebra", "Test searchengine name eq Zebra" );
37
$qs = Koha::SearchEngine::QueryBuilder->new;
37
$qs = Koha::SearchEngine::QueryBuilder->new;
38
my ( $builterror, $builtquery, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, $limit_desc, $stopwords_removed, $query_type ) = $qs->build_query($operators, $operands, $indexes);
38
my ( $builterror, $builtquery, $simple_query, $query_cgi, $query_desc, $limit, $limit_cgi, $limit_desc, $query_type ) = $qs->build_query($operators, $operands, $indexes);
39
my $gotzebra = $builtquery;
39
my $gotzebra = $builtquery;
40
my $expectedzebra = qq{ti,wrdl= cup AND au,wrdl= rowling };
40
my $expectedzebra = qq{ti,wrdl= cup AND au,wrdl= rowling };
41
is($gotzebra, $expectedzebra, "Test Zebra indexes in 'normal' search");
41
is($gotzebra, $expectedzebra, "Test Zebra indexes in 'normal' search");
(-)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