|
Lines 42-95
sub job_type {
Link Here
|
| 42 |
return 'update_elastic_index'; |
42 |
return 'update_elastic_index'; |
| 43 |
} |
43 |
} |
| 44 |
|
44 |
|
| 45 |
=head3 process |
45 |
# While most background jobs provide this method, the ES indexing has its own dedicated worker: |
| 46 |
|
46 |
# misc/workers/es_index_daemon.pl |
| 47 |
Process the modification. |
47 |
# That worker will handle all job processing. |
| 48 |
|
48 |
#=head3 process |
| 49 |
=cut |
49 |
# |
| 50 |
|
50 |
#Process the modification. |
| 51 |
sub process { |
51 |
# |
| 52 |
my ( $self, $args ) = @_; |
52 |
#=cut |
| 53 |
|
53 |
# |
| 54 |
$self->start; |
54 |
#sub process { |
| 55 |
|
55 |
#} |
| 56 |
my @record_ids = @{ $args->{record_ids} }; |
|
|
| 57 |
my $record_server = $args->{record_server}; |
| 58 |
|
| 59 |
my $report = { |
| 60 |
total_records => scalar @record_ids, |
| 61 |
total_success => 0, |
| 62 |
}; |
| 63 |
|
| 64 |
my @messages; |
| 65 |
eval { |
| 66 |
my $es_index = |
| 67 |
$record_server eq "authorityserver" |
| 68 |
? $Koha::SearchEngine::AUTHORITIES_INDEX |
| 69 |
: $Koha::SearchEngine::BIBLIOS_INDEX; |
| 70 |
my $indexer = Koha::SearchEngine::Indexer->new({ index => $es_index }); |
| 71 |
$indexer->update_index(\@record_ids); |
| 72 |
}; |
| 73 |
if ( $@ ) { |
| 74 |
warn $@; |
| 75 |
push @messages, { |
| 76 |
type => 'error', |
| 77 |
code => 'index_error', |
| 78 |
error => $@, |
| 79 |
|
| 80 |
} |
| 81 |
} else { |
| 82 |
$self->step; |
| 83 |
# FIXME This is not correct if some record_ids have been skipped |
| 84 |
$report->{total_success} = scalar @record_ids; |
| 85 |
} |
| 86 |
|
| 87 |
my $data = $self->decoded_data; |
| 88 |
$data->{messages} = \@messages; |
| 89 |
$data->{report} = $report; |
| 90 |
|
| 91 |
$self->finish( $data ); |
| 92 |
} |
| 93 |
|
56 |
|
| 94 |
=head3 enqueue |
57 |
=head3 enqueue |
| 95 |
|
58 |
|
| 96 |
- |
|
|