From ded3e91a15eebb915a698f369c8caa692e8a2da7 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 3 Feb 2021 10:36:06 +0100 Subject: [PATCH] Bug 27597: Remove extra spaces in the generated query Look at the tests, sometime we have extra spaces. With this patch they still pass and the expected queries are better. Feel free to drop this patch if you have any concerns about it. --- Koha/SearchEngine/Elasticsearch/QueryBuilder.pm | 2 +- t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm index 174b93738a..6833abb024 100644 --- a/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm +++ b/Koha/SearchEngine/Elasticsearch/QueryBuilder.pm @@ -945,7 +945,7 @@ sub _clean_search_term { } # Remove unquoted colons that have whitespace on either side of them - $term =~ s/(:+)(\s+)$lookahead/$2/g; + $term =~ s/(:+)(\s+)$lookahead//g; $term =~ s/(\s+)(:+)$lookahead/$1/g; $term =~ s/^://; diff --git a/t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t b/t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t index b2ce6f4319..eb1d44d8a1 100755 --- a/t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t +++ b/t/Koha/SearchEngine/Elasticsearch/QueryBuilder.t @@ -208,10 +208,10 @@ subtest '_clean_search_term() tests' => sub { is($res, ' unbalanced quotes ', 'unbalanced quotes removed'); $res = $qb->_clean_search_term('test : query'); - is($res, 'test query', 'dangling colon removed'); + is($res, 'test query', 'dangling colon removed'); $res = $qb->_clean_search_term('test :: query'); - is($res, 'test query', 'dangling double colon removed'); + is($res, 'test query', 'dangling double colon removed'); $res = $qb->_clean_search_term('test "another : query"'); is($res, 'test "another : query"', 'quoted dangling colon not removed'); -- 2.20.1