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

(-)a/C4/AuthoritiesMarc.pm (-5 / +35 lines)
Lines 201-206 sub SearchAuthorities { Link Here
201
        }
201
        }
202
    } else {
202
    } else {
203
        my $query;
203
        my $query;
204
        my $qpquery = '';
205
        my $QParser;
206
        $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
204
        my $attr = '';
207
        my $attr = '';
205
            # the marclist may contain "mainentry". In this case, search the tag_to_report, that depends on
208
            # the marclist may contain "mainentry". In this case, search the tag_to_report, that depends on
206
            # the authtypecode. Then, search on $a of this tag_to_report
209
            # the authtypecode. Then, search on $a of this tag_to_report
Lines 219-224 sub SearchAuthorities { Link Here
219
            if ($n>1){
222
            if ($n>1){
220
                while ($n>1){$query= "\@or ".$query;$n--;}
223
                while ($n>1){$query= "\@or ".$query;$n--;}
221
            }
224
            }
225
            if ($QParser) {
226
                $qpquery .= '(authtype:' . join('|| authtype:', @auths) . ')';
227
            }
222
        }
228
        }
223
        
229
        
224
        my $dosearch;
230
        my $dosearch;
Lines 276-281 sub SearchAuthorities { Link Here
276
                $q2 .=$attr;
282
                $q2 .=$attr;
277
                $dosearch=1;
283
                $dosearch=1;
278
                ++$attr_cnt;
284
                ++$attr_cnt;
285
                if ($QParser) {
286
                    $qpquery .= " $tags->[$i]:$value->[$i]";
287
                }
279
            }#if value
288
            }#if value
280
        }
289
        }
281
        ##Add how many queries generated
290
        ##Add how many queries generated
Lines 296-303 sub SearchAuthorities { Link Here
296
        } elsif ($sortby eq 'AuthidDsc') {
305
        } elsif ($sortby eq 'AuthidDsc') {
297
            $orderstring = '@attr 7=2 @attr 4=109 @attr 1=Local-Number 0';
306
            $orderstring = '@attr 7=2 @attr 4=109 @attr 1=Local-Number 0';
298
        }
307
        }
299
        $query=($query?$query:"\@attr 1=_ALLRECORDS \@attr 2=103 ''");
308
        if ($QParser) {
300
        $query="\@or $orderstring $query" if $orderstring;
309
            $qpquery .= ' all:all' unless $value->[0];
310
311
            if ( $value->[0] =~ m/^qp=(.*)$/ ) {
312
                $qpquery = $1;
313
            }
314
315
            $qpquery .= " #$sortby";
316
317
            $QParser->parse( $qpquery );
318
            $query = $QParser->target_syntax('authorityserver');
319
        } else {
320
            $query=($query?$query:"\@attr 1=_ALLRECORDS \@attr 2=103 ''");
321
            $query="\@or $orderstring $query" if $orderstring;
322
        }
301
323
302
        $offset=0 unless $offset;
324
        $offset=0 unless $offset;
303
        my $counter = $offset;
325
        my $counter = $offset;
Lines 406-412 sub CountUsage { Link Here
406
    } else {
428
    } else {
407
        ### ZOOM search here
429
        ### ZOOM search here
408
        my $query;
430
        my $query;
409
        $query= "an=".$authid;
431
        $query= "an:".$authid;
410
  		my ($err,$res,$result) = C4::Search::SimpleSearch($query,0,10);
432
  		my ($err,$res,$result) = C4::Search::SimpleSearch($query,0,10);
411
        if ($err) {
433
        if ($err) {
412
            warn "Error: $err from search $query";
434
            warn "Error: $err from search $query";
Lines 910-920 sub FindDuplicateAuthority { Link Here
910
    $sth->finish;
932
    $sth->finish;
911
#     warn "record :".$record->as_formatted."  auth_tag_to_report :$auth_tag_to_report";
933
#     warn "record :".$record->as_formatted."  auth_tag_to_report :$auth_tag_to_report";
912
    # build a request for SearchAuthorities
934
    # build a request for SearchAuthorities
913
    my $query='at='.$authtypecode.' ';
935
    my $QParser;
936
    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
937
    my $op;
938
    if ($QParser) {
939
        $op = '&&';
940
    } else {
941
        $op = 'and';
942
    }
943
    my $query='at:'.$authtypecode.' ';
914
    my $filtervalues=qr([\001-\040\!\'\"\`\#\$\%\&\*\+,\-\./:;<=>\?\@\(\)\{\[\]\}_\|\~]);
944
    my $filtervalues=qr([\001-\040\!\'\"\`\#\$\%\&\*\+,\-\./:;<=>\?\@\(\)\{\[\]\}_\|\~]);
915
    if ($record->field($auth_tag_to_report)) {
945
    if ($record->field($auth_tag_to_report)) {
916
      foreach ($record->field($auth_tag_to_report)->subfields()) {
946
      foreach ($record->field($auth_tag_to_report)->subfields()) {
917
        $_->[1]=~s/$filtervalues/ /g; $query.= " and he,wrdl=\"".$_->[1]."\"" if ($_->[0]=~/[A-z]/);
947
        $_->[1]=~s/$filtervalues/ /g; $query.= " $op he:\"".$_->[1]."\"" if ($_->[0]=~/[A-z]/);
918
      }
948
      }
919
    }
949
    }
920
    my ($error, $results, $total_hits) = C4::Search::SimpleSearch( $query, 0, 1, [ "authorityserver" ] );
950
    my ($error, $results, $total_hits) = C4::Search::SimpleSearch( $query, 0, 1, [ "authorityserver" ] );
(-)a/C4/Matcher.pm (-24 / +31 lines)
Lines 626-631 sub get_matches { Link Here
626
626
627
    my %matches = ();
627
    my %matches = ();
628
628
629
    my $QParser;
630
    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
629
    foreach my $matchpoint (@{ $self->{'matchpoints'} }) {
631
    foreach my $matchpoint (@{ $self->{'matchpoints'} }) {
630
        my @source_keys = _get_match_keys($source_record, $matchpoint);
632
        my @source_keys = _get_match_keys($source_record, $matchpoint);
631
        next if scalar(@source_keys) == 0;
633
        next if scalar(@source_keys) == 0;
Lines 634-664 sub get_matches { Link Here
634
        my $error;
636
        my $error;
635
        my $searchresults;
637
        my $searchresults;
636
        my $total_hits;
638
        my $total_hits;
637
        if ($self->{'record_type'} eq 'biblio') {
639
        if ($QParser) {
638
            $query = join(" or ", map { "$matchpoint->{'index'}=$_" } @source_keys);
640
            $query = join(" || ", map { "$matchpoint->{'index'}:$_" } @source_keys);
639
# FIXME only searching biblio index at the moment
640
            require C4::Search;
641
            require C4::Search;
641
            ($error, $searchresults, $total_hits) = C4::Search::SimpleSearch($query, 0, $max_matches);
642
            ($error, $searchresults, $total_hits) = C4::Search::SimpleSearch($query, 0, $max_matches, [ $self->{'record_type'} . 'server' ] );
642
        } elsif ($self->{'record_type'} eq 'authority') {
643
        } else {
643
            my $authresults;
644
            if ($self->{'record_type'} eq 'biblio') {
644
            my @marclist;
645
                $query = join(" or ", map { "$matchpoint->{'index'}=$_" } @source_keys);
645
            my @and_or;
646
                require C4::Search;
646
            my @excluding = [];
647
                ($error, $searchresults, $total_hits) = C4::Search::SimpleSearch($query, 0, $max_matches);
647
            my @operator;
648
            } elsif ($self->{'record_type'} eq 'authority') {
648
            my @value;
649
                my $authresults;
649
            foreach my $key (@source_keys) {
650
                my @marclist;
650
                push @marclist, $matchpoint->{'index'};
651
                my @and_or;
651
                push @and_or, 'or';
652
                my @excluding = [];
652
                push @operator, 'exact';
653
                my @operator;
653
                push @value, $key;
654
                my @value;
654
            }
655
                foreach my $key (@source_keys) {
655
            require C4::AuthoritiesMarc;
656
                    push @marclist, $matchpoint->{'index'};
656
            ($authresults, $total_hits) = C4::AuthoritiesMarc::SearchAuthorities(
657
                    push @and_or, 'or';
657
                    \@marclist, \@and_or, \@excluding, \@operator,
658
                    push @operator, 'exact';
658
                    \@value, 0, 20, undef, 'AuthidAsc', 1
659
                    push @value, $key;
659
            );
660
                }
660
            foreach my $result (@$authresults) {
661
                require C4::AuthoritiesMarc;
661
                push @$searchresults, $result->{'authid'};
662
                ($authresults, $total_hits) = C4::AuthoritiesMarc::SearchAuthorities(
663
                        \@marclist, \@and_or, \@excluding, \@operator,
664
                        \@value, 0, 20, undef, 'AuthidAsc', 1
665
                        );
666
                foreach my $result (@$authresults) {
667
                    push @$searchresults, $result->{'authid'};
668
                }
662
            }
669
            }
663
        }
670
        }
664
671
(-)a/C4/Search.pm (-37 / +75 lines)
Lines 100-108 sub FindDuplicate { Link Here
100
    if ( $result->{isbn} ) {
100
    if ( $result->{isbn} ) {
101
        $result->{isbn} =~ s/\(.*$//;
101
        $result->{isbn} =~ s/\(.*$//;
102
        $result->{isbn} =~ s/\s+$//;
102
        $result->{isbn} =~ s/\s+$//;
103
        $query = "isbn=$result->{isbn}";
103
        $query = "isbn:$result->{isbn}";
104
    }
104
    }
105
    else {
105
    else {
106
        my $QParser;
107
        $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
108
        my $titleindex;
109
        my $authorindex;
110
111
        if ($QParser) {
112
            $titleindex = 'title|exact';
113
            $authorindex = 'author|exact';
114
        } else {
115
            $titleindex = 'ti,ext';
116
            $authorindex = 'au,ext';
117
        }
118
106
        $result->{title} =~ s /\\//g;
119
        $result->{title} =~ s /\\//g;
107
        $result->{title} =~ s /\"//g;
120
        $result->{title} =~ s /\"//g;
108
        $result->{title} =~ s /\(//g;
121
        $result->{title} =~ s /\(//g;
Lines 111-118 sub FindDuplicate { Link Here
111
        # FIXME: instead of removing operators, could just do
124
        # FIXME: instead of removing operators, could just do
112
        # quotes around the value
125
        # quotes around the value
113
        $result->{title} =~ s/(and|or|not)//g;
126
        $result->{title} =~ s/(and|or|not)//g;
114
        $query = "ti,ext=$result->{title}";
127
        $query = "$titleindex:\"$result->{title}\"";
115
        $query .= " and itemtype=$result->{itemtype}"
128
        $query .= " && itemtype:$result->{itemtype}"
116
          if ( $result->{itemtype} );
129
          if ( $result->{itemtype} );
117
        if   ( $result->{author} ) {
130
        if   ( $result->{author} ) {
118
            $result->{author} =~ s /\\//g;
131
            $result->{author} =~ s /\\//g;
Lines 122-128 sub FindDuplicate { Link Here
122
135
123
            # remove valid operators
136
            # remove valid operators
124
            $result->{author} =~ s/(and|or|not)//g;
137
            $result->{author} =~ s/(and|or|not)//g;
125
            $query .= " and au,ext=$result->{author}";
138
            $query .= " && $authorindex:\"$result->{author}\"";
126
        }
139
        }
127
    }
140
    }
128
141
Lines 226-236 sub SimpleSearch { Link Here
226
        my $results = [];
239
        my $results = [];
227
        my $total_hits = 0;
240
        my $total_hits = 0;
228
241
242
        my $QParser;
243
        $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser') && ! ($query =~ m/\w,\w|\w=\w/));
244
229
        # Initialize & Search Zebra
245
        # Initialize & Search Zebra
230
        for ( my $i = 0 ; $i < @servers ; $i++ ) {
246
        for ( my $i = 0 ; $i < @servers ; $i++ ) {
231
            eval {
247
            eval {
232
                $zconns[$i] = C4::Context->Zconn( $servers[$i], 1 );
248
                $zconns[$i] = C4::Context->Zconn( $servers[$i], 1 );
233
                $zoom_queries[$i] = new ZOOM::Query::CCL2RPN( $query, $zconns[$i]);
249
                if ($QParser) {
250
                    $query =~ s/=/:/g;
251
                    $QParser->parse( $query );
252
                    $query = $QParser->target_syntax($servers[$i]);
253
                    $zoom_queries[$i] = new ZOOM::Query::PQF( $query, $zconns[$i]);
254
                } else {
255
                    $zoom_queries[$i] = new ZOOM::Query::CCL2RPN( $query, $zconns[$i]);
256
                }
234
                $tmpresults[$i] = $zconns[$i]->search( $zoom_queries[$i] );
257
                $tmpresults[$i] = $zconns[$i]->search( $zoom_queries[$i] );
235
258
236
                # error handling
259
                # error handling
Lines 1093-1099 on authority data). Link Here
1093
=cut
1116
=cut
1094
1117
1095
sub _handle_exploding_index {
1118
sub _handle_exploding_index {
1096
    my ( $index, $term ) = @_;
1119
    my ($QParser, $struct, $filter, $params, $negate, $server) = @_;
1120
    my $index = $filter;
1121
    my $term = join(' ', @$params);
1097
1122
1098
    return unless ($index =~ m/(su-br|su-na|su-rl)/ && $term);
1123
    return unless ($index =~ m/(su-br|su-na|su-rl)/ && $term);
1099
1124
Lines 1101-1108 sub _handle_exploding_index { Link Here
1101
1126
1102
    my $codesubfield = $marcflavour eq 'UNIMARC' ? '5' : 'w';
1127
    my $codesubfield = $marcflavour eq 'UNIMARC' ? '5' : 'w';
1103
    my $wantedcodes = '';
1128
    my $wantedcodes = '';
1104
    my @subqueries = ( "(su=\"$term\")");
1129
    my @subqueries = ( "su:\"$term\"");
1105
    my ($error, $results, $total_hits) = SimpleSearch( "Heading,wrdl=$term", undef, undef, [ "authorityserver" ] );
1130
    my ($error, $results, $total_hits) = SimpleSearch( "he:$term", undef, undef, [ "authorityserver" ] );
1106
    foreach my $auth (@$results) {
1131
    foreach my $auth (@$results) {
1107
        my $record = MARC::Record->new_from_usmarc($auth);
1132
        my $record = MARC::Record->new_from_usmarc($auth);
1108
        my @references = $record->field('5..');
1133
        my @references = $record->field('5..');
Lines 1116-1126 sub _handle_exploding_index { Link Here
1116
            }
1141
            }
1117
            foreach my $reference (@references) {
1142
            foreach my $reference (@references) {
1118
                my $codes = $reference->subfield($codesubfield);
1143
                my $codes = $reference->subfield($codesubfield);
1119
                push @subqueries, '(su="' . $reference->as_string('abcdefghijlmnopqrstuvxyz') . '")' if (($codes && $codes eq $wantedcodes) || !$wantedcodes);
1144
                push @subqueries, 'su:"' . $reference->as_string('abcdefghijlmnopqrstuvxyz') . '"' if (($codes && $codes eq $wantedcodes) || !$wantedcodes);
1120
            }
1145
            }
1121
        }
1146
        }
1122
    }
1147
    }
1123
    return join(' or ', @subqueries);
1148
    my $query = '(' x scalar(@subqueries) . join(') || ', @subqueries) . ')';
1149
    warn $query;
1150
    return $query;
1124
}
1151
}
1125
1152
1126
=head2 parseQuery
1153
=head2 parseQuery
Lines 1147-1183 sub parseQuery { Link Here
1147
    my $query = $operands[0];
1174
    my $query = $operands[0];
1148
    my $index;
1175
    my $index;
1149
    my $term;
1176
    my $term;
1177
    my $query_desc;
1150
1178
1151
# TODO: once we are using QueryParser, all this special case code for
1179
    my $QParser;
1152
#       exploded search indexes will be replaced by a callback to
1180
    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser') || $query =~ s/^qp=//);
1153
#       _handle_exploding_index
1181
    undef $QParser if ($query =~ m/^(ccl=|pqf=|cql=)/ || grep (/\w,\w|\w=\w/, @operands) );
1154
    if ( $query =~ m/^(.*)\b(su-br|su-na|su-rl)[:=](\w.*)$/ ) {
1182
1155
        $query = $1;
1183
    if ($QParser)
1156
        $index = $2;
1184
    {
1157
        $term  = $3;
1158
    } else {
1159
        $query = '';
1185
        $query = '';
1160
        for ( my $i = 0 ; $i <= @operands ; $i++ ) {
1186
        for ( my $ii = 0 ; $ii <= @operands ; $ii++ ) {
1161
            if ($operands[$i] && $indexes[$i] =~ m/(su-br|su-na|su-rl)/) {
1187
            next unless $operands[$ii];
1162
                $index = $indexes[$i];
1188
            $query .= $operators[ $ii - 1 ] eq 'or' ? ' || ' : ' && '
1163
                $term = $operands[$i];
1189
              if ($query);
1164
            } elsif ($operands[$i]) {
1190
            $query .=
1165
                $query .= $operators[$i] eq 'or' ? ' or ' : ' and ' if ($query);
1191
              ( $operators[$ii] ? "$operators[$ii]:" : '' ) . $operands[$ii];
1166
                $query .= "($indexes[$i]:$operands[$i])";
1192
        }
1167
            }
1193
        foreach my $limit (@limits) {
1194
        }
1195
        foreach my $modifier (@sort_by) {
1196
            $query .= " #$modifier";
1168
        }
1197
        }
1169
    }
1170
1198
1171
    if ($index) {
1199
        $query_desc = $query;
1172
        my $queryPart = _handle_exploding_index($index, $term);
1200
        if ( C4::Context->preference("QueryWeightFields") ) {
1173
        if ($queryPart) {
1174
            $query .= "($queryPart)";
1175
        }
1201
        }
1176
        $operators = ();
1202
        $QParser->add_bib1_filter_map( 'biblioserver', 'su-br', { 'callback' => \&_handle_exploding_index });
1177
        $operands[0] = "ccl=$query";
1203
        $QParser->add_bib1_filter_map( 'biblioserver', 'su-na', { 'callback' => \&_handle_exploding_index });
1204
        $QParser->add_bib1_filter_map( 'biblioserver', 'su-rl', { 'callback' => \&_handle_exploding_index });
1205
        $QParser->parse( $query );
1206
        $operands[0] = "pqf=" . $QParser->target_syntax('biblioserver');
1207
# TODO: once we are using QueryParser, all this special case code for
1208
#       exploded search indexes will be replaced by a callback to
1209
#       _handle_exploding_index
1178
    }
1210
    }
1179
1211
1180
    return ( $operators, \@operands, $indexes, $limits, $sort_by, $scan, $lang);
1212
    return ( $operators, \@operands, $indexes, $limits, $sort_by, $scan, $lang, $query_desc);
1181
}
1213
}
1182
1214
1183
=head2 buildQuery
1215
=head2 buildQuery
Lines 1201-1207 sub buildQuery { Link Here
1201
1233
1202
    warn "---------\nEnter buildQuery\n---------" if $DEBUG;
1234
    warn "---------\nEnter buildQuery\n---------" if $DEBUG;
1203
1235
1204
    ( $operators, $operands, $indexes, $limits, $sort_by, $scan, $lang) = parseQuery($operators, $operands, $indexes, $limits, $sort_by, $scan, $lang);
1236
    my $query_desc;
1237
    ( $operators, $operands, $indexes, $limits, $sort_by, $scan, $lang, $query_desc) = parseQuery($operators, $operands, $indexes, $limits, $sort_by, $scan, $lang);
1205
1238
1206
    # dereference
1239
    # dereference
1207
    my @operators = $operators ? @$operators : ();
1240
    my @operators = $operators ? @$operators : ();
Lines 1229-1235 sub buildQuery { Link Here
1229
1262
1230
    # initialize the variables we're passing back
1263
    # initialize the variables we're passing back
1231
    my $query_cgi;
1264
    my $query_cgi;
1232
    my $query_desc;
1233
    my $query_type;
1265
    my $query_type;
1234
1266
1235
    my $limit;
1267
    my $limit;
Lines 1264-1270 sub buildQuery { Link Here
1264
        return ( undef, $', $', "q=cql=$'", $', '', '', '', '', 'cql' );
1296
        return ( undef, $', $', "q=cql=$'", $', '', '', '', '', 'cql' );
1265
    }
1297
    }
1266
    if ( $query =~ /^pqf=/ ) {
1298
    if ( $query =~ /^pqf=/ ) {
1267
        return ( undef, $', $', "q=pqf=$'", $', '', '', '', '', 'pqf' );
1299
        if ($query_desc) {
1300
            $query_cgi = "q=$query_desc";
1301
        } else {
1302
            $query_desc = $';
1303
            $query_cgi = "q=pqf=$'";
1304
        }
1305
        return ( undef, $', $', $query_cgi, $query_desc, '', '', '', '', 'pqf' );
1268
    }
1306
    }
1269
1307
1270
    # pass nested queries directly
1308
    # pass nested queries directly
(-)a/Koha/SuggestionEngine/Plugin/AuthorityFile.pm (-1 / +1 lines)
Lines 85-91 sub get_suggestions { Link Here
85
    # FIXME: calling into C4
85
    # FIXME: calling into C4
86
    require C4::AuthoritiesMarc;
86
    require C4::AuthoritiesMarc;
87
    my ( $searchresults, $count ) = C4::AuthoritiesMarc::SearchAuthorities(
87
    my ( $searchresults, $count ) = C4::AuthoritiesMarc::SearchAuthorities(
88
        \@marclist,  \@and_or, \@excluding,       \@operator,
88
        @marclist,  @and_or, @excluding,       @operator,
89
        @value,      0,        $param->{'count'}, '',
89
        @value,      0,        $param->{'count'}, '',
90
        'Relevance', 0
90
        'Relevance', 0
91
    );
91
    );
(-)a/cataloguing/addbooks.pl (-2 / +8 lines)
Lines 70-79 if ($query) { Link Here
70
70
71
    # build query
71
    # build query
72
    my @operands = $query;
72
    my @operands = $query;
73
    my ( $builterror,$builtquery,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$stopwords_removed,$query_type) = buildQuery(undef,\@operands);
73
74
    my $QParser;
75
    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
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);
78
        $query = $builtquery;
79
    }
74
80
75
    # find results
81
    # find results
76
    my ( $error, $marcresults, $total_hits ) = SimpleSearch($builtquery, $results_per_page * ($page - 1), $results_per_page);
82
    my ( $error, $marcresults, $total_hits ) = SimpleSearch($query, $results_per_page * ($page - 1), $results_per_page);
77
83
78
    if ( defined $error ) {
84
    if ( defined $error ) {
79
        $template->param( error => $error );
85
        $template->param( error => $error );
(-)a/cataloguing/value_builder/marc21_linking_section.pl (-1 / +9 lines)
Lines 190-196 sub plugin { Link Here
190
           my $startfrom      = $query->param('startfrom');
190
           my $startfrom      = $query->param('startfrom');
191
               my $resultsperpage = $query->param('resultsperpage') || 20;
191
               my $resultsperpage = $query->param('resultsperpage') || 20;
192
            my $orderby;
192
            my $orderby;
193
           $search = 'kw,wrdl=' . $search . ' and mc-itemtype=' . $itype if $itype;
193
            my $QParser;
194
            $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
195
            my $op;
196
            if ($QParser) {
197
                $op = '&&';
198
            } else {
199
                $op = 'and';
200
            }
201
           $search = 'kw:' . $search . " $op mc-itemtype:" . $itype if $itype;
194
               my ( $errors, $results, $total_hits ) =
202
               my ( $errors, $results, $total_hits ) =
195
                  SimpleSearch( $search, $startfrom * $resultsperpage,
203
                  SimpleSearch( $search, $startfrom * $resultsperpage,
196
                 $resultsperpage );
204
                 $resultsperpage );
(-)a/cataloguing/value_builder/unimarc_field_4XX.pl (-1 / +9 lines)
Lines 341-347 sub plugin { Link Here
341
        my $startfrom      = $query->param('startfrom');
341
        my $startfrom      = $query->param('startfrom');
342
        my $resultsperpage = $query->param('resultsperpage') || 20;
342
        my $resultsperpage = $query->param('resultsperpage') || 20;
343
        my $orderby;
343
        my $orderby;
344
        $search = 'kw,wrdl='.$search.' and mc-itemtype='.$itype if $itype;
344
        my $QParser;
345
        $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
346
        my $op;
347
        if ($QParser) {
348
            $op = '&&';
349
        } else {
350
            $op = 'and';
351
        }
352
        $search = 'kw:'.$search." $op mc-itemtype:".$itype if $itype;
345
        my ( $errors, $results, $total_hits ) = SimpleSearch($search, $startfrom * $resultsperpage, $resultsperpage );
353
        my ( $errors, $results, $total_hits ) = SimpleSearch($search, $startfrom * $resultsperpage, $resultsperpage );
346
        if (defined $errors ) {
354
        if (defined $errors ) {
347
            $results = [];
355
            $results = [];
(-)a/labels/label-item-search.pl (-6 / +19 lines)
Lines 66-75 my $display_columns = [ {_add => {label => "Add Item", link_fi Link Here
66
                      ];
66
                      ];
67
67
68
if ( $op eq "do_search" ) {
68
if ( $op eq "do_search" ) {
69
    my $QParser;
70
    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
69
    $idx         = $query->param('idx');
71
    $idx         = $query->param('idx');
70
    $ccl_textbox = $query->param('ccl_textbox');
72
    $ccl_textbox = $query->param('ccl_textbox');
71
    if ( $ccl_textbox && $idx ) {
73
    if ( $ccl_textbox && $idx ) {
72
        $ccl_query = "$idx=$ccl_textbox";
74
        $ccl_query = "$idx:$ccl_textbox";
73
    }
75
    }
74
76
75
    $datefrom = $query->param('datefrom');
77
    $datefrom = $query->param('datefrom');
Lines 77-91 if ( $op eq "do_search" ) { Link Here
77
79
78
    if ($datefrom) {
80
    if ($datefrom) {
79
        $datefrom = C4::Dates->new($datefrom);
81
        $datefrom = C4::Dates->new($datefrom);
80
        $ccl_query .= ' and ' if $ccl_textbox;
82
        if ($QParser) {
81
        $ccl_query .=
83
            $ccl_query .= ' && ' if $ccl_textbox;
82
          "acqdate,st-date-normalized,ge=" . $datefrom->output("iso");
84
            $ccl_query .=
85
                "acqdate(" . $datefrom->output("iso") . '-)';
86
        } else {
87
            $ccl_query .= ' and ' if $ccl_textbox;
88
            $ccl_query .=
89
                "acqdate,st-date-normalized,ge=" . $datefrom->output("iso");
90
        }
83
    }
91
    }
84
92
85
    if ($dateto) {
93
    if ($dateto) {
86
        $dateto = C4::Dates->new($dateto);
94
        $dateto = C4::Dates->new($dateto);
87
        $ccl_query .= ' and ' if ( $ccl_textbox || $datefrom );
95
        if ($QParser) {
88
        $ccl_query .= "acqdate,st-date-normalized,le=" . $dateto->output("iso");
96
            $ccl_query .= ' && ' if ( $ccl_textbox || $datefrom );
97
            $ccl_query .= "acqdate(-" . $dateto->output("iso") . ')';
98
        } else {
99
            $ccl_query .= ' and ' if ( $ccl_textbox || $datefrom );
100
            $ccl_query .= "acqdate,st-date-normalized,le=" . $datefrom->output("iso");
101
        }
89
    }
102
    }
90
103
91
    my $offset = $startfrom > 1 ? $startfrom - 1 : 0;
104
    my $offset = $startfrom > 1 ? $startfrom - 1 : 0;
(-)a/misc/migration_tools/bulkmarcimport.pl (-3 / +19 lines)
Lines 432-438 sub build_query { Link Here
432
	  my $string = build_simplequery($matchingpoint,$record);
432
	  my $string = build_simplequery($matchingpoint,$record);
433
	  push @searchstrings,$string if (length($string)>0);
433
	  push @searchstrings,$string if (length($string)>0);
434
        }
434
        }
435
	return join(" and ",@searchstrings);
435
    my $QParser;
436
    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
437
    my $op;
438
    if ($QParser) {
439
        $op = '&&';
440
    } else {
441
        $op = 'and';
442
    }
443
    return join(" $op ",@searchstrings);
436
}
444
}
437
sub build_simplequery {
445
sub build_simplequery {
438
	my $element=shift;
446
	my $element=shift;
Lines 442-451 sub build_simplequery { Link Here
442
        my @searchstrings;
450
        my @searchstrings;
443
        foreach my $field ($record->field($tag)){
451
        foreach my $field ($record->field($tag)){
444
		  if (length($field->as_string("$subfields"))>0){
452
		  if (length($field->as_string("$subfields"))>0){
445
          	push @searchstrings,"$index,wrdl=\"".$field->as_string("$subfields")."\"";
453
              push @searchstrings,"$index:\"".$field->as_string("$subfields")."\"";
446
		  }
454
		  }
447
        }
455
        }
448
	return join(" and ",@searchstrings);
456
    my $QParser;
457
    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
458
    my $op;
459
    if ($QParser) {
460
        $op = '&&';
461
    } else {
462
        $op = 'and';
463
    }
464
    return join(" $op ",@searchstrings);
449
}
465
}
450
sub report_item_errors {
466
sub report_item_errors {
451
    my $biblionumber = shift;
467
    my $biblionumber = shift;
(-)a/serials/subscription-bib-search.pl (-6 / +13 lines)
Lines 90-100 if ($op eq "do_search" && $query) { Link Here
90
    # add the itemtype limit if applicable
90
    # add the itemtype limit if applicable
91
    my $itemtypelimit = $input->param('itemtypelimit');
91
    my $itemtypelimit = $input->param('itemtypelimit');
92
    if ( $itemtypelimit ) {
92
    if ( $itemtypelimit ) {
93
	if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') {
93
        my $QParser;
94
	    $query .= " AND $itype_or_itemtype=$itemtypelimit";
94
        $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
95
	} else {
95
        my $op;
96
	    $query .= " AND $advanced_search_types=$itemtypelimit";
96
        if ($QParser) {
97
	}
97
            $op = '&&';
98
        } else {
99
            $op = 'and';
100
        }
101
        if (!$advanced_search_types or $advanced_search_types eq 'itemtypes') {
102
            $query .= " $op $itype_or_itemtype:$itemtypelimit";
103
        } else {
104
            $query .= " $op $advanced_search_types:$itemtypelimit";
105
        }
98
    }
106
    }
99
    $debug && warn $query;
107
    $debug && warn $query;
100
    $resultsperpage= $input->param('resultsperpage');
108
    $resultsperpage= $input->param('resultsperpage');
101
- 

Return to bug 9239