Lines 194-200
sub get_elasticsearch_mappings {
Link Here
|
194 |
my $marcflavour = lc C4::Context->preference('marcflavour'); |
194 |
my $marcflavour = lc C4::Context->preference('marcflavour'); |
195 |
$self->_foreach_mapping( |
195 |
$self->_foreach_mapping( |
196 |
sub { |
196 |
sub { |
197 |
my ( $name, $type, $facet, $suggestible, $sort, $search, $marc_type ) = @_; |
197 |
my ( $name, $type, $facet, $suggestible, $sort, $search, $filter, $marc_type ) = @_; |
198 |
return if $marc_type ne $marcflavour; |
198 |
return if $marc_type ne $marcflavour; |
199 |
# TODO if this gets any sort of complexity to it, it should |
199 |
# TODO if this gets any sort of complexity to it, it should |
200 |
# be broken out into its own function. |
200 |
# be broken out into its own function. |
Lines 291-297
sub raw_elasticsearch_mappings {
Link Here
|
291 |
marc_type => $marc_map->marc_type, |
291 |
marc_type => $marc_map->marc_type, |
292 |
marc_field => $marc_map->marc_field, |
292 |
marc_field => $marc_map->marc_field, |
293 |
sort => $marc_to_field->sort, |
293 |
sort => $marc_to_field->sort, |
294 |
suggestible => $marc_to_field->suggestible || '' |
294 |
suggestible => $marc_to_field->suggestible || '', |
|
|
295 |
filter => $marc_to_field->filter || '' |
295 |
}); |
296 |
}); |
296 |
|
297 |
|
297 |
} |
298 |
} |
Lines 381-387
sub reset_elasticsearch_mappings {
Link Here
|
381 |
facet => $mapping->{facet} || 0, |
382 |
facet => $mapping->{facet} || 0, |
382 |
suggestible => $mapping->{suggestible} || 0, |
383 |
suggestible => $mapping->{suggestible} || 0, |
383 |
sort => $mapping->{sort} // 1, |
384 |
sort => $mapping->{sort} // 1, |
384 |
search => $mapping->{search} // 1 |
385 |
search => $mapping->{search} // 1, |
|
|
386 |
filter => $mapping->{filter} // '' |
385 |
}); |
387 |
}); |
386 |
} |
388 |
} |
387 |
} |
389 |
} |
Lines 887-895
sub _array_to_marc {
Link Here
|
887 |
return $record; |
889 |
return $record; |
888 |
} |
890 |
} |
889 |
|
891 |
|
890 |
=head2 _field_mappings($facet, $suggestible, $sort, $search, $target_name, $target_type, $range) |
892 |
=head2 _field_mappings($facet, $suggestible, $sort, $search, $filter, $target_name, $target_type, $range) |
891 |
|
893 |
|
892 |
my @mappings = _field_mappings($facet, $suggestible, $sort, $search, $target_name, $target_type, $range) |
894 |
my @mappings = _field_mappings( $facet, $suggestible, $sort, $search, $filter, $target_name, $target_type, $range ) |
893 |
|
895 |
|
894 |
Get mappings, an internal data structure later used by |
896 |
Get mappings, an internal data structure later used by |
895 |
L<_process_mappings($mappings, $data, $record_document, $meta)> to process MARC target |
897 |
L<_process_mappings($mappings, $data, $record_document, $meta)> to process MARC target |
Lines 947-953
be extracted.
Link Here
|
947 |
=cut |
949 |
=cut |
948 |
|
950 |
|
949 |
sub _field_mappings { |
951 |
sub _field_mappings { |
950 |
my ($_self, $facet, $suggestible, $sort, $search, $target_name, $target_type, $range) = @_; |
952 |
my ( $_self, $facet, $suggestible, $sort, $search, $filter, $target_name, $target_type, $range ) = @_; |
951 |
my %mapping_defaults = (); |
953 |
my %mapping_defaults = (); |
952 |
my @mappings; |
954 |
my @mappings; |
953 |
|
955 |
|
Lines 984-989
sub _field_mappings {
Link Here
|
984 |
}; |
986 |
}; |
985 |
} |
987 |
} |
986 |
|
988 |
|
|
|
989 |
if ( defined $filter && $filter eq 'punctuation' ) { |
990 |
$default_options->{value_callbacks} //= []; |
991 |
push @{ $default_options->{value_callbacks} }, sub { |
992 |
my ($value) = @_; |
993 |
|
994 |
# Trim punctuation marks from field |
995 |
$value =~ |
996 |
s/[\x00-\x1F,\x21-\x2F,\x3A-\x40,\x5B-\x60,\x7B-\x89,\x8B,\x8D,\x8F,\x90-\x99,\x9B,\x9D,\xA0-\xBF,\xD7,\xF7]//g; |
997 |
return $value; |
998 |
}; |
999 |
} |
1000 |
|
987 |
if ($search) { |
1001 |
if ($search) { |
988 |
my $mapping = [$target_name, $default_options]; |
1002 |
my $mapping = [$target_name, $default_options]; |
989 |
push @mappings, $mapping; |
1003 |
push @mappings, $mapping; |
Lines 1046-1052
sub _get_marc_mapping_rules {
Link Here
|
1046 |
}; |
1060 |
}; |
1047 |
|
1061 |
|
1048 |
$self->_foreach_mapping(sub { |
1062 |
$self->_foreach_mapping(sub { |
1049 |
my ($name, $type, $facet, $suggestible, $sort, $search, $marc_type, $marc_field) = @_; |
1063 |
my ($name, $type, $facet, $suggestible, $sort, $search, $filter, $marc_type, $marc_field) = @_; |
1050 |
return if $marc_type ne $marcflavour; |
1064 |
return if $marc_type ne $marcflavour; |
1051 |
|
1065 |
|
1052 |
if ($type eq 'sum') { |
1066 |
if ($type eq 'sum') { |
Lines 1110-1116
sub _get_marc_mapping_rules {
Link Here
|
1110 |
} |
1124 |
} |
1111 |
|
1125 |
|
1112 |
my $range = defined $3 ? $3 : undef; |
1126 |
my $range = defined $3 ? $3 : undef; |
1113 |
my @mappings = $self->_field_mappings($facet, $suggestible, $sort, $search, $name, $type, $range); |
1127 |
my @mappings = $self->_field_mappings($facet, $suggestible, $sort, $search, $filter, $name, $type, $range); |
1114 |
if ($field_tag < 10) { |
1128 |
if ($field_tag < 10) { |
1115 |
$rules->{control_fields}->{$field_tag} //= []; |
1129 |
$rules->{control_fields}->{$field_tag} //= []; |
1116 |
push @{$rules->{control_fields}->{$field_tag}}, @{clone(\@mappings)}; |
1130 |
push @{$rules->{control_fields}->{$field_tag}}, @{clone(\@mappings)}; |
Lines 1129-1135
sub _get_marc_mapping_rules {
Link Here
|
1129 |
} |
1143 |
} |
1130 |
elsif ($marc_field =~ $leader_regexp) { |
1144 |
elsif ($marc_field =~ $leader_regexp) { |
1131 |
my $range = defined $1 ? $1 : undef; |
1145 |
my $range = defined $1 ? $1 : undef; |
1132 |
my @mappings = $self->_field_mappings($facet, $suggestible, $sort, $search, $name, $type, $range); |
1146 |
my @mappings = $self->_field_mappings($facet, $suggestible, $sort, $search, $filter, $name, $type, $range); |
1133 |
push @{$rules->{leader}}, @{clone(\@mappings)}; |
1147 |
push @{$rules->{leader}}, @{clone(\@mappings)}; |
1134 |
} |
1148 |
} |
1135 |
else { |
1149 |
else { |
Lines 1182-1188
sub _get_marc_mapping_rules {
Link Here
|
1182 |
|
1196 |
|
1183 |
$self->_foreach_mapping( |
1197 |
$self->_foreach_mapping( |
1184 |
sub { |
1198 |
sub { |
1185 |
my ( $name, $type, $facet, $suggestible, $sort, $marc_type, |
1199 |
my ( $name, $type, $facet, $suggestible, $sort, $search, $filter, $marc_type, |
1186 |
$marc_field ) |
1200 |
$marc_field ) |
1187 |
= @_; |
1201 |
= @_; |
1188 |
return unless $marc_type eq 'marc21'; |
1202 |
return unless $marc_type eq 'marc21'; |
Lines 1218-1223
should be sorted on. False if a) but not b). Undef if not a). This allows,
Link Here
|
1218 |
for example, author to be sorted on but not everything marked with "author" |
1232 |
for example, author to be sorted on but not everything marked with "author" |
1219 |
to be included in that sort. |
1233 |
to be included in that sort. |
1220 |
|
1234 |
|
|
|
1235 |
=item C<$search> |
1236 |
|
1237 |
True if this value should be searchable. |
1238 |
|
1239 |
=item C<$filter> |
1240 |
|
1241 |
Contains a string that represents a filter defined in the indexing code. Currently supports |
1242 |
the option 'punctuation' |
1243 |
|
1221 |
=item C<$marc_type> |
1244 |
=item C<$marc_type> |
1222 |
|
1245 |
|
1223 |
A string that indicates the MARC type that this mapping is for, e.g. 'marc21', |
1246 |
A string that indicates the MARC type that this mapping is for, e.g. 'marc21', |
Lines 1245-1250
sub _foreach_mapping {
Link Here
|
1245 |
'search_marc_to_fields.suggestible', |
1268 |
'search_marc_to_fields.suggestible', |
1246 |
'search_marc_to_fields.sort', |
1269 |
'search_marc_to_fields.sort', |
1247 |
'search_marc_to_fields.search', |
1270 |
'search_marc_to_fields.search', |
|
|
1271 |
'search_marc_to_fields.filter', |
1248 |
'search_marc_map.marc_type', |
1272 |
'search_marc_map.marc_type', |
1249 |
'search_marc_map.marc_field', |
1273 |
'search_marc_map.marc_field', |
1250 |
], |
1274 |
], |
Lines 1253-1258
sub _foreach_mapping {
Link Here
|
1253 |
'suggestible', |
1277 |
'suggestible', |
1254 |
'sort', |
1278 |
'sort', |
1255 |
'search', |
1279 |
'search', |
|
|
1280 |
'filter', |
1256 |
'marc_type', |
1281 |
'marc_type', |
1257 |
'marc_field', |
1282 |
'marc_field', |
1258 |
], |
1283 |
], |
Lines 1269-1274
sub _foreach_mapping {
Link Here
|
1269 |
$search_field->get_column('suggestible'), |
1294 |
$search_field->get_column('suggestible'), |
1270 |
$search_field->get_column('sort'), |
1295 |
$search_field->get_column('sort'), |
1271 |
$search_field->get_column('search'), |
1296 |
$search_field->get_column('search'), |
|
|
1297 |
$search_field->get_column('filter'), |
1272 |
$search_field->get_column('marc_type'), |
1298 |
$search_field->get_column('marc_type'), |
1273 |
$search_field->get_column('marc_field'), |
1299 |
$search_field->get_column('marc_field'), |
1274 |
); |
1300 |
); |