Lines 313-319
sub marc_records_to_documents {
Link Here
|
313 |
my @record_documents; |
313 |
my @record_documents; |
314 |
|
314 |
|
315 |
sub _process_mappings { |
315 |
sub _process_mappings { |
316 |
my ($mappings, $data, $record_document) = @_; |
316 |
my ($mappings, $data, $record_document, $altscript) = @_; |
317 |
foreach my $mapping (@{$mappings}) { |
317 |
foreach my $mapping (@{$mappings}) { |
318 |
my ($target, $options) = @{$mapping}; |
318 |
my ($target, $options) = @{$mapping}; |
319 |
# Copy (scalar) data since can have multiple targets |
319 |
# Copy (scalar) data since can have multiple targets |
Lines 333-355
sub marc_records_to_documents {
Link Here
|
333 |
$options->{property} => $_data |
333 |
$options->{property} => $_data |
334 |
} |
334 |
} |
335 |
} |
335 |
} |
336 |
push @{$record_document->{$target}}, $_data; |
336 |
|
|
|
337 |
# For sort fields, index only a single field with concatenated values |
338 |
# and ignore alt script fields |
339 |
if ($target =~ /__sort$/) { |
340 |
if (!$altscript) { |
341 |
if (!@{$record_document->{$target}}) { |
342 |
push @{$record_document->{$target}}, $_data; |
343 |
} else { |
344 |
@{$record_document->{$target}}[0] .= " $_data"; |
345 |
} |
346 |
} |
347 |
} else { |
348 |
push @{$record_document->{$target}}, $_data; |
349 |
} |
337 |
} |
350 |
} |
338 |
} |
351 |
} |
339 |
foreach my $record (@{$records}) { |
352 |
foreach my $record (@{$records}) { |
340 |
my $record_document = {}; |
353 |
my $record_document = {}; |
341 |
my $mappings = $rules->{leader}; |
354 |
my $mappings = $rules->{leader}; |
342 |
if ($mappings) { |
355 |
if ($mappings) { |
343 |
_process_mappings($mappings, $record->leader(), $record_document); |
356 |
_process_mappings($mappings, $record->leader(), $record_document, 0); |
344 |
} |
357 |
} |
345 |
foreach my $field ($record->fields()) { |
358 |
foreach my $field ($record->fields()) { |
346 |
if($field->is_control_field()) { |
359 |
if ($field->is_control_field()) { |
347 |
my $mappings = $control_fields_rules->{$field->tag()}; |
360 |
my $mappings = $control_fields_rules->{$field->tag()}; |
348 |
if ($mappings) { |
361 |
if ($mappings) { |
349 |
_process_mappings($mappings, $field->data(), $record_document); |
362 |
_process_mappings($mappings, $field->data(), $record_document, 0); |
350 |
} |
363 |
} |
351 |
} |
364 |
} |
352 |
else { |
365 |
else { |
|
|
366 |
my $tag = $field->tag(); |
367 |
# Handle alternate scripts in MARC 21 |
368 |
my $altscript = 0; |
369 |
if ($marcflavour eq 'marc21' && $tag eq '880') { |
370 |
my $sub6 = $field->subfield('6'); |
371 |
if ($sub6 =~ /^(...)-\d+/) { |
372 |
$tag = $1; |
373 |
$altscript = 1; |
374 |
} |
375 |
} |
376 |
|
353 |
my $data_field_rules = $data_fields_rules->{$field->tag()}; |
377 |
my $data_field_rules = $data_fields_rules->{$field->tag()}; |
354 |
|
378 |
|
355 |
if ($data_field_rules) { |
379 |
if ($data_field_rules) { |