From 7108ce311c1e34591024cd37483e83fd27e78c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= Date: Tue, 24 Nov 2020 19:19:04 +0200 Subject: [PATCH] Bug 11175: Search using double quotes to support Elasticsearch With Elasticsearch if you would use the search string here without the change to double quotes, i.e. (rcn='1234' AND cni='FI-XXX') OR rcn='FI-XXX 1234' then the search would somehow manage to return a record with 001 = 1234 and 003 = FI-XXX. Using double quotes prevents that. Also using parenthesis around the latter part of the OR seems to work: (rcn='1234' AND cni='FI-XXX') OR (rcn='FI-XXX 1234') --- Koha/Util/Search.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Koha/Util/Search.pm b/Koha/Util/Search.pm index 4e1c9706a8..c9d9f62e59 100644 --- a/Koha/Util/Search.pm +++ b/Koha/Util/Search.pm @@ -45,11 +45,11 @@ sub get_component_part_query { if (!defined($pf003)) { # search for 773$w='Host001' - $searchstr = "rcn='".$pf001->data()."'"; + $searchstr = "rcn=\"".$pf001->data()."\""; } else { # search for (773$w='Host001' and 003='Host003') or 773$w='Host003 Host001') - $searchstr = "(rcn='".$pf001->data()."' AND cni='".$pf003->data()."')"; - $searchstr .= " OR rcn='".$pf003->data()." ".$pf001->data()."'"; + $searchstr = "(rcn=\"".$pf001->data()."\" AND cni=\"".$pf003->data()."\")"; + $searchstr .= " OR rcn=\"".$pf003->data()." ".$pf001->data()."\""; } } } -- 2.17.1