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

(-)a/catalogue/search.pl (+27 lines)
Lines 373-382 if ($indexes[0] && (!$indexes[1] || $params->{'scan'})) { Link Here
373
my @operands = map uri_unescape($_), $cgi->multi_param('q');
373
my @operands = map uri_unescape($_), $cgi->multi_param('q');
374
374
375
# if a simple search, display the value in the search box
375
# if a simple search, display the value in the search box
376
my $basic_search = 0;
376
if ($operands[0] && !$operands[1]) {
377
if ($operands[0] && !$operands[1]) {
377
    my $ms_query = $operands[0];
378
    my $ms_query = $operands[0];
378
    $ms_query =~ s/ #\S+//;
379
    $ms_query =~ s/ #\S+//;
379
    $template->param(ms_value => $ms_query);
380
    $template->param(ms_value => $ms_query);
381
    $basic_search=1;
380
}
382
}
381
383
382
my $available;
384
my $available;
Lines 523-528 for (my $i=0;$i<@servers;$i++) { Link Here
523
    my $server = $servers[$i];
525
    my $server = $servers[$i];
524
    if ($server =~/biblioserver/) { # this is the local bibliographic server
526
    if ($server =~/biblioserver/) { # this is the local bibliographic server
525
        my $hits = $results_hashref->{$server}->{"hits"} // 0;
527
        my $hits = $results_hashref->{$server}->{"hits"} // 0;
528
        if ( $hits == 0 && $basic_search ){
529
            $operands[0] = '"'.$operands[0].'"'; #quote it
530
            ## I. BUILD THE QUERY
531
            (
532
                $error,             $query, $simple_query, $query_cgi,
533
                $query_desc,        $limit, $limit_cgi,    $limit_desc,
534
                $query_type
535
              )
536
              = $builder->build_query_compat( \@operators, \@operands, \@indexes, \@limits,
537
                \@sort_by, $scan, $lang, { weighted_fields => $weight_search, whole_record => $whole_record });
538
            my $quoted_results_hashref;
539
            eval {
540
                my $itemtypes = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
541
                ( $error, $quoted_results_hashref, $facets ) = $searcher->search_compat(
542
                    $query,            $simple_query, \@sort_by,       ['biblioserver'],
543
                    $results_per_page, $offset,       undef,           $itemtypes,
544
                    $query_type,       $scan
545
                );
546
            };
547
            my $quoted_hits = $quoted_results_hashref->{$server}->{"hits"} // 0;
548
            if ( $quoted_hits ){
549
                $results_hashref->{'biblioserver'} = $quoted_results_hashref->{'biblioserver'};
550
                $hits = $quoted_hits;
551
            }
552
        }
526
        my $page = $cgi->param('page') || 0;
553
        my $page = $cgi->param('page') || 0;
527
        my @newresults = searchResults({ 'interface' => 'intranet' }, $query_desc, $hits, $results_per_page, $offset, $scan,
554
        my @newresults = searchResults({ 'interface' => 'intranet' }, $query_desc, $hits, $results_per_page, $offset, $scan,
528
                                       $results_hashref->{$server}->{"RECORDS"});
555
                                       $results_hashref->{$server}->{"RECORDS"});
(-)a/opac/opac-search.pl (-1 / +31 lines)
Lines 419-428 my @operands = $cgi->multi_param('q'); Link Here
419
$template->{VARS}->{querystring} = join(' ', @operands);
419
$template->{VARS}->{querystring} = join(' ', @operands);
420
420
421
# if a simple search, display the value in the search box
421
# if a simple search, display the value in the search box
422
my $basic_search = 0;
422
if ($operands[0] && !$operands[1]) {
423
if ($operands[0] && !$operands[1]) {
423
    my $ms_query = $operands[0];
424
    my $ms_query = $operands[0];
424
    $ms_query =~ s/ #\S+//;
425
    $ms_query =~ s/ #\S+//;
425
    $template->param(ms_value => $ms_query);
426
    $template->param(ms_value => $ms_query);
427
    $basic_search=1;
426
}
428
}
427
429
428
# limits are use to limit to results to a pre-defined category such as branch or language
430
# limits are use to limit to results to a pre-defined category such as branch or language
Lines 608-613 for (my $i=0;$i<@servers;$i++) { Link Here
608
    my $server = $servers[$i];
610
    my $server = $servers[$i];
609
    if ($server && $server =~/biblioserver/) { # this is the local bibliographic server
611
    if ($server && $server =~/biblioserver/) { # this is the local bibliographic server
610
        $hits = $results_hashref->{$server}->{"hits"};
612
        $hits = $results_hashref->{$server}->{"hits"};
613
        if ( $hits == 0 && $basic_search ){
614
            $operands[0] = '"'.$operands[0].'"'; #quote it
615
            ## I. BUILD THE QUERY
616
            ( $error,$query,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type)
617
              = $builder->build_query_compat(
618
                \@operators,
619
                \@operands,
620
                \@indexes,
621
                \@limits,
622
                \@sort_by,
623
                0,
624
                $lang,
625
                {
626
                    suppress => $suppress,
627
                    is_opac => 1,
628
                    weighted_fields => $weight_search
629
                }
630
            );
631
            my $quoted_results_hashref;
632
            my $itemtypes_nocategory = { map { $_->{itemtype} => $_ } @{ Koha::ItemTypes->search_with_localization->unblessed } };
633
            eval {
634
                ($error, $quoted_results_hashref, $facets) = $searcher->search_compat($query,$simple_query,\@sort_by,\@servers,$results_per_page,$offset,undef,$itemtypes_nocategory,$query_type,$scan,1);
635
            };
636
            my $quoted_hits = $quoted_results_hashref->{$server}->{"hits"} // 0;
637
            if ( $quoted_hits ){
638
                $results_hashref->{'biblioserver'} = $quoted_results_hashref->{'biblioserver'};
639
                $hits = $quoted_hits;
640
            }
641
        }
611
        my $page = $cgi->param('page') || 0;
642
        my $page = $cgi->param('page') || 0;
612
        my @newresults = searchResults( $search_context, $query_desc, $hits, $results_per_page, $offset, $scan,
643
        my @newresults = searchResults( $search_context, $query_desc, $hits, $results_per_page, $offset, $scan,
613
                                        $results_hashref->{$server}->{"RECORDS"}, $variables);
644
                                        $results_hashref->{$server}->{"RECORDS"}, $variables);
614
- 

Return to bug 31213