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

(-)a/C4/AuthoritiesMarc.pm (+1 lines)
Lines 1213-1218 sub GetAuthorizedHeading { Link Here
1213
    unless ($record = $args->{record}) {
1213
    unless ($record = $args->{record}) {
1214
        return unless $args->{authid};
1214
        return unless $args->{authid};
1215
        $record = GetAuthority($args->{authid});
1215
        $record = GetAuthority($args->{authid});
1216
        return unless $record;
1216
    }
1217
    }
1217
    if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
1218
    if (C4::Context->preference('marcflavour') eq 'UNIMARC') {
1218
# construct UNIMARC summary, that is quite different from MARC21 one
1219
# construct UNIMARC summary, that is quite different from MARC21 one
(-)a/C4/Search.pm (-16 / +25 lines)
Lines 253-258 sub SimpleSearch { Link Here
253
                    $query = $QParser->target_syntax($servers[$i]);
253
                    $query = $QParser->target_syntax($servers[$i]);
254
                    $zoom_queries[$i] = new ZOOM::Query::PQF( $query, $zconns[$i]);
254
                    $zoom_queries[$i] = new ZOOM::Query::PQF( $query, $zconns[$i]);
255
                } else {
255
                } else {
256
                    $query =~ s/:/=/g;
256
                    $zoom_queries[$i] = new ZOOM::Query::CCL2RPN( $query, $zconns[$i]);
257
                    $zoom_queries[$i] = new ZOOM::Query::CCL2RPN( $query, $zconns[$i]);
257
                }
258
                }
258
                $tmpresults[$i] = $zconns[$i]->search( $zoom_queries[$i] );
259
                $tmpresults[$i] = $zconns[$i]->search( $zoom_queries[$i] );
Lines 1117-1123 on authority data). Link Here
1117
=cut
1118
=cut
1118
1119
1119
sub _handle_exploding_index {
1120
sub _handle_exploding_index {
1120
    my ($QParser, $struct, $filter, $params, $negate, $server) = @_;
1121
    my ($QParser, $filter, $params, $negate, $server) = @_;
1121
    my $index = $filter;
1122
    my $index = $filter;
1122
    my $term = join(' ', @$params);
1123
    my $term = join(' ', @$params);
1123
1124
Lines 1127-1133 sub _handle_exploding_index { Link Here
1127
1128
1128
    my $codesubfield = $marcflavour eq 'UNIMARC' ? '5' : 'w';
1129
    my $codesubfield = $marcflavour eq 'UNIMARC' ? '5' : 'w';
1129
    my $wantedcodes = '';
1130
    my $wantedcodes = '';
1130
    my @subqueries = ( "su:\"$term\"");
1131
    my @subqueries = ( "\@attr 1=Subject \@attr 4=1 \"$term\"");
1131
    my ($error, $results, $total_hits) = SimpleSearch( "he:$term", undef, undef, [ "authorityserver" ] );
1132
    my ($error, $results, $total_hits) = SimpleSearch( "he:$term", undef, undef, [ "authorityserver" ] );
1132
    foreach my $auth (@$results) {
1133
    foreach my $auth (@$results) {
1133
        my $record = MARC::Record->new_from_usmarc($auth);
1134
        my $record = MARC::Record->new_from_usmarc($auth);
Lines 1142-1153 sub _handle_exploding_index { Link Here
1142
            }
1143
            }
1143
            foreach my $reference (@references) {
1144
            foreach my $reference (@references) {
1144
                my $codes = $reference->subfield($codesubfield);
1145
                my $codes = $reference->subfield($codesubfield);
1145
                push @subqueries, 'su:"' . $reference->as_string('abcdefghijlmnopqrstuvxyz') . '"' if (($codes && $codes eq $wantedcodes) || !$wantedcodes);
1146
                push @subqueries, '@attr 1=Subject @attr 4=1 "' . $reference->as_string('abcdefghijlmnopqrstuvxyz') . '"' if (($codes && $codes eq $wantedcodes) || !$wantedcodes);
1146
            }
1147
            }
1147
        }
1148
        }
1148
    }
1149
    }
1149
    my $query = '(' x scalar(@subqueries) . join(') || ', @subqueries) . ')';
1150
    my $query = ' @or ' x (scalar(@subqueries) - 1) . join(' ', @subqueries);
1150
    warn $query;
1151
    return $query;
1151
    return $query;
1152
}
1152
}
1153
1153
Lines 1179-1185 sub parseQuery { Link Here
1179
1179
1180
    my $QParser;
1180
    my $QParser;
1181
    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser') || $query =~ s/^qp=//);
1181
    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser') || $query =~ s/^qp=//);
1182
    undef $QParser if ($query =~ m/^(ccl=|pqf=|cql=)/ || grep (/\w,\w|\w=\w/, @operands) );
1182
    undef $QParser if ($query =~ m/^(ccl=|pqf=|cql=)/ || grep (/\w,\w|\w=\w/, @operands, @indexes) );
1183
    undef $QParser if (scalar @limits > 0);
1183
    undef $QParser if (scalar @limits > 0);
1184
1184
1185
    if ($QParser)
1185
    if ($QParser)
Lines 1189-1201 sub parseQuery { Link Here
1189
            next unless $operands[$ii];
1189
            next unless $operands[$ii];
1190
            $query .= $operators[ $ii - 1 ] eq 'or' ? ' || ' : ' && '
1190
            $query .= $operators[ $ii - 1 ] eq 'or' ? ' || ' : ' && '
1191
              if ($query);
1191
              if ($query);
1192
            $query .=
1192
            if ( $indexes[$ii] =~ m/su-/ ) {
1193
              ( $indexes[$ii] ? "$indexes[$ii]:" : '' ) . $operands[$ii];
1193
                $query .= $indexes[$ii] . '(' . $operands[$ii] . ')';
1194
            }
1195
            else {
1196
                $query .=
1197
                  ( $indexes[$ii] ? "$indexes[$ii]:" : '' ) . $operands[$ii];
1198
            }
1194
        }
1199
        }
1195
        foreach my $limit (@limits) {
1200
        foreach my $limit (@limits) {
1196
        }
1201
        }
1197
        if (scalar (@sort_by) > 0) {
1202
        if ( scalar(@sort_by) > 0 ) {
1198
            my $modifier_re = '#(' . join( '|', @{$QParser->modifiers}) . ')';
1203
            my $modifier_re =
1204
              '#(' . join( '|', @{ $QParser->modifiers } ) . ')';
1199
            $query =~ s/$modifier_re//g;
1205
            $query =~ s/$modifier_re//g;
1200
            foreach my $modifier (@sort_by) {
1206
            foreach my $modifier (@sort_by) {
1201
                $query .= " #$modifier";
1207
                $query .= " #$modifier";
Lines 1206-1217 sub parseQuery { Link Here
1206
        $query_desc =~ s/\s+/ /g;
1212
        $query_desc =~ s/\s+/ /g;
1207
        if ( C4::Context->preference("QueryWeightFields") ) {
1213
        if ( C4::Context->preference("QueryWeightFields") ) {
1208
        }
1214
        }
1209
        $QParser->add_bib1_filter_map( 'biblioserver', 'su-br', { 'callback' => \&_handle_exploding_index });
1215
        $QParser->add_bib1_filter_map( 'su-br' => 'biblioserver' =>
1210
        $QParser->add_bib1_filter_map( 'biblioserver', 'su-na', { 'callback' => \&_handle_exploding_index });
1216
              { 'target_syntax_callback' => \&_handle_exploding_index } );
1211
        $QParser->add_bib1_filter_map( 'biblioserver', 'su-rl', { 'callback' => \&_handle_exploding_index });
1217
        $QParser->add_bib1_filter_map( 'su-na' => 'biblioserver' =>
1212
        $QParser->parse( $query );
1218
              { 'target_syntax_callback' => \&_handle_exploding_index } );
1219
        $QParser->add_bib1_filter_map( 'su-rl' => 'biblioserver' =>
1220
              { 'target_syntax_callback' => \&_handle_exploding_index } );
1221
        $QParser->parse($query);
1213
        $operands[0] = "pqf=" . $QParser->target_syntax('biblioserver');
1222
        $operands[0] = "pqf=" . $QParser->target_syntax('biblioserver');
1214
    } else {
1223
    }
1224
    else {
1215
        require Koha::QueryParser::Driver::PQF;
1225
        require Koha::QueryParser::Driver::PQF;
1216
        my $modifier_re = '#(' . join( '|', @{Koha::QueryParser::Driver::PQF->modifiers}) . ')';
1226
        my $modifier_re = '#(' . join( '|', @{Koha::QueryParser::Driver::PQF->modifiers}) . ')';
1217
        s/$modifier_re//g for @operands;
1227
        s/$modifier_re//g for @operands;
1218
- 

Return to bug 9239