Bug 23671: Elasticsearch shouldn't throw exception on an uppercase subfield identifier

Prevent Elasticsearch from throwing an exception when the mappings
include uppercase subfield identifier.

Though forbidden in MARC21, It doesn't seem to be the case for Unimarc
or ISO 2709 as a whole. It is also possible to define such a subfield
identifier in the Koha MARC Framework and in the Elasticsearch
mappings.

Test plan:

1. add a 995Z subfield identifier in Elasticsearch mappings
(Administration -> Search engine configuration)
2. run $KOHA_PATH/misc/search_tools/rebuild_elasticsearch.pl -v -d -b
3. see it throw: “Invalid MARC field expression: 995Z”
4. apply patch
5. rerun $KOHA_PATH/misc/search_tools/rebuild_elasticsearch.pl -v -d -b
6. sababa

Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Nicolas Legrand 2019-09-23 18:55:56 +02:00 committed by Martin Renvoize
parent 12d3331691
commit 7a80c94d96
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F

View file

@ -815,7 +815,7 @@ which is terribly slow.
sub _get_marc_mapping_rules {
my ($self) = @_;
my $marcflavour = lc C4::Context->preference('marcflavour');
my $field_spec_regexp = qr/^([0-9]{3})([()0-9a-z]+)?(?:_\/(\d+(?:-\d+)?))?$/;
my $field_spec_regexp = qr/^([0-9]{3})([()0-9a-zA-Z]+)?(?:_\/(\d+(?:-\d+)?))?$/;
my $leader_regexp = qr/^leader(?:_\/(\d+(?:-\d+)?))?$/;
my $rules = {
'leader' => [],