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

(-)a/C4/Matcher.pm (-35 / +41 lines)
Lines 628-678 sub get_matches { Link Here
628
628
629
    my $QParser;
629
    my $QParser;
630
    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
630
    $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
631
    foreach my $matchpoint (@{ $self->{'matchpoints'} }) {
631
    foreach my $matchpoint ( @{ $self->{'matchpoints'} } ) {
632
        my @source_keys = _get_match_keys($source_record, $matchpoint);
632
        my @source_keys = _get_match_keys( $source_record, $matchpoint );
633
        next if scalar(@source_keys) == 0;
633
        next if scalar(@source_keys) == 0;
634
634
        # build query
635
        # build query
635
        my $query;
636
        my $query;
636
        my $error;
637
        my $error;
637
        my $searchresults;
638
        my $searchresults;
638
        my $total_hits;
639
        my $total_hits;
639
        if ($QParser) {
640
        if ( $self->{'record_type'} eq 'biblio' ) {
640
            $query = join(" || ", map { "$matchpoint->{'index'}:$_" } @source_keys);
641
            if ($QParser) {
642
                $query = join( " || ",
643
                    map { "$matchpoint->{'index'}:$_" } @source_keys );
644
            }
645
            else {
646
                $query = join( " or ",
647
                    map { "$matchpoint->{'index'}=$_" } @source_keys );
648
            }
641
            require C4::Search;
649
            require C4::Search;
642
            ($error, $searchresults, $total_hits) = C4::Search::SimpleSearch($query, 0, $max_matches, [ $self->{'record_type'} . 'server' ] );
650
            ( $error, $searchresults, $total_hits ) =
643
        } else {
651
              C4::Search::SimpleSearch( $query, 0, $max_matches );
644
            if ($self->{'record_type'} eq 'biblio') {
652
        }
645
                $query = join(" or ", map { "$matchpoint->{'index'}=$_" } @source_keys);
653
        elsif ( $self->{'record_type'} eq 'authority' ) {
646
                require C4::Search;
654
            my $authresults;
647
                ($error, $searchresults, $total_hits) = C4::Search::SimpleSearch($query, 0, $max_matches);
655
            my @marclist;
648
            } elsif ($self->{'record_type'} eq 'authority') {
656
            my @and_or;
649
                my $authresults;
657
            my @excluding = [];
650
                my @marclist;
658
            my @operator;
651
                my @and_or;
659
            my @value;
652
                my @excluding = [];
660
            foreach my $key (@source_keys) {
653
                my @operator;
661
                push @marclist, $matchpoint->{'index'};
654
                my @value;
662
                push @and_or,   'or';
655
                foreach my $key (@source_keys) {
663
                push @operator, 'exact';
656
                    push @marclist, $matchpoint->{'index'};
664
                push @value,    $key;
657
                    push @and_or, 'or';
665
            }
658
                    push @operator, 'exact';
666
            require C4::AuthoritiesMarc;
659
                    push @value, $key;
667
            ( $authresults, $total_hits ) =
660
                }
668
              C4::AuthoritiesMarc::SearchAuthorities(
661
                require C4::AuthoritiesMarc;
669
                \@marclist,  \@and_or, \@excluding, \@operator,
662
                ($authresults, $total_hits) = C4::AuthoritiesMarc::SearchAuthorities(
670
                \@value,     0,        20,          undef,
663
                        \@marclist, \@and_or, \@excluding, \@operator,
671
                'AuthidAsc', 1
664
                        \@value, 0, 20, undef, 'AuthidAsc', 1
672
              );
665
                        );
673
            foreach my $result (@$authresults) {
666
                foreach my $result (@$authresults) {
674
                push @$searchresults, $result->{'authid'};
667
                    push @$searchresults, $result->{'authid'};
668
                }
669
            }
675
            }
670
        }
676
        }
671
677
672
        if (defined $error ) {
678
        if ( defined $error ) {
673
            warn "search failed ($query) $error";
679
            warn "search failed ($query) $error";
674
        } else {
680
        }
675
            foreach my $matched (@{$searchresults}) {
681
        else {
682
            foreach my $matched ( @{$searchresults} ) {
676
                $matches{$matched} += $matchpoint->{'score'};
683
                $matches{$matched} += $matchpoint->{'score'};
677
            }
684
            }
678
        }
685
        }
679
- 

Return to bug 10230