From 8176df88a68811f0bbddd55b930543779e7c8f9d 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 ". 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 two words from a title, surrounded by double quotes. Like "Order of the Phoenix" 4) Check you get same results with an without patch --- C4/Search.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/C4/Search.pm b/C4/Search.pm index 811e6c1809..2ab5a528d9 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -963,6 +963,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.29.2