Lines 21-26
use Carp qw( carp croak );
Link Here
|
21 |
use Modern::Perl; |
21 |
use Modern::Perl; |
22 |
use Try::Tiny qw( catch try ); |
22 |
use Try::Tiny qw( catch try ); |
23 |
use List::Util qw( any ); |
23 |
use List::Util qw( any ); |
|
|
24 |
use List::MoreUtils qw( natatime ); |
24 |
use base qw(Koha::SearchEngine::Elasticsearch); |
25 |
use base qw(Koha::SearchEngine::Elasticsearch); |
25 |
|
26 |
|
26 |
use Koha::Exceptions; |
27 |
use Koha::Exceptions; |
Lines 309-314
at the moment.
Link Here
|
309 |
The other variables are used for parity with Zebra indexing calls. Currently the calls are passed through |
310 |
The other variables are used for parity with Zebra indexing calls. Currently the calls are passed through |
310 |
to Zebra as well. |
311 |
to Zebra as well. |
311 |
|
312 |
|
|
|
313 |
Will obey the chunk_size defined in koha-conf for amount of records to send during a single reindex, or default |
314 |
to 5000. |
315 |
|
312 |
=cut |
316 |
=cut |
313 |
|
317 |
|
314 |
sub index_records { |
318 |
sub index_records { |
Lines 316-325
sub index_records {
Link Here
|
316 |
$record_numbers = [$record_numbers] if ref $record_numbers ne 'ARRAY' && defined $record_numbers; |
320 |
$record_numbers = [$record_numbers] if ref $record_numbers ne 'ARRAY' && defined $record_numbers; |
317 |
$records = [$records] if ref $records ne 'ARRAY' && defined $records; |
321 |
$records = [$records] if ref $records ne 'ARRAY' && defined $records; |
318 |
if ( $op eq 'specialUpdate' ) { |
322 |
if ( $op eq 'specialUpdate' ) { |
319 |
if ($records){ |
323 |
my $config = $self->get_elasticsearch_params; |
320 |
$self->update_index( $record_numbers, $records ); |
324 |
my $at_a_time = $config->{chunk_size} // 5000; |
|
|
325 |
my ( $record_chunks, $record_id_chunks ); |
326 |
$record_chunks = natatime $at_a_time, @$records if ($records); |
327 |
$record_id_chunks = natatime $at_a_time, @$record_numbers if ($record_numbers); |
328 |
if ($records) { |
329 |
while ( (my @records = $record_chunks->()) && (my @record_ids = $record_id_chunks->()) ) { |
330 |
$self->update_index( \@record_ids, \@records ); |
331 |
} |
321 |
} else { |
332 |
} else { |
322 |
$self->update_index_background( $record_numbers, $server ); |
333 |
while ( my @record_ids = $record_id_chunks->() ) { |
|
|
334 |
$self->update_index_background( \@record_ids, $server ); |
335 |
} |
323 |
} |
336 |
} |
324 |
} |
337 |
} |
325 |
elsif ( $op eq 'recordDelete' ) { |
338 |
elsif ( $op eq 'recordDelete' ) { |