@@ -, +, @@ indexes Can't locate object method "id" via package "MARC::Record" perl misc/search_tools/rebuild_elastic_search.pl -a -b -v perl misc/search_tools/rebuild_elastic_search.pl -b -v perl misc/search_tools/rebuild_elastic_search.pl -b -bn 42 -v --- Koha/BiblioUtils.pm | 14 +++++++++--- Koha/MetadataRecord/Authority.pm | 11 +++++++--- misc/search_tools/rebuild_elastic_search.pl | 33 +++++++---------------------- 3 files changed, 27 insertions(+), 31 deletions(-) --- a/Koha/BiblioUtils.pm +++ a/Koha/BiblioUtils.pm @@ -111,11 +111,19 @@ The iterator is a Koha::MetadataIterator object. =cut sub get_all_biblios_iterator { + my ( @biblionumbers ) = @_; my $database = Koha::Database->new(); my $schema = $database->schema(); - my $rs = - $schema->resultset('Biblio')->search( {}, - { columns => [qw/ biblionumber /] } ); + my $rs = $schema->resultset('Biblio')->search( + { + ( + @biblionumbers + ? ( biblionumber => { -in => \@biblionumbers } ) + : () + ) + }, + { columns => [qw/ biblionumber /] } + ); my $next_func = sub { # Warn and skip bad records, otherwise we break the loop while (1) { --- a/Koha/MetadataRecord/Authority.pm +++ a/Koha/MetadataRecord/Authority.pm @@ -167,11 +167,16 @@ The iterator is a Koha::MetadataIterator object. =cut sub get_all_authorities_iterator { + my ( @authid ) = @_; my $database = Koha::Database->new(); my $schema = $database->schema(); - my $rs = - $schema->resultset('AuthHeader')->search( { marcxml => { '!=', undef } }, - { columns => [qw/ authid authtypecode marcxml /] } ); + my $rs = $schema->resultset('AuthHeader')->search( + { + marcxml => { '!=', undef }, + ( @authid ? ( authid => { -in => \@authid } ) : () ) + }, + { columns => [qw/ authid authtypecode marcxml /] } + ); my $next_func = sub { my $row = $rs->next(); return if !$row; --- a/misc/search_tools/rebuild_elastic_search.pl +++ a/misc/search_tools/rebuild_elastic_search.pl @@ -124,35 +124,18 @@ sanity_check(); my $next; if ($index_biblios) { _log(1, "Indexing biblios\n"); - if (@biblionumbers) { - $next = sub { - my $r = shift @biblionumbers; - return () unless defined $r; - return ($r, Koha::BiblioUtils->get_from_biblionumber($r, item_data => 1 )); - }; - } else { - my $records = Koha::BiblioUtils->get_all_biblios_iterator(); - $next = sub { - $records->next(); - } - } + my $records = Koha::BiblioUtils->get_all_biblios_iterator( @biblionumbers ); + $next = sub { + $records->next(); + }; do_reindex($next, $Koha::SearchEngine::Elasticsearch::BIBLIOS_INDEX); } if ($index_authorities) { _log(1, "Indexing authorities\n"); - if (@biblionumbers) { - $next = sub { - my $r = shift @biblionumbers; - return () unless defined $r; - my $a = Koha::MetadataRecord::Authority->get_from_authid($r); - return ($r, $a->record); - }; - } else { - my $records = Koha::MetadataRecord::Authority->get_all_authorities_iterator(); - $next = sub { - $records->next(); - } - } + my $records = Koha::MetadataRecord::Authority->get_all_authorities_iterator( @biblionumbers ); + $next = sub { + $records->next(); + }; do_reindex($next, $Koha::SearchEngine::Elasticsearch::AUTHORITIES_INDEX); } --