From e9cb3483909a41fdb56b9115b32c7a3c1646cba5 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 23 Nov 2020 18:37:48 +0000 Subject: [PATCH] Bug 26957: Don't remove words that are also operators from search terms FindDuplicate has a hardcoded regex to remove 'and', 'or', and 'not' from any search fields, however, is does this with no regard for these terms being embedded in the middle of a word or phrase. E.g.: 'Coupland' becomes 'Coupl' 'Frog and toad' becomes 'frog toad' etc. This patch simplay removes the substitutions as we already quote the terms as well To test: 1 - Add records to your system like: The night circus by Erin Morgenstern Frog and toad all year Nothing ever happens 2 - Attempt to add purchase suggestions like title: the night circus, author:Morgenstern, Erin title: For and toad all year title:nothing ever happens (case is important) 3 - No warnings about existing biblios 4 - Apply patches 5 - Delete existing suggestions 6 - Repeat step 2 7 - Each attempt should warn you of existing biblio Signed-off-by: Fridolin Somers Signed-off-by: Martin Renvoize --- C4/Search.pm | 5 ----- 1 file changed, 5 deletions(-) diff --git a/C4/Search.pm b/C4/Search.pm index 811e6c1809..864d4bd11b 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -107,9 +107,6 @@ sub FindDuplicate { $result->{title} =~ s /\(//g; $result->{title} =~ s /\)//g; - # FIXME: instead of removing operators, could just do - # quotes around the value - $result->{title} =~ s/(and|or|not)//g; $query = "$titleindex:\"$result->{title}\""; if ( $result->{author} ) { $result->{author} =~ s /\\//g; @@ -117,8 +114,6 @@ sub FindDuplicate { $result->{author} =~ s /\(//g; $result->{author} =~ s /\)//g; - # remove valid operators - $result->{author} =~ s/(and|or|not)//g; $query .= " $op $authorindex:\"$result->{author}\""; } } -- 2.20.1