Lines 92-105
use MARC::Record;
Link Here
|
92 |
use Modern::Perl; |
92 |
use Modern::Perl; |
93 |
use Pod::Usage; |
93 |
use Pod::Usage; |
94 |
|
94 |
|
95 |
use Data::Dumper; # TODO remove |
|
|
96 |
|
97 |
my $verbose = 0; |
95 |
my $verbose = 0; |
98 |
my $commit = 5000; |
96 |
my $commit = 5000; |
99 |
my ($delete, $help, $man); |
97 |
my ($delete, $help, $man); |
100 |
my ($index_biblios, $index_authorities); |
98 |
my ($index_biblios, $index_authorities); |
101 |
my (@biblionumbers); |
99 |
my (@biblionumbers); |
102 |
|
100 |
|
|
|
101 |
$|=1; # flushes output |
102 |
|
103 |
GetOptions( |
103 |
GetOptions( |
104 |
'c|commit=i' => \$commit, |
104 |
'c|commit=i' => \$commit, |
105 |
'd|delete' => \$delete, |
105 |
'd|delete' => \$delete, |
Lines 161-170
sub do_reindex {
Link Here
|
161 |
|
161 |
|
162 |
my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new( { index => $index_name } ); |
162 |
my $indexer = Koha::SearchEngine::Elasticsearch::Indexer->new( { index => $index_name } ); |
163 |
if ($delete) { |
163 |
if ($delete) { |
164 |
|
|
|
165 |
# We know it's safe to not recreate the indexer because update_index |
166 |
# hasn't been called yet. |
167 |
$indexer->drop_index(); |
164 |
$indexer->drop_index(); |
|
|
165 |
$indexer->create_index(); |
168 |
} |
166 |
} |
169 |
|
167 |
|
170 |
my $count = 0; |
168 |
my $count = 0; |
Lines 173-195
sub do_reindex {
Link Here
|
173 |
while ( my $record = $next->() ) { |
171 |
while ( my $record = $next->() ) { |
174 |
my $id = $record->id; |
172 |
my $id = $record->id; |
175 |
my $record = $record->record; |
173 |
my $record = $record->record; |
176 |
_log( 1, "$id\n" ); |
|
|
177 |
$count++; |
174 |
$count++; |
|
|
175 |
if ( $verbose == 1 ) { |
176 |
_log( 1, "$count records processed\n" ) if ( $count % 1000 == 0); |
177 |
} else { |
178 |
_log( 2, "$id\n" ); |
179 |
} |
178 |
|
180 |
|
179 |
push @id_buffer, $id; |
181 |
push @id_buffer, $id; |
180 |
push @commit_buffer, $record; |
182 |
push @commit_buffer, $record; |
181 |
if ( !( --$commit_count ) ) { |
183 |
if ( !( --$commit_count ) ) { |
182 |
_log( 2, "Committing...\n" ); |
184 |
_log( 1, "Committing $commit records..." ); |
183 |
$indexer->update_index( \@id_buffer, \@commit_buffer ); |
185 |
$indexer->update_index( \@id_buffer, \@commit_buffer ); |
184 |
$commit_count = $commit; |
186 |
$commit_count = $commit; |
185 |
@id_buffer = (); |
187 |
@id_buffer = (); |
186 |
@commit_buffer = (); |
188 |
@commit_buffer = (); |
|
|
189 |
_log( 1, " done\n" ); |
187 |
} |
190 |
} |
188 |
} |
191 |
} |
189 |
|
192 |
|
190 |
# There are probably uncommitted records |
193 |
# There are probably uncommitted records |
|
|
194 |
_log( 1, "Committing final records...\n" ); |
191 |
$indexer->update_index( \@id_buffer, \@commit_buffer ); |
195 |
$indexer->update_index( \@id_buffer, \@commit_buffer ); |
192 |
_log( 1, "$count records indexed.\n" ); |
196 |
_log( 1, "Total $count records indexed\n" ); |
193 |
} |
197 |
} |
194 |
|
198 |
|
195 |
# Checks some basic stuff to ensure that it's sane before we start. |
199 |
# Checks some basic stuff to ensure that it's sane before we start. |
196 |
- |
|
|