Lines 55-60
use JSON qw( decode_json );
Link Here
|
55 |
use Try::Tiny; |
55 |
use Try::Tiny; |
56 |
use Pod::Usage; |
56 |
use Pod::Usage; |
57 |
use Getopt::Long; |
57 |
use Getopt::Long; |
|
|
58 |
use List::MoreUtils qw( natatime ); |
58 |
|
59 |
|
59 |
use C4::Context; |
60 |
use C4::Context; |
60 |
use Koha::Logger; |
61 |
use Koha::Logger; |
Lines 95-102
if ( $conn ) {
Link Here
|
95 |
} |
96 |
} |
96 |
); |
97 |
); |
97 |
} |
98 |
} |
98 |
my $biblio_indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::BIBLIOS_INDEX }); |
99 |
my $biblio_indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::BIBLIOS_INDEX } ); |
99 |
my $auth_indexer = Koha::SearchEngine::Indexer->new({ index => $Koha::SearchEngine::AUTHORITIES_INDEX }); |
100 |
my $auth_indexer = Koha::SearchEngine::Indexer->new( { index => $Koha::SearchEngine::AUTHORITIES_INDEX } ); |
|
|
101 |
my $config = $biblio_indexer->get_elasticsearch_params; |
102 |
my $at_a_time = $config->{chunk_size} // 5000; |
103 |
|
100 |
my @jobs = (); |
104 |
my @jobs = (); |
101 |
|
105 |
|
102 |
while (1) { |
106 |
while (1) { |
Lines 177-194
sub commit {
Link Here
|
177 |
} |
181 |
} |
178 |
|
182 |
|
179 |
if (@auth_records) { |
183 |
if (@auth_records) { |
180 |
try { |
184 |
my $auth_chunks = natatime $at_a_time, @auth_records; |
181 |
$auth_indexer->update_index( \@auth_records ); |
185 |
while ( ( my @auth_chunk = $auth_chunks->() ) ) { |
182 |
} catch { |
186 |
try { |
183 |
$logger->warn( sprintf "Update of elastic index failed with: %s", $_ ); |
187 |
$auth_indexer->update_index( \@auth_chunk ); |
184 |
}; |
188 |
} catch { |
|
|
189 |
$logger->warn( sprintf "Update of elastic index failed with: %s", $_ ); |
190 |
}; |
191 |
} |
185 |
} |
192 |
} |
186 |
if (@bib_records) { |
193 |
if (@bib_records) { |
187 |
try { |
194 |
my $biblio_chunks = natatime $at_a_time, @bib_records; |
188 |
$biblio_indexer->update_index( \@bib_records ); |
195 |
while ( ( my @bib_chunk = $biblio_chunks->() ) ) { |
189 |
} catch { |
196 |
try { |
190 |
$logger->warn( sprintf "Update of elastic index failed with: %s", $_ ); |
197 |
$biblio_indexer->update_index( \@bib_chunk ); |
191 |
}; |
198 |
} catch { |
|
|
199 |
$logger->warn( sprintf "Update of elastic index failed with: %s", $_ ); |
200 |
}; |
201 |
} |
192 |
} |
202 |
} |
193 |
|
203 |
|
194 |
# Finish |
204 |
# Finish |
195 |
- |
|
|