Bug 36678: Index fields with non-filing characters in both versions

Currently we only remove non-filing characters for sort fields, however, this can make searching difficult.
This patch adds the filing form to the index as well to aid in searching.

To test:
 0 - Setup Koha with Elasticsearch
 1 - Import the sample record on this report: "L'amour de l'art"
 2 - Search for "amour de l'art" - no results
 3 - Apply patch
 4 - Reindex
 5 - Search for "amour de l'art" - result!
 6 - Search for "title:amour de l'art" - result!

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Nick Clemens 2024-04-23 18:57:54 +00:00 committed by Katrin Fischer
parent 93a647fa90
commit 7c20263fd0
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834

View file

@ -520,7 +520,13 @@ sub _process_mappings {
$nonfiling_chars = looks_like_number($nonfiling_chars) ? int($nonfiling_chars) : 0;
# Nonfiling chars does not make sense for multiple values
# Only apply on first element
$values->[0] = substr $values->[0], $nonfiling_chars;
if ( $nonfiling_chars > 0 ) {
if ($sort) {
$values->[0] = substr $values->[0], $nonfiling_chars;
} else {
push @{$values}, substr $values->[0], $nonfiling_chars;
}
}
}
$values = [ grep(!/^$/, @{$values}) ];
@ -1196,12 +1202,10 @@ sub _get_marc_mapping_rules {
foreach my $indicator (keys %title_fields) {
foreach my $field_tag (@{$title_fields{$indicator}}) {
my $mappings = $rules->{data_fields}->{$field_tag}->{subfields}->{a} // [];
foreach my $mapping (@{$mappings}) {
if ($mapping->[0] =~ /__sort$/) {
# Mark this as to be processed for nonfiling characters indicator
# later on in _process_mappings
$mapping->[1]->{nonfiling_characters_indicator} = $indicator;
}
foreach my $mapping ( @{$mappings} ) {
# Mark this as to be processed for nonfiling characters indicator
# later on in _process_mappings
$mapping->[1]->{nonfiling_characters_indicator} = $indicator;
}
}
}