Bugzilla – Attachment 118577 Details for
Bug 27928
FindDuplicate is hardcoded to use Zebra
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27928: FindDuplicate shuold use simple_search_compat
Bug-27928-FindDuplicate-shuold-use-simplesearchcom.patch (text/plain), 4.39 KB, created by
Fridolin Somers
on 2021-03-22 10:24:54 UTC
(
hide
)
Description:
Bug 27928: FindDuplicate shuold use simple_search_compat
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2021-03-22 10:24:54 UTC
Size:
4.39 KB
patch
obsolete
>From 66096a7b2d0d71ab7ddb5d4a407437e520156c3f Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Thu, 11 Mar 2021 13:33:43 +0000 >Subject: [PATCH] Bug 27928: FindDuplicate shuold use simple_search_compat > >This patch switches from calling SimpleSearch directly to using the compat >method so that Elastic is used when it is the chosen search engine > >To test: > 1 - Set SearchEngine syspref to 'Zebra' > 2 - Add a suggestion with an existing title, e.g.: > 'E street shuffle' > 3 - Confirm you get a duplication warning > 4 - Change SearchEngine to ES > 5 - Repeat get same warning > 6 - sudo koha-zebra --stop > 'ps aux | grep zebra' to confirm they are stoped > 'sudo pkill -9 zebra' if they arent; > 7 - Repeat suggestion - no duplication warning (because zebra returns nothing) > 8 - Delete the suggestion > 9 - Apply patches >10 - Restart all the things, stop zebra >11 - Repeat suggestion >12 - Successful warning from ES >13 - prove -v t/db_dependent/Search.t > >Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com> >--- > C4/Search.pm | 5 +++-- > t/db_dependent/Search.t | 45 +++++++++++++++++++++++++---------------- > 2 files changed, 31 insertions(+), 19 deletions(-) > >diff --git a/C4/Search.pm b/C4/Search.pm >index 4413211849..c2c8d4ecea 100644 >--- a/C4/Search.pm >+++ b/C4/Search.pm >@@ -115,8 +115,9 @@ sub FindDuplicate { > $query .= " $op $authorindex:\"$result->{author}\""; > } > } >- >- my ( $error, $searchresults, undef ) = SimpleSearch($query); # FIXME :: hardcoded ! >+ >+ my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX}); >+ my ( $error, $searchresults, undef ) = $searcher->simple_search_compat($query,0,50); > my @results; > if (!defined $error) { > foreach my $possible_duplicate_record (@{$searchresults}) { >diff --git a/t/db_dependent/Search.t b/t/db_dependent/Search.t >index 3b4e6d38dc..10c44c9592 100755 >--- a/t/db_dependent/Search.t >+++ b/t/db_dependent/Search.t >@@ -923,37 +923,48 @@ subtest 'UNIMARC + DOM' => sub { > > > subtest 'FindDuplicate' => sub { >- plan tests => 3; >+ plan tests => 6; > Koha::Caches->get_instance('config')->flush_all; > t::lib::Mocks::mock_preference('marcflavour', 'marc21' ); > mock_GetMarcSubfieldStructure('marc21'); >- my $searcher = Test::MockModule->new('C4::Search'); >- $searcher->mock('SimpleSearch', sub { >+ my $z_searcher = Test::MockModule->new('C4::Search'); >+ $z_searcher->mock('SimpleSearch', sub { >+ warn shift @_; >+ return 1; >+ }); >+ my $e_searcher = Test::MockModule->new('Koha::SearchEngine::Elasticsearch::Search'); >+ $e_searcher->mock('simple_search_compat', sub { >+ shift @_; > warn shift @_; > return 1; > }); > >- my $record = MARC::Record->new; >- $record->add_fields( >+ my $record_1 = MARC::Record->new; >+ $record_1 ->add_fields( > [ '100', '0', '0', a => 'Morgenstern, Erin' ], > [ '245', '0', '0', a => 'The night circus /' ] > ); >- warning_is { C4::Search::FindDuplicate($record);} >- q/ti,ext:"The night circus \/" and au,ext:"Morgenstern, Erin"/,"Term correctly formed"; >- >- $record = MARC::Record->new; >- $record->add_fields( >+ my $record_2 = MARC::Record->new; >+ $record_2 ->add_fields( > [ '245', '0', '0', a => 'The book of nothing /' ] > ); >- warning_is { C4::Search::FindDuplicate($record);} >- q/ti,ext:"The book of nothing \/"/,"Term correctly formed"; >- >- $record = MARC::Record->new; >- $record->add_fields( >+ my $record_3 = MARC::Record->new; >+ $record_3->add_fields( > [ '245', '0', '0', a => 'Frog and toad all year /' ] > ); >- warning_is { C4::Search::FindDuplicate($record);} >- q/ti,ext:"Frog and toad all year \/"/,"Term correctly formed"; >+ >+ foreach my $engine ('Zebra','Elasticsearch'){ >+ t::lib::Mocks::mock_preference('searchEngine', $engine ); >+ >+ warning_is { C4::Search::FindDuplicate($record_1);} >+ q/ti,ext:"The night circus \/" and au,ext:"Morgenstern, Erin"/,"Term correctly formed and passed to $engine"; >+ >+ warning_is { C4::Search::FindDuplicate($record_2);} >+ q/ti,ext:"The book of nothing \/"/,"Term correctly formed and passed to $engine"; >+ >+ warning_is { C4::Search::FindDuplicate($record_3);} >+ q/ti,ext:"Frog and toad all year \/"/,"Term correctly formed and passed to $engine"; >+ } > > }; > >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 27928
:
118120
|
118577
|
118816