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

(-)a/Koha/SearchEngine/Elasticsearch.pm (-8 / +8 lines)
Lines 806-818 sub marc_records_to_documents { Link Here
806
806
807
        # TODO: Perhaps should check if $records_document non empty, but really should never be the case
807
        # TODO: Perhaps should check if $records_document non empty, but really should never be the case
808
        $record->encoding('UTF-8');
808
        $record->encoding('UTF-8');
809
        if ($marcformat_syspref eq 'ARRAY') {
809
        if ( $marcformat_syspref eq 'ARRAY' ) {
810
            $record_document->{'marc_data_array'} = $self->_marc_to_array($record);
810
            $record_document->{'marc_data_array'} = $self->_marc_to_array($record);
811
            $record_document->{'marc_format'}     = 'ARRAY';
811
            $record_document->{'marc_format'}     = 'ARRAY';
812
        } elsif ($marcformat_syspref eq 'MARCXML'){
812
        } elsif ( $marcformat_syspref eq 'MARCXML' ) {
813
            $record_document->{'marc_data'}   = $record->as_xml_record($marcflavour);
813
            $record_document->{'marc_data'}   = $record->as_xml_record($marcflavour);
814
            $record_document->{'marc_format'} = 'MARCXML';
814
            $record_document->{'marc_format'} = 'MARCXML';
815
        } elsif ($marcformat_syspref eq 'MARCXML_COMPRESSED'){
815
        } elsif ( $marcformat_syspref eq 'MARCXML_COMPRESSED' ) {
816
            my $deflate = deflateInit( -Level => Z_BEST_COMPRESSION );
816
            my $deflate = deflateInit( -Level => Z_BEST_COMPRESSION );
817
            my $output  = "";
817
            my $output  = "";
818
            if ($deflate) {
818
            if ($deflate) {
Lines 833-851 sub marc_records_to_documents { Link Here
833
                local $SIG{__WARN__} = sub {
833
                local $SIG{__WARN__} = sub {
834
                    push @warnings, $_[0];
834
                    push @warnings, $_[0];
835
                };
835
                };
836
                $record_document->{'marc_data'} = encode_base64(encode('UTF-8', $record->as_usmarc()));
836
                $record_document->{'marc_data'} = encode_base64( encode( 'UTF-8', $record->as_usmarc() ) );
837
            }
837
            }
838
            if (@warnings) {
838
            if (@warnings) {
839
839
                # Suppress warnings if record length exceeded
840
                # Suppress warnings if record length exceeded
840
                unless (substr($record->leader(), 0, 5) eq '99999') {
841
                unless ( substr( $record->leader(), 0, 5 ) eq '99999' ) {
841
                    foreach my $warning (@warnings) {
842
                    foreach my $warning (@warnings) {
842
                        carp $warning;
843
                        carp $warning;
843
                    }
844
                    }
844
                }
845
                }
845
                $record_document->{'marc_data'} = $record->as_xml_record($marcflavour);
846
                $record_document->{'marc_data'}   = $record->as_xml_record($marcflavour);
846
                $record_document->{'marc_format'} = 'MARCXML';
847
                $record_document->{'marc_format'} = 'MARCXML';
847
            }
848
            } else {
848
            else {
849
                $record_document->{'marc_format'} = 'base64ISO2709';
849
                $record_document->{'marc_format'} = 'base64ISO2709';
850
            }
850
            }
851
        }
851
        }
(-)a/Koha/SearchEngine/Elasticsearch/Search.pm (-13 / +8 lines)
Lines 408-428 sub decode_record_from_result { Link Here
408
    # Result is passed in as array, will get flattened
408
    # Result is passed in as array, will get flattened
409
    # and first element will be $result
409
    # and first element will be $result
410
    my ( $self, $result ) = @_;
410
    my ( $self, $result ) = @_;
411
    if ($result->{marc_format} eq 'base64ISO2709') {
411
    if ( $result->{marc_format} eq 'base64ISO2709' ) {
412
        return MARC::Record->new_from_usmarc(decode_base64($result->{marc_data}));
412
        return MARC::Record->new_from_usmarc( decode_base64( $result->{marc_data} ) );
413
    }
413
    } elsif ( $result->{marc_format} eq 'MARCXML' ) {
414
    elsif ($result->{marc_format} eq 'MARCXML') {
414
        return MARC::Record->new_from_xml( $result->{marc_data}, 'UTF-8', uc C4::Context->preference('marcflavour') );
415
        return MARC::Record->new_from_xml($result->{marc_data}, 'UTF-8', uc C4::Context->preference('marcflavour'));
415
    } elsif ( $result->{marc_format} eq 'MARCXML_COMPRESSED' ) {
416
    }
417
    elsif ($result->{marc_format} eq 'MARCXML_COMPRESSED') {
418
        my $inflate = inflateInit();
416
        my $inflate = inflateInit();
419
        my $marcxml = $inflate->inflate( decode_base64( $result->{marc_data} ) );
417
        my $marcxml = $inflate->inflate( decode_base64( $result->{marc_data} ) );
420
        return MARC::Record->new_from_xml( $marcxml, 'UTF-8', uc C4::Context->preference('marcflavour') );
418
        return MARC::Record->new_from_xml( $marcxml, 'UTF-8', uc C4::Context->preference('marcflavour') );
421
    }
419
    } elsif ( $result->{marc_format} eq 'ARRAY' ) {
422
    elsif ($result->{marc_format} eq 'ARRAY') {
420
        return $self->_array_to_marc( $result->{marc_data_array} );
423
        return $self->_array_to_marc($result->{marc_data_array});
421
    } else {
424
    }
425
    else {
426
        Koha::Exceptions::Elasticsearch->throw("Missing marc_format field in Elasticsearch result");
422
        Koha::Exceptions::Elasticsearch->throw("Missing marc_format field in Elasticsearch result");
427
    }
423
    }
428
}
424
}
429
- 

Return to bug 38270