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

(-)a/C4/Search.pm (-2 / +3 lines)
Lines 115-122 sub FindDuplicate { Link Here
115
            $query .= " $op $authorindex:\"$result->{author}\"";
115
            $query .= " $op $authorindex:\"$result->{author}\"";
116
        }
116
        }
117
    }
117
    }
118
118
 
119
    my ( $error, $searchresults, undef ) = SimpleSearch($query); # FIXME :: hardcoded !
119
    my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
120
    my ( $error, $searchresults, undef ) = $searcher->simple_search_compat($query,0,50);
120
    my @results;
121
    my @results;
121
    if (!defined $error) {
122
    if (!defined $error) {
122
        foreach my $possible_duplicate_record (@{$searchresults}) {
123
        foreach my $possible_duplicate_record (@{$searchresults}) {
(-)a/t/db_dependent/Search.t (-18 / +28 lines)
Lines 923-959 subtest 'UNIMARC + DOM' => sub { Link Here
923
923
924
924
925
subtest 'FindDuplicate' => sub {
925
subtest 'FindDuplicate' => sub {
926
    plan tests => 3;
926
    plan tests => 6;
927
    Koha::Caches->get_instance('config')->flush_all;
927
    Koha::Caches->get_instance('config')->flush_all;
928
    t::lib::Mocks::mock_preference('marcflavour', 'marc21' );
928
    t::lib::Mocks::mock_preference('marcflavour', 'marc21' );
929
    mock_GetMarcSubfieldStructure('marc21');
929
    mock_GetMarcSubfieldStructure('marc21');
930
    my $searcher = Test::MockModule->new('C4::Search');
930
    my $z_searcher = Test::MockModule->new('C4::Search');
931
    $searcher->mock('SimpleSearch', sub {
931
    $z_searcher->mock('SimpleSearch', sub {
932
        warn shift @_;
933
        return 1;
934
    });
935
    my $e_searcher = Test::MockModule->new('Koha::SearchEngine::Elasticsearch::Search');
936
    $e_searcher->mock('simple_search_compat', sub {
937
        shift @_;
932
        warn shift @_;
938
        warn shift @_;
933
        return 1;
939
        return 1;
934
    });
940
    });
935
941
936
    my $record = MARC::Record->new;
942
    my $record_1 = MARC::Record->new;
937
    $record->add_fields(
943
    $record_1 ->add_fields(
938
            [ '100', '0', '0', a => 'Morgenstern, Erin' ],
944
            [ '100', '0', '0', a => 'Morgenstern, Erin' ],
939
            [ '245', '0', '0', a => 'The night circus /' ]
945
            [ '245', '0', '0', a => 'The night circus /' ]
940
    );
946
    );
941
    warning_is { C4::Search::FindDuplicate($record);}
947
    my $record_2 = MARC::Record->new;
942
        q/ti,ext:"The night circus \/" and au,ext:"Morgenstern, Erin"/,"Term correctly formed";
948
    $record_2 ->add_fields(
943
944
    $record = MARC::Record->new;
945
    $record->add_fields(
946
            [ '245', '0', '0', a => 'The book of nothing /' ]
949
            [ '245', '0', '0', a => 'The book of nothing /' ]
947
    );
950
    );
948
    warning_is { C4::Search::FindDuplicate($record);}
951
    my $record_3 = MARC::Record->new;
949
        q/ti,ext:"The book of nothing \/"/,"Term correctly formed";
952
    $record_3->add_fields(
950
951
    $record = MARC::Record->new;
952
    $record->add_fields(
953
            [ '245', '0', '0', a => 'Frog and toad all year /' ]
953
            [ '245', '0', '0', a => 'Frog and toad all year /' ]
954
    );
954
    );
955
    warning_is { C4::Search::FindDuplicate($record);}
955
956
        q/ti,ext:"Frog and toad all year \/"/,"Term correctly formed";
956
    foreach my $engine ('Zebra','Elasticsearch'){
957
        t::lib::Mocks::mock_preference('searchEngine', $engine );
958
959
        warning_is { C4::Search::FindDuplicate($record_1);}
960
            q/ti,ext:"The night circus \/" and au,ext:"Morgenstern, Erin"/,"Term correctly formed and passed to $engine";
961
962
        warning_is { C4::Search::FindDuplicate($record_2);}
963
            q/ti,ext:"The book of nothing \/"/,"Term correctly formed and passed to $engine";
964
965
        warning_is { C4::Search::FindDuplicate($record_3);}
966
            q/ti,ext:"Frog and toad all year \/"/,"Term correctly formed and passed to $engine";
967
    }
957
968
958
};
969
};
959
970
960
- 

Return to bug 27928