Lines 47-52
use MIME::Base64 qw( encode_base64 );
Link Here
|
47 |
use Encode qw( encode ); |
47 |
use Encode qw( encode ); |
48 |
use Business::ISBN; |
48 |
use Business::ISBN; |
49 |
use Scalar::Util qw( looks_like_number ); |
49 |
use Scalar::Util qw( looks_like_number ); |
|
|
50 |
use Compress::Zlib qw/deflateInit Z_BEST_COMPRESSION/; |
50 |
|
51 |
|
51 |
__PACKAGE__->mk_ro_accessors(qw( index index_name )); |
52 |
__PACKAGE__->mk_ro_accessors(qw( index index_name )); |
52 |
__PACKAGE__->mk_accessors(qw( sort_fields )); |
53 |
__PACKAGE__->mk_accessors(qw( sort_fields )); |
Lines 564-570
sub marc_records_to_documents {
Link Here
|
564 |
my $control_fields_rules = $rules->{control_fields}; |
565 |
my $control_fields_rules = $rules->{control_fields}; |
565 |
my $data_fields_rules = $rules->{data_fields}; |
566 |
my $data_fields_rules = $rules->{data_fields}; |
566 |
my $marcflavour = lc C4::Context->preference('marcflavour'); |
567 |
my $marcflavour = lc C4::Context->preference('marcflavour'); |
567 |
my $use_array = C4::Context->preference('ElasticsearchMARCFormat') eq 'ARRAY'; |
568 |
my $marcformat_syspref = C4::Context->preference('ElasticsearchMARCFormat'); |
568 |
|
569 |
|
569 |
my @record_documents; |
570 |
my @record_documents; |
570 |
|
571 |
|
Lines 805-813
sub marc_records_to_documents {
Link Here
|
805 |
|
806 |
|
806 |
# 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 |
807 |
$record->encoding('UTF-8'); |
808 |
$record->encoding('UTF-8'); |
808 |
if ($use_array) { |
809 |
if ($marcformat_syspref eq 'ARRAY') { |
809 |
$record_document->{'marc_data_array'} = $self->_marc_to_array($record); |
810 |
$record_document->{'marc_data_array'} = $self->_marc_to_array($record); |
810 |
$record_document->{'marc_format'} = 'ARRAY'; |
811 |
$record_document->{'marc_format'} = 'ARRAY'; |
|
|
812 |
} elsif ($marcformat_syspref eq 'MARCXML'){ |
813 |
$record_document->{'marc_data'} = $record->as_xml_record($marcflavour); |
814 |
$record_document->{'marc_format'} = 'MARCXML'; |
815 |
} elsif ($marcformat_syspref eq 'MARCXML_COMPRESSED'){ |
816 |
my $deflate = deflateInit( -Level => Z_BEST_COMPRESSION ); |
817 |
my $output = ""; |
818 |
if ($deflate) { |
819 |
my $input_xml = $record->as_xml_record($marcflavour); |
820 |
if ($input_xml) { |
821 |
my $compressed = $deflate->deflate($input_xml); |
822 |
$output .= $compressed; |
823 |
my $final = $deflate->flush(); |
824 |
$output .= $final; |
825 |
} |
826 |
} |
827 |
$record_document->{'marc_data'} = encode_base64($output); |
828 |
$record_document->{'marc_format'} = 'MARCXML_COMPRESSED'; |
811 |
} else { |
829 |
} else { |
812 |
my @warnings; |
830 |
my @warnings; |
813 |
{ |
831 |
{ |