Bug 31471: Send multiple ISBN with 'OR' for FindDuplicate

When a record has multiple ISBNs the database stores them seperated by a
pipe

Zebra interprets a string like "isbn:1600213510 | 9781600213519" as an 'OR' search, but for
Elasticsearch we need to explicitly send "OR" - and Zebra support this
as well

To test:
1 - Make sure you are using Elasticsearch
2 - Cataloging->Add a new record from Z3950
3 - Choose target: LOC
4 - Search for: Control number: 14455023
5 - Import and save
6 - Search for the record again
7 - Import and save - duplicate check isn't been triggered
8 - Apply patch
9 - restart_all
10 - repeat 2-7
11 - this time you should get a duplicate notification
12 - Sitch SearchEngine syspref to 'Zebra'
13 - repeat 2-7
14 - Ensure you still get duplicate notification

Signed-off-by: Michaela Sieber <michaela.sieber@kit.edu>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
Nick Clemens 2023-02-24 14:04:34 +00:00 committed by Tomas Cohen Arazi
parent b93b6f3dde
commit 2dafd6f749
No known key found for this signature in database
GPG Key ID: 0A272EA1B2F3C15F
2 changed files with 22 additions and 2 deletions

View File

@ -96,6 +96,7 @@ sub FindDuplicate {
if ( $result->{isbn} ) {
$result->{isbn} =~ s/\(.*$//;
$result->{isbn} =~ s/\s+$//;
$result->{isbn} =~ s/\|/OR/;
$query = "isbn:$result->{isbn}";
}
else {

View File

@ -292,6 +292,15 @@ sub run_marc21_search_tests {
($biblionumber,undef,$title) = FindDuplicate($record);
is($biblionumber, 51, 'Found duplicate with ISBN');
$record = MARC::Record->new;
$record->add_fields(
[ '020', ' ', ' ', a => '0465039146' ],
[ '020', ' ', ' ', a => '9780465039142' ],
[ '245', '0', '0', a => 'Doesnt matter, searching isbn /' ]
);
($biblionumber,undef,$title) = FindDuplicate($record);
is($biblionumber, 48, 'Found duplicate with ISBN when two ISBNs in record');
$record = MARC::Record->new;
$record->add_fields(
@ -930,7 +939,7 @@ sub run_unimarc_search_tests {
}
subtest 'MARC21 + DOM' => sub {
plan tests => 93;
plan tests => 94;
run_marc21_search_tests();
};
@ -941,7 +950,7 @@ subtest 'UNIMARC + DOM' => sub {
subtest 'FindDuplicate' => sub {
plan tests => 6;
plan tests => 8;
Koha::Caches->get_instance('config')->flush_all;
t::lib::Mocks::mock_preference('marcflavour', 'MARC21' );
mock_GetMarcSubfieldStructure('MARC21');
@ -970,6 +979,13 @@ subtest 'FindDuplicate' => sub {
$record_3->add_fields(
[ '245', '0', '0', a => 'Frog and toad all year /' ]
);
my $record_4 = MARC::Record->new;
$record_4 ->add_fields(
[ '020', ' ', ' ', a => '9780307744432' ],
[ '020', ' ', ' ', a => '0307744434' ],
[ '100', '0', '0', a => 'Morgenstern, Erin' ],
[ '245', '0', '0', a => 'The night circus /' ]
);
foreach my $engine ('Zebra','Elasticsearch'){
t::lib::Mocks::mock_preference('searchEngine', $engine );
@ -982,6 +998,9 @@ subtest 'FindDuplicate' => sub {
warning_is { C4::Search::FindDuplicate($record_3);}
q/ti,ext:"Frog and toad all year \/"/,"Term correctly formed and passed to $engine";
warning_is { C4::Search::FindDuplicate($record_4);}
q/isbn:9780307744432 OR 0307744434/,"Term correctly formed and passed to $engine";
}
};