From a8b70f9473d535a10461e9da532c2c0a3985d69f Mon Sep 17 00:00:00 2001 From: Andreas Jonsson Date: Tue, 21 May 2024 09:29:29 +0200 Subject: [PATCH] Bug 36902: Filter year fields containing blanks Test plan: * If you are using koha-testing-docker, make sure that you have an elasticsearch container running (e.g., ku-es7) and that the searchengine system preference is set to ElasticSearch, and that the indexer is running (koha-es-indexer --start kohadev). * Under Koha administration -> Search engine configuration, make sure that the type of the field date-of-publication is set to 'year'. * If you needed to changed the type above, rebuild the index: koha-elasticsearch --delete --rebuild kohadev * Edit any record and change control field 008 position 7-10 (Date 1) to all blanks. * Save the record. * Show the elasticsearch record (Klick on "Show" in Elasticsearch record: Show") * Make sure there are no value "0000" for date-of-publication. * Edit the record again and change control field 008 position 7-10 (Date 1) to valid year. * Save the record. * Show the elasticsearch record. * Make sure there set year is present in the field date-of-publication. Signed-off-by: David Nind --- Koha/SearchEngine/Elasticsearch.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm index 531d410e5b..f3e035df19 100644 --- a/Koha/SearchEngine/Elasticsearch.pm +++ b/Koha/SearchEngine/Elasticsearch.pm @@ -1011,7 +1011,7 @@ sub _field_mappings { push @{$default_options->{value_callbacks}}, sub { my ($value) = @_; # Replace "u" with "0" for sorting - return map { s/[u\s]/0/gr } ( $value =~ /[0-9u\s]{4}/g ); + return map { /[0-9u]{4}/g } ( $value =~ s/u/0/gr ); }; } -- 2.39.2