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 394-414 sub decode_record_from_result { Link Here
394
    # Result is passed in as array, will get flattened
394
    # Result is passed in as array, will get flattened
395
    # and first element will be $result
395
    # and first element will be $result
396
    my ( $self, $result ) = @_;
396
    my ( $self, $result ) = @_;
397
    if ($result->{marc_format} eq 'base64ISO2709') {
397
    if ( $result->{marc_format} eq 'base64ISO2709' ) {
398
        return MARC::Record->new_from_usmarc(decode_base64($result->{marc_data}));
398
        return MARC::Record->new_from_usmarc( decode_base64( $result->{marc_data} ) );
399
    }
399
    } elsif ( $result->{marc_format} eq 'MARCXML' ) {
400
    elsif ($result->{marc_format} eq 'MARCXML') {
400
        return MARC::Record->new_from_xml( $result->{marc_data}, 'UTF-8', uc C4::Context->preference('marcflavour') );
401
        return MARC::Record->new_from_xml($result->{marc_data}, 'UTF-8', uc C4::Context->preference('marcflavour'));
401
    } elsif ( $result->{marc_format} eq 'MARCXML_COMPRESSED' ) {
402
    }
403
    elsif ($result->{marc_format} eq 'MARCXML_COMPRESSED') {
404
        my $inflate = inflateInit();
402
        my $inflate = inflateInit();
405
        my $marcxml = $inflate->inflate( decode_base64( $result->{marc_data} ) );
403
        my $marcxml = $inflate->inflate( decode_base64( $result->{marc_data} ) );
406
        return MARC::Record->new_from_xml( $marcxml, 'UTF-8', uc C4::Context->preference('marcflavour') );
404
        return MARC::Record->new_from_xml( $marcxml, 'UTF-8', uc C4::Context->preference('marcflavour') );
407
    }
405
    } elsif ( $result->{marc_format} eq 'ARRAY' ) {
408
    elsif ($result->{marc_format} eq 'ARRAY') {
406
        return $self->_array_to_marc( $result->{marc_data_array} );
409
        return $self->_array_to_marc($result->{marc_data_array});
407
    } else {
410
    }
411
    else {
412
        Koha::Exceptions::Elasticsearch->throw("Missing marc_format field in Elasticsearch result");
408
        Koha::Exceptions::Elasticsearch->throw("Missing marc_format field in Elasticsearch result");
413
    }
409
    }
414
}
410
}
415
- 

Return to bug 38270