Bug 12478: make things using SimpleSearch use the new version
authorRobin Sheat <robin@catalyst.net.nz>
Wed, 8 Jul 2015 04:34:12 +0000 (16:34 +1200)
committerTomas Cohen Arazi <tomascohen@theke.io>
Tue, 26 Apr 2016 12:57:47 +0000 (09:57 -0300)
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Jesse Weaver <jweaver@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

18 files changed:
C4/AuthoritiesMarc.pm
C4/Items.pm
C4/Matcher.pm
C4/XISBN.pm
Koha/ElasticSearch/Indexer.pm
Koha/SearchEngine.pm [new file with mode: 0644]
Koha/SearchEngine/Elasticsearch/Search.pm
acqui/neworderbiblio.pl
authorities/authorities-list.pl
cataloguing/value_builder/marc21_linking_section.pl
cataloguing/value_builder/unimarc_field_4XX.pl
circ/circulation.pl
installer/data/mysql/elasticsearch_mapping.sql
labels/label-item-search.pl
misc/migration_tools/bulkmarcimport.pl
misc/migration_tools/checkNonIndexedBiblios.pl
misc/migration_tools/remove_unused_authorities.pl
serials/subscription-bib-search.pl

index 82c53b4..dcfc4d1 100644 (file)
@@ -29,6 +29,9 @@ use C4::Log;
 use Koha::MetadataRecord::Authority;
 use Koha::Authorities;
 use Koha::Authority::Types;
+use Koha::Authority;
+use Koha::SearchEngine;
+use Koha::SearchEngine::Search;
 
 use vars qw(@ISA @EXPORT);
 
@@ -349,7 +352,10 @@ sub CountUsage {
         ### ZOOM search here
         my $query;
         $query= "an:".$authid;
-               my ($err,$res,$result) = C4::Search::SimpleSearch($query,0,10);
+        # Should really be replaced with a real count call, this is a
+        # bad way.
+        my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
+               my ($err,$res,$result) = $searcher->simple_search_compat($query,0,1);
         if ($err) {
             warn "Error: $err from search $query";
             $result = 0;
@@ -822,7 +828,8 @@ sub FindDuplicateAuthority {
             $_->[1]=~s/$filtervalues/ /g; $query.= " $op he:\"".$_->[1]."\"" if ($_->[0]=~/[A-z]/);
         }
     }
-    my ($error, $results, $total_hits) = C4::Search::SimpleSearch( $query, 0, 1, [ "authorityserver" ] );
+    my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::AUTHORITIES_INDEX});
+    my ($error, $results, $total_hits) = $searcher->simple_search_compat( $query, 0, 1 );
     # there is at least 1 result => return the 1st one
     if (!defined $error && @{$results} ) {
         my $marcrecord = C4::Search::new_record_from_zebra(
index 7f9a3da..c4f239b 100644 (file)
@@ -38,6 +38,8 @@ use Koha::DateUtils qw/dt_from_string/;
 use Koha::Database;
 
 use Koha::Database;
+use Koha::SearchEngine;
+use Koha::SearchEngine::Search;
 
 use vars qw(@ISA @EXPORT);
 
@@ -2601,12 +2603,12 @@ counts Usage of itemnumber in Analytical bibliorecords.
 
 sub GetAnalyticsCount {
     my ($itemnumber) = @_;
-    require C4::Search;
 
     ### ZOOM search here
     my $query;
     $query= "hi=".$itemnumber;
-            my ($err,$res,$result) = C4::Search::SimpleSearch($query,0,10);
+    my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
+    my ($err,$res,$result) = $searcher->simple_search_compat($query,0,10);
     return ($result);
 }
 
index 7d91cf2..b51d10e 100644 (file)
@@ -23,7 +23,8 @@ use warnings;
 use C4::Context;
 use MARC::Record;
 
-
+use Koha::SearchEngine;
+use Koha::SearchEngine::Search;
 
 =head1 NAME
 
@@ -655,10 +656,9 @@ sub get_matches {
                     #NOTE: double-quote the values so you don't get a "Embedded truncation not supported" error when a term has a ? in it.
             }
 
-            require C4::Search;
-
+            my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
             ( $error, $searchresults, $total_hits ) =
-              C4::Search::SimpleSearch( $query, 0, $max_matches );
+              $searcher->simple_search_compat( $query, 0, $max_matches );
         }
         elsif ( $self->{'record_type'} eq 'authority' ) {
             my $authresults;
index df31356..5512633 100644 (file)
@@ -26,6 +26,9 @@ use C4::External::Syndetics qw(get_syndetics_editions);
 use LWP::UserAgent;
 use HTTP::Request::Common;
 
+use Koha::SearchEngine;
+use Koha::SearchEngine::Search;
+
 use strict;
 #use warnings; FIXME - Bug 2505
 use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
@@ -63,7 +66,8 @@ sub _get_biblio_from_xisbn {
     my $xisbn = shift;
     my $dbh = C4::Context->dbh;
 
-    my ( $errors, $results, $total_hits ) = C4::Search::SimpleSearch( "nb=$xisbn", 0, 1 );
+    my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
+    my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat( "nb=$xisbn", 0, 1 );
     return unless ( !$errors && scalar @$results );
 
     my $record = C4::Search::new_record_from_zebra( 'biblioserver', $results->[0] );
index a8e8280..cc450dc 100644 (file)
@@ -96,6 +96,7 @@ it to be updated by a regular index cron job in the future.
 =cut
 
 sub update_index_background {
+    my $self = shift;
     $self->update_index(@_);
 }
 
diff --git a/Koha/SearchEngine.pm b/Koha/SearchEngine.pm
new file mode 100644 (file)
index 0000000..70ef799
--- /dev/null
@@ -0,0 +1,46 @@
+package Koha::SearchEngine;
+# This handles generic search-engine related functions
+
+# Copyright 2015 Catalyst IT
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with Koha; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+use Modern::Perl;
+use Readonly;
+
+=head1 NAME
+
+Koha::SearchEngine - non-engine-specific data and functions
+
+=head1 VARIABLES / CONSTANTS
+
+=head2 BIBLIOS_INDEX
+
+Use this constant when creating a new L<Koha::SearchEngine::Search> instance
+to indicate that you want to be working with the biblio index.
+
+=head2 AUTHORITIES_INDEX
+
+Use this constant when creating a new L<Koha::SearchEngine::Search> instance to
+indicate that you want to be working with the authorities index.
+
+=cut
+
+# Search engine implementations should compare against these to determine
+# what bit of storage is being requested. They will be sensible strings so
+# may be used for, e.g., directory names.
+Readonly our $BIBLIOS_INDEX     => 'biblios';
+Readonly our $AUTHORITIES_INDEX => 'authorities';
index 4218544..0738020 100644 (file)
@@ -38,6 +38,7 @@ Koha::SearchEngine::ElasticSearch::Search - search functions for Elasticsearch
 
 use base qw(Koha::ElasticSearch);
 use Koha::ItemTypes;
+use Koha::SearchEngine::QueryBuilder;
 
 use Catmandu::Store::ElasticSearch;
 
@@ -276,7 +277,7 @@ How many results to skip from the start of the results.
 
 =item C<$max_results>
 
-The max number of results to return. The default is 1,000 (because unlimited
+The max number of results to return. The default is 100 (because unlimited
 is a pretty terrible thing to do.)
 
 =back
@@ -313,9 +314,9 @@ sub simple_search_compat {
     $max_results //= 100;
 
     unless (ref $query) {
-        # We'll push it through the query builder
+        # We'll push it through the query builder to sanitise everything.
         my $qb = Koha::SearchEngine::QueryBuilder->new();
-        $query = $qb->build_query($query);
+        (undef,$query) = $qb->build_query_compat(undef, [$query]);
     }
     my $results = $self->search($query, undef, $max_results, %options);
     my @records;
index 4bd0827..9341fb5 100755 (executable)
@@ -68,6 +68,9 @@ use C4::Members qw/ GetMember /;
 use C4::Budgets qw/ GetBudgetHierarchy /;
 
 use Koha::Acquisition::Bookseller;
+use Koha::SearchEngine;
+use Koha::SearchEngine::Search;
+use Koha::SearchEngine::QueryBuilder;
 
 my $input = new CGI;
 
@@ -99,13 +102,14 @@ my @operands = $query;
 my $QParser;
 $QParser = C4::Context->queryparser if (C4::Context->preference('UseQueryParser'));
 my $builtquery;
+my $builder  = Koha::SearchEngine::QueryBuilder->new();
+my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
 if ($QParser) {
     $builtquery = $query;
 } else {
-    my ( $builterror,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type);
-    ( $builterror,$builtquery,$simple_query,$query_cgi,$query_desc,$limit,$limit_cgi,$limit_desc,$query_type) = buildQuery(undef,\@operands);
+    ( undef,$builtquery,undef,undef,undef,undef,undef,undef,undef,undef) = $builder->build_query_compat(undef,\@operands);
 }
-my ( $error, $marcresults, $total_hits ) = SimpleSearch( $builtquery, $results_per_page * ( $page - 1 ), $results_per_page );
+my ( $error, $marcresults, $total_hits ) = $searcher->simple_search_compat($builtquery, $results_per_page * ($page - 1), $results_per_page);
 
 if (defined $error) {
     $template->param(
index 2b15856..0afa5e7 100755 (executable)
@@ -5,6 +5,8 @@ use C4::Context;
 use C4::AuthoritiesMarc;
 use utf8;
 use open qw[ :std :encoding(utf8) ];
+use Koha::SearchEngine;
+use Koha::SearchEngine::Search;
 
 my $dbh=C4::Context->dbh;
 my $datatypes_query = $dbh->prepare(<<ENDSQL);
@@ -24,7 +26,8 @@ foreach my $authority (@$dataauthorities){
   my $query;
   $query= "an=".$authority->{'authid'};
   # search for biblios mapped
-  my ($err,$res,$used) = C4::Search::SimpleSearch($query,0,10);
+  my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
+  my ($err,undef,$used) = $searcher->simple_search_compat($query,0,1);
   if (defined $err) {
       $used = 0;
   }
index 61e21c7..33b7420 100755 (executable)
@@ -35,6 +35,9 @@ use C4::Branch;
 
 use Koha::ItemTypes;
 
+use Koha::SearchEngine;
+use Koha::SearchEngine::Search;
+
 my $builder = sub {
     my ( $params ) = @_;
     my $function_name = $params->{id};
@@ -179,8 +182,13 @@ my $launcher = sub {
         } else {
             $op = 'and';
         }
+        my $searcher = Koha::SearchEngine::Search->new(
+            { index => $Koha::SearchEngine::BIBLIOS_INDEX } );
         $search = 'kw:' . $search . " $op mc-itemtype:" . $itype if $itype;
-        my ( $errors, $results, $total_hits ) = SimpleSearch( $search, $startfrom * $resultsperpage, $resultsperpage );
+        my ( $errors, $results, $total_hits ) =
+          $searcher->simple_search_compat( $search,
+            $startfrom * $resultsperpage,
+            $resultsperpage );
         if ( defined $errors ) {
             $results = [];
         }
index f14a616..be299eb 100755 (executable)
@@ -35,6 +35,14 @@ use C4::Branch;    # GetBranches
 
 use Koha::ItemTypes;
 
+use Koha::SearchEngine;
+use Koha::SearchEngine::Search;
+
+sub plugin_parameters {
+    my ( $dbh, $record, $tagslib, $i, $tabloop ) = @_;
+    return "";
+}
+
 sub plugin_javascript {
     my ( $dbh, $record, $tagslib, $field_number, $tabloop ) = @_;
     my $function_name = $field_number;
@@ -361,7 +369,8 @@ sub plugin {
             $op = 'and';
         }
         $search = 'kw:'.$search." $op mc-itemtype:".$itype if $itype;
-        my ( $errors, $results, $total_hits ) = SimpleSearch($search, $startfrom * $resultsperpage, $resultsperpage );
+        my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
+        my ( $errors, $results, $total_hits ) = $searcher->simple_search_compat($search, $startfrom * $resultsperpage, $resultsperpage );
         if (defined $errors ) {
             $results = [];
         }
index 3a57685..7cf295f 100755 (executable)
@@ -49,6 +49,8 @@ use Koha::DateUtils;
 use Koha::Database;
 use Koha::Patron::Messages;
 use Koha::Patron::Images;
+use Koha::SearchEngine;
+use Koha::SearchEngine::Search;
 
 use Date::Calc qw(
   Today
@@ -353,8 +355,9 @@ if (@$barcodes) {
     {
      $template_params->{FALLBACK} = 1;
 
+        my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
         my $query = "kw=" . $barcode;
-        my ( $searcherror, $results, $total_hits ) = SimpleSearch($query);
+        my ( $searcherror, $results, $total_hits ) = $searcher->simple_search_compat($query, 0, 10);
 
         # if multiple hits, offer options to librarian
         if ( $total_hits > 0 ) {
index 1bb7da6..92717ee 100644 (file)
@@ -53,7 +53,7 @@ INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `m
 INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','rtype',FALSE,'','leader_/6',NULL,'leader_/6');
 INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','bib-level',FALSE,'','leader_/7',NULL,'leader_/7');
 INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','control-number',FALSE,'','001',NULL,'001');
-INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','local-number',FALSE,'string',NULL,'001',NULL);
+INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','Local-number',FALSE,'string',NULL,'001',NULL);
 INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','date-time-last-modified',FALSE,'','005','099d',NULL);
 INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','microform-generation',FALSE,'','007_/11',NULL,'007_/11');
 INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','material-type',FALSE,'','007','','007');
@@ -170,8 +170,8 @@ INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `m
 INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','subject',TRUE,'string','653a','610','653');
 INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','local-classification',FALSE,'','952o','995k','952o');
 INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','local-classification',FALSE,'',NULL,'686',NULL);
-INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','local-number',FALSE,'string','999c','001','999c');
-INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','local-number',FALSE,'string',NULL,'0909',NULL);
+INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','Local-number',FALSE,'string','999c','001','999c');
+INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','Local-number',FALSE,'string',NULL,'0909',NULL);
 INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','itype',TRUE,'string','942c','200b','942c');
 INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','itype',TRUE,'string','952y','995r','952y');
 INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','acqdate',FALSE,'date','952d','9955','952d');
@@ -230,7 +230,7 @@ INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `m
 INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('biblios','an',FALSE,'number',NULL,'6219',NULL);
 
 -- Authorities: incomplete
-INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('authorities','local-number',FALSE,'string','001',NULL,'001');
+INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('authorities','Local-number',FALSE,'string','001',NULL,'001');
 INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('authorities','authtype',FALSE,'','942a',NULL,'942a');
 INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('authorities','Kind-of-record',FALSE,'','008_/9',NULL,'008_/9');
 INSERT INTO `elasticsearch_mapping` (`indexname`, `mapping`, `facet`, `type`, `marc21`, `unimarc`, `normarc`) VALUES ('authorities','Descriptive-cataloging-rules',FALSE,'','008_/10',NULL,'008_/10');
index c2d218a..2ef5e15 100755 (executable)
@@ -29,6 +29,7 @@ use C4::Auth qw(get_template_and_user);
 use C4::Output qw(output_html_with_http_headers);
 use C4::Context;
 use C4::Search qw(SimpleSearch);
+use C4::Dates;
 use C4::Biblio qw(TransformMarcToKoha);
 use C4::Items qw(GetItemInfosOf get_itemnumbers_of);
 use C4::Koha qw(GetItemTypes);
@@ -36,6 +37,8 @@ use C4::Creators::Lib qw(html_table);
 use C4::Debug;
 use Koha::DateUtils;
 
+use Koha::SearchEngine::Search;
+
 BEGIN {
     $debug = $debug || $cgi_debug;
     if ($debug) {
@@ -107,14 +110,14 @@ if ( $op eq "do_search" ) {
     }
 
     my $offset = $startfrom > 1 ? $startfrom - 1 : 0;
-    ( $error, $marcresults, $total_hits ) =
-      SimpleSearch( $ccl_query, $offset, $resultsperpage );
+    my $searcher = Koha::SearchEngine::Search->new({index => 'biblios'});
+    ( $error, $marcresults, $total_hits ) = $searcher->simple_search_compat($ccl_query, $offset, $resultsperpage);
 
     if (!defined $error && @{$marcresults} ) {
         $show_results = @{$marcresults};
     }
     else {
-        $debug and warn "ERROR label-item-search: no results from SimpleSearch";
+        $debug and warn "ERROR label-item-search: no results from simple_search_compat";
 
         # leave $show_results undef
     }
index fc68e40..d007d29 100755 (executable)
@@ -31,6 +31,9 @@ use Getopt::Long;
 use IO::File;
 use Pod::Usage;
 
+use Koha::SearchEngine;
+use Koha::SearchEngine::Search;
+
 use open qw( :std :encoding(UTF-8) );
 binmode( STDOUT, ":encoding(UTF-8)" );
 my ( $input_marc_file, $number, $offset) = ('',0,0);
@@ -215,6 +218,17 @@ if ($logfile){
    $loghandle= IO::File->new($logfile, $writemode) ;
    print $loghandle "id;operation;status\n";
 }
+
+my $searcher = Koha::SearchEngine::Search->new(
+    {
+        index => (
+              $authorities
+            ? $Koha::SearchEngine::AUTHORITIES_INDEX
+            : $Koha::SearchEngine::BIBLIOS_INDEX
+        )
+    }
+);
+
 RECORD: while (  ) {
     my $record;
     # get records
@@ -268,7 +282,7 @@ RECORD: while (  ) {
         my $query = build_query( $match, $record );
         my $server = ( $authorities ? 'authorityserver' : 'biblioserver' );
         $debug && warn $query;
-        my ( $error, $results, $totalhits ) = C4::Search::SimpleSearch( $query, 0, 3, [$server] );
+        my ( $error, $results, $totalhits ) = $searcher->simple_search_compat( $query, 0, 3, [$server] );
         # changed to warn so able to continue with one broken record
         if ( defined $error ) {
             warn "unable to search the database for duplicates : $error";
index 4d58a13..bd47431 100755 (executable)
@@ -34,9 +34,10 @@ BEGIN {
 # Koha modules used
 use MARC::Record;
 use C4::Context;
-use C4::Search;
 use Getopt::Long;
 
+use Koha::SearchEngine::Search;
+
 my ( $help, $confirm, $zebraqueue, $silent,$stealth );
 
 GetOptions(
@@ -62,13 +63,14 @@ $| = 1;
 my $sth = $dbh->prepare("SELECT biblionumber FROM biblio");
 my $sth_insert = $dbh->prepare("INSERT INTO zebraqueue (biblio_auth_number,operation,server,done) VALUES (?,'specialUpdate','biblioserver',0)");
 
+my $searcher = Koha::SearchEngine::Search->new({index => 'biblios'});
+
 # We get all biblios
 $sth->execute;
 my ($nbhits);
-
 # We check for each biblio
 while ( my ($biblionumber) = $sth->fetchrow ) {
-    (undef,undef,$nbhits) = SimpleSearch("Local-number=$biblionumber");
+    (undef,undef,$nbhits) = $searcher->simple_search_compat("Local-number=$biblionumber");
     print "biblionumber $biblionumber not indexed\n" unless $nbhits || $stealth;
 # If -z option we put the biblio in zebraqueue
     if ($zebraqueue && !$nbhits){
@@ -105,4 +107,4 @@ Syntax:
 \t./batchCheckNonIndexedBiblios.pl -s (s like silent => don't throws a warn every 1000 biblios to show progress)
 \t./batchCheckNonIndexedBiblios.pl -st (s like stealth => don't throws a warn every 1000 biblios to show progress and no warn for the non indexed biblionumbers, just the total)
 _USAGE_
-}
\ No newline at end of file
+}
index eec2155..49bd1df 100755 (executable)
@@ -27,6 +27,8 @@ use C4::Context;
 use C4::AuthoritiesMarc;
 use Getopt::Long;
 
+use Koha::SearchEngine::Search;
+
 my @authtypes;
 my $want_help = 0;
 my $test = 0;
@@ -66,11 +68,12 @@ $rqselect->execute;
 my $counter=0;
 my $totdeleted=0;
 my $totundeleted=0;
+my $searcher = Koha::SearchEngine::Search->new({index => 'biblios'});
 while (my $data=$rqselect->fetchrow_hashref){
     my $query;
     $query= "an=".$data->{'authid'};
     # search for biblios mapped
-    my ($err,$res,$used) = C4::Search::SimpleSearch($query,0,10);
+    my ($err,$res,$used) = $searcher->simple_search_compat($query,0,10);
     if (defined $err) {
         warn "error: $err on search $query\n";
         next;
index 09530ca..8e44603 100755 (executable)
@@ -58,6 +58,9 @@ use C4::Search;
 use C4::Biblio;
 use C4::Debug;
 
+use Koha::SearchEngine;
+use Koha::SearchEngine::Search;
+
 my $input = new CGI;
 my $op = $input->param('op') || q{};
 my $dbh = C4::Context->dbh;
@@ -96,8 +99,9 @@ if ( $op eq "do_search" && $query ) {
     $resultsperpage = $input->param('resultsperpage');
     $resultsperpage = 20 if ( !defined $resultsperpage );
 
+    my $searcher = Koha::SearchEngine::Search->new({index => $Koha::SearchEngine::BIBLIOS_INDEX});
     my ( $error, $marcrecords, $total_hits ) =
-      SimpleSearch( $query, $startfrom * $resultsperpage, $resultsperpage );
+      $searcher->simple_search_compat( $query, $startfrom * $resultsperpage, $resultsperpage );
     my $total = 0;
     if ( defined $marcrecords ) {
         $total = scalar @{$marcrecords};