From 093bf89f2d4b41a067b16f71ebbf4875c76b0ce5 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 8 Jul 2020 17:29:52 +0000 Subject: [PATCH] Bug 25957: Don't push blank field values to ES document MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To test: 1 - Load the sample DB or edit a record (using advanced cataloging editor) to have a blank subfield in a field that is indexed as suggestible 2 - For example 'author' / 100a 100 _ _ ‡a 3 - Index that record into Elasticsearch 5.X: perl misc/search_tools/rebuild_elasticsearch.pl -v -bn 115 -b -d 4 - Note error 'value must have length > 0' 5 - Edit mappings to set author 100a not suggestible 6 - perl misc/search_tools/rebuild_elasticsearch.pl -v -bn 115 -b -d 7 - Success 8 - Set field to suggestible again 9 - Apply patch 10 - perl misc/search_tools/rebuild_elasticsearch.pl -v -bn 115 -b -d 11 - Success! --- Koha/SearchEngine/Elasticsearch.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch.pm b/Koha/SearchEngine/Elasticsearch.pm index a43b864145..cff1248e19 100644 --- a/Koha/SearchEngine/Elasticsearch.pm +++ b/Koha/SearchEngine/Elasticsearch.pm @@ -485,7 +485,7 @@ sub _process_mappings { if (defined $options->{property}) { $_data = { $options->{property} => $_data - } + } if $_data; } if (defined $options->{nonfiling_characters_indicator}) { my $nonfiling_chars = $meta->{field}->indicator($options->{nonfiling_characters_indicator}); @@ -494,7 +494,7 @@ sub _process_mappings { $_data = substr $_data, $nonfiling_chars; } } - push @{$record_document->{$target}}, $_data; + push @{$record_document->{$target}}, $_data if $_data; } } -- 2.11.0