diff --git a/Koha/BiblioUtils.pm b/Koha/BiblioUtils.pm index cb7baed0db..5f438253f7 100644 --- a/Koha/BiblioUtils.pm +++ b/Koha/BiblioUtils.pm @@ -140,6 +140,11 @@ sub get_all_biblios_iterator { my $rs = Koha::Biblios->search( $search_terms, $search_options ); + + if ( my $sql = $options{where} ) { + $rs = $rs->search( \[$sql] ); + } + my $next_func = sub { # Warn and skip bad records, otherwise we break the loop while (1) { diff --git a/Koha/MetadataRecord/Authority.pm b/Koha/MetadataRecord/Authority.pm index ed0ebfc016..f616415d18 100644 --- a/Koha/MetadataRecord/Authority.pm +++ b/Koha/MetadataRecord/Authority.pm @@ -201,6 +201,11 @@ sub get_all_authorities_iterator { $schema->resultset('AuthHeader')->search( $search_terms, $search_options); + + if ( my $sql = $options{where} ) { + $rs = $rs->search( \[$sql] ); + } + my $next_func = sub { # Warn and skip bad records, otherwise we break the loop while (1) { diff --git a/misc/search_tools/rebuild_elasticsearch.pl b/misc/search_tools/rebuild_elasticsearch.pl index 337ac19dd2..58fa298830 100755 --- a/misc/search_tools/rebuild_elasticsearch.pl +++ b/misc/search_tools/rebuild_elasticsearch.pl @@ -34,6 +34,7 @@ B [B<--desc>] [B<-bn|--bnumber>] [B<-ai|--authid>] +[B<-w|--where SQL>] [B<-p|--processes>] [B<-v|--verbose>] [B<-h|--help>] @@ -87,6 +88,10 @@ repeated. Only index the supplied authority id, mostly for testing purposes. May be repeated. +=item B<-w|--where> + +Pass some additional SQL to limit the records to be indexed. + =item B<-p|--processes> Number of processes to use for indexing. This can be used to do more indexing @@ -128,7 +133,7 @@ my $verbose = 0; my $commit = 5000; my ($delete, $reset, $help, $man, $processes); my ($index_biblios, $index_authorities); -my (@biblionumbers,@authids); +my (@biblionumbers,@authids,$where); my $desc; $|=1; # flushes output @@ -142,6 +147,7 @@ GetOptions( 'desc' => \$desc, 'bn|bnumber=i' => \@biblionumbers, 'ai|authid=i' => \@authids, + 'w|where=s' => \$where, 'p|processes=i' => \$processes, 'v|verbose+' => \$verbose, 'h|help' => \$help, @@ -197,6 +203,10 @@ if( $desc ){ $iterator_options{desc} = 1; } +if ($where) { + $iterator_options{where} = $where; +} + my $next; if ($index_biblios) { _log(1, "Indexing biblios\n");