View | Details | Raw Unified | Return to bug 25265
Collapse All | Expand All

(-)a/Koha/SearchEngine/Elasticsearch/Indexer.pm (-13 / +17 lines)
Lines 284-290 sub update_index_background { Link Here
284
284
285
=head2 index_records
285
=head2 index_records
286
286
287
This function takes an array of biblionumbers and fetches the records to send to update_index
287
This function takes an array of record numbers and fetches the records to send to update_index
288
for actual indexing.
288
for actual indexing.
289
289
290
If $records parameter is provided the records will be used as-is, this is only utilized for authorities
290
If $records parameter is provided the records will be used as-is, this is only utilized for authorities
Lines 296-326 to Zebra as well. Link Here
296
=cut
296
=cut
297
297
298
sub index_records {
298
sub index_records {
299
    my ( $self, $biblionumbers, $op, $server, $records ) = @_;
299
    my ( $self, $record_numbers, $op, $server, $records ) = @_;
300
    $biblionumbers = [$biblionumbers] if ref $biblionumbers ne 'ARRAY' && defined $biblionumbers;
300
    $record_numbers = [$record_numbers] if ref $record_numbers ne 'ARRAY' && defined $record_numbers;
301
    $records = [$records] if ref $records ne 'ARRAY' && defined $records;
301
    $records = [$records] if ref $records ne 'ARRAY' && defined $records;
302
    if ( $op eq 'specialUpdate' ) {
302
    if ( $op eq 'specialUpdate' ) {
303
        my $index_biblionumbers;
303
        my $index_record_numbers;
304
        unless ($records) {
304
        unless ($records) {
305
            foreach my $biblionumber ( @$biblionumbers ){
305
            foreach my $record_number ( @$record_numbers ){
306
                my $record = C4::Biblio::GetMarcBiblio({
306
                my $record = _get_record( $record_number, $server );
307
                    biblionumber => $biblionumber,
308
                    embed_items  => 1 });
309
                if( $record ){
307
                if( $record ){
310
                    push @$records, $record;
308
                    push @$records, $record;
311
                    push @$index_biblionumbers, $biblionumber;
309
                    push @$index_record_numbers, $record_number;
312
                }
310
                }
313
            }
311
            }
314
        }
312
        }
315
        $self->update_index_background( $index_biblionumbers, $records ) if $index_biblionumbers && $records;
313
        $self->update_index_background( $index_record_numbers, $records ) if $index_record_numbers && $records;
316
    }
314
    }
317
    elsif ( $op eq 'recordDelete' ) {
315
    elsif ( $op eq 'recordDelete' ) {
318
        $self->delete_index_background( $biblionumbers );
316
        $self->delete_index_background( $record_numbers );
319
    }
317
    }
320
    #FIXME Current behaviour is to index Zebra when using ES, at some point we should stop
318
    #FIXME Current behaviour is to index Zebra when using ES, at some point we should stop
321
    Koha::SearchEngine::Zebra::Indexer::index_records( $self, $biblionumbers, $op, $server, undef );
319
    Koha::SearchEngine::Zebra::Indexer::index_records( $self, $record_numbers, $op, $server, undef );
322
}
320
}
323
321
322
sub _get_record {
323
    my ( $id, $server ) = @_;
324
    return $server eq 'biblioserver'
325
        ? C4::Biblio::GetMarcBiblio({ biblionumber => $id, embed_items  => 1 })
326
        : C4::AuthoritiesMarc::GetAuthority($id);
327
} 
328
324
=head2 delete_index($biblionums)
329
=head2 delete_index($biblionums)
325
330
326
C<$biblionums> is an arrayref of biblionumbers to delete from the index.
331
C<$biblionums> is an arrayref of biblionumbers to delete from the index.
327
- 

Return to bug 25265