From 49c5acc5b9a47946b514c339fed33862d98e63d7 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 6 Nov 2017 17:14:34 +0000 Subject: [PATCH] Bug 19582: Use compat routines for searching authorities in auth_finder.pl To test: 1 - Enable Zebra 2 - Perform an auth search 3 - note results 4 - Enable ES 5 - Repeat search, note (likely) diff results 6 - Open a record in cataloging and use the button to launch auth search 7 - Perform same search as above, note results match for eiher engine selected 8 - NOTE: Disbale sorting for ES search - this will be dealt with in another report Signed-off-by: David Bourgault Signed-off-by: Nicolas Legrand Signed-off-by: Alex Arnaud Signed-off-by: Jonathan Druart --- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 1 + authorities/auth_finder.pl | 16 +++++++++++++--- .../prog/en/includes/auth-finder-search.inc | 2 +- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index 95cc86ab78..d950891175 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -435,6 +435,7 @@ sub build_authorities_query_compat { unless exists $koha_to_index_name->{$m}; } for ( my $i = 0 ; $i < @$value ; $i++ ) { + next unless $value->[$i]; #clean empty form values, ES doesn't like undefined searches push @searches, { where => $koha_to_index_name->{$marclist->[$i]}, diff --git a/authorities/auth_finder.pl b/authorities/auth_finder.pl index b484f03db3..4d6e61fc11 100755 --- a/authorities/auth_finder.pl +++ b/authorities/auth_finder.pl @@ -28,6 +28,8 @@ use C4::Context; use C4::AuthoritiesMarc; use C4::Acquisition; use C4::Koha; +use Koha::SearchEngine::Search; +use Koha::SearchEngine::QueryBuilder; use Koha::Authority::Types; @@ -69,10 +71,18 @@ if ( $op eq "do_search" ) { my $startfrom = $query->param('startfrom') || 0; my $resultsperpage = $query->param('resultsperpage') || 20; + my $builder = Koha::SearchEngine::QueryBuilder->new( + { index => $Koha::SearchEngine::AUTHORITIES_INDEX } ); + my $searcher = Koha::SearchEngine::Search->new( + { index => $Koha::SearchEngine::AUTHORITIES_INDEX } ); + my $search_query = $builder->build_authorities_query_compat( + \@marclist, \@and_or, \@excluding, \@operator, + \@value, $authtypecode, $orderby + ); + my $offset = $startfrom * $resultsperpage; my ( $results, $total ) = - SearchAuthorities( \@marclist, \@and_or, \@excluding, \@operator, \@value, - $startfrom * $resultsperpage, - $resultsperpage, $authtypecode, $orderby ); + $searcher->search_auth_compat( $search_query, $offset, + $resultsperpage ); # multi page display gestion my $displaynext = 0; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc index 22f9a75a87..78746cb002 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc @@ -92,7 +92,7 @@
  • - +