From dd77d02ffb88df5801f88540db47ec80cbd8db1d Mon Sep 17 00:00:00 2001 From: Fridolin Somers Date: Tue, 30 Jun 2020 15:14:24 +0200 Subject: [PATCH] Bug 25900: trim spaces in search with Zebra and QueryWeightFields Search with Zebra and system preference QueryWeightFields on builds a query with surrounding double quotes : q=tree => q="tree". Therefore existing double quotes are replaced by a space : q="tree" => q=" tree ". Looks like the leading space breaks the search, 0 results. Experimented on Ubuntu Xenial and Bionic with Indexdata repository so Zebra version is 2.1.4. It might be specific to this version. Patch corrects by adding trim on operand after transforming quotes into spaces. Test plan : 1) Use Zebra searchengine and enable system preference QueryWeightFields 2) Go to advanced search 3) Search on title two words you know exists in title surrounded by double quotes, like "Order of the Phoenix" 4) With patch you get results, no results without patch --- C4/Search.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/C4/Search.pm b/C4/Search.pm index a9448e483b..fdfd9de533 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -961,6 +961,7 @@ sub _build_weighted_query { my $weight_fields = C4::Context->preference("QueryWeightFields") || 0; my $fuzzy_enabled = C4::Context->preference("QueryFuzzy") || 0; $operand =~ s/"/ /g; # Bug 7518: searches with quotation marks don't work + $operand =~ s/^\s+|\s+$//g; # Trim my $weighted_query .= "(rk=("; # Specifies that we're applying rank -- 2.27.0