Partial fix for 2446: single word queries that were stopwords
authorJoshua Ferraro <jmf@liblime.com>
Fri, 8 Aug 2008 19:09:52 +0000 (14:09 -0500)
committerJoshua Ferraro <jmf@liblime.com>
Fri, 8 Aug 2008 19:09:52 +0000 (14:09 -0500)
weren't being striped out of the query

C4/Search.pm

index e350ff3..1509f49 100755 (executable)
@@ -33,7 +33,7 @@ BEGIN {
     $VERSION = 3.01;
     $DEBUG = ($ENV{DEBUG}) ? 1 : 0;
 }
-
+$DEBUG=1;
 =head1 NAME
 
 C4::Search - Functions for searching the Koha catalog.
@@ -702,11 +702,12 @@ sub _remove_stopwords {
         foreach ( keys %{ C4::Context->stopwords } ) {
             next if ( $_ =~ /(and|or|not)/ );    # don't remove operators
             if ( $operand =~
-                /(\P{IsAlpha}$_\P{IsAlpha}|^$_\P{IsAlpha}|\P{IsAlpha}$_$)/ )
+                /(\P{IsAlpha}$_\P{IsAlpha}|^$_\P{IsAlpha}|\P{IsAlpha}$_$|^$_$)/ )
             {
                 $operand =~ s/\P{IsAlpha}$_\P{IsAlpha}/ /gi;
                 $operand =~ s/^$_\P{IsAlpha}/ /gi;
                 $operand =~ s/\P{IsAlpha}$_$/ /gi;
+                               $operand =~ s/$1//gi;
                 push @stopwords_removed, $_;
             }
         }