[B<-r|--reset>]
[B<-a|--authorities>]
[B<-b|--biblios>]
+[B<--desc>]
[B<-bn|--bnumber>]
[B<-ai|--authid>]
[B<-p|--processes>]
Index the biblios only. Combining this with B<-a> is the same as
specifying neither and so both get indexed.
+=item B<--desc>
+
+Index the records in descending id order. Intended to index newer record before older records.
+Default is to index in ascending order.
+Does not work with --bnumber or --authid
+
=item B<-bn|--bnumber>
Only index the supplied biblionumber, mostly for testing purposes. May be
=cut
use autodie;
-use Getopt::Long;
+use Getopt::Long qw( GetOptions );
use Koha::Script;
use C4::Context;
use Koha::MetadataRecord::Authority;
use Koha::SearchEngine::Elasticsearch;
use Koha::SearchEngine::Elasticsearch::Indexer;
use MARC::Field;
-use MARC::Record;
use Modern::Perl;
-use Pod::Usage;
+use Pod::Usage qw( pod2usage );
+use Try::Tiny qw( catch try );
my $verbose = 0;
my $commit = 5000;
my ($delete, $reset, $help, $man, $processes);
my ($index_biblios, $index_authorities);
my (@biblionumbers,@authids);
+my $desc;
$|=1; # flushes output
'r|reset' => \$reset,
'a|authorities' => \$index_authorities,
'b|biblios' => \$index_biblios,
- 'bn|bnumber=i' => \@biblionumbers,
- 'ai|authid=i' => \@authids,
+ 'desc' => \$desc,
+ 'bn|bnumber=i' => \@biblionumbers,
+ 'ai|authid=i' => \@authids,
'p|processes=i' => \$processes,
'v|verbose+' => \$verbose,
'h|help' => \$help,
}
# Fudge the commit count a bit to spread out the Elasticsearch commits
$commit *= 1 + 0.10 * $slice_index;
+ $commit = int( $commit );
_log(1, "Processing slice @{[$slice_index + 1]} of $slice_count\n");
$iterator_options{slice} = { index => $slice_index, count => $slice_count };
}
+if( $desc ){
+ $iterator_options{desc} = 1;
+}
+
my $next;
if ($index_biblios) {
_log(1, "Indexing biblios\n");
push @commit_buffer, $record;
if ( !( --$commit_count ) ) {
_log( 1, "Committing $commit records...\n" );
- my $response = $indexer->update_index( \@id_buffer, \@commit_buffer );
- _handle_response($response);
+ my $response;
+ try{
+ $response = $indexer->update_index( \@id_buffer, \@commit_buffer );
+ _handle_response($response);
+ _log( 1, "Commit complete\n" );
+ } catch {
+ _log(1,"Elasticsearch exception thrown: ".$_->type."\n");
+ _log(2,"Details: ".$_->details."\n");
+ };
$commit_count = $commit;
@id_buffer = ();
@commit_buffer = ();
- _log( 1, "Commit complete\n" );
}
}