From b5ceced57697b97d727430c21fddd62c06830a51 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Sat, 4 Nov 2017 01:01:42 +0000 Subject: [PATCH] Bug 19580: Exclude period as splitting character for autotrunction To test: 0 - Apply Unit test patch only 1 - prove t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t 2 - Should fail 3 - Apply this patch 4 - prove t/db_dependent/Koha_SearchEngine_Elasticsearch_Search.t 5 - should pass 6 - search for 'Local-number.raw:"4"' (or a vlid biblionumber) 7 - should get expected result Signed-off-by: David Bourgault Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart Signed-off-by: Nick Clemens (cherry picked from commit 4538e6c4981b096f8ddcf4b235a7f9e2860ffe9b) Signed-off-by: Fridolin Somers --- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index b76d39a3f0..9e9b1a1db9 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -602,7 +602,7 @@ will have to wait for a real query parser. sub _convert_index_strings_freeform { my ( $self, $search ) = @_; while ( my ( $zeb, $es ) = each %index_field_convert ) { - $search =~ s/\b$zeb(?:,[\w-]*)?:/$es:/g; + $search =~ s/\b$zeb(?:,[\w\-]*)?:/$es:/g; } return $search; } @@ -797,7 +797,7 @@ sub _truncate_terms { # '"donald duck" title:"the mouse" and peter" get split into # ['', '"donald duck"', '', ' ', '', 'title:"the mouse"', '', ' ', 'and', ' ', 'pete'] - my @tokens = split /((?:[\w-]+:)?"[^"]+"|\s+)/, $query; + my @tokens = split /((?:[\w\-.]+:)?"[^"]+"|\s+)/, $query; # Filter out empty tokens my @words = grep { $_ !~ /^\s*$/ } @tokens; -- 2.39.5