fixing case of only negated words
[Evergreen.git] / Open-ILS / src / perlmods / OpenILS / Application / Storage / Driver / Pg / fts.pm
index deaff9e..867ab52 100644 (file)
@@ -3,21 +3,30 @@
        #-------------------------------------------------------------------------------
        package OpenILS::Application::Storage::FTS;
        use OpenSRF::Utils::Logger qw/:level/;
+       use Unicode::Normalize;
        my $log = 'OpenSRF::Utils::Logger';
 
        sub compile {
                my $self = shift;
-               my $term = shift;
+               my $term = NFD(shift());
+
+               $log->debug("Raw term: $term",DEBUG);
+
+               $term =~ s/\&//go;
+               $term =~ s/\|//go;
 
                $self = ref($self) || $self;
                $self = bless {} => $self;
 
+               $term =~ s/(\pM+)//gos;
                $self->decompose($term);
 
-               my $newterm = join('&', $self->words);
+               my $newterm = '';
+               $newterm = join('&', $self->words) if ($self->words);
 
                if (@{$self->nots}) {
-                       $newterm = '('.$newterm.')&!('. join('|', $self->nots) . ')';
+                       $newterm = '('.$newterm.')&' if ($newterm);
+                       $newterm .= '!('. join('|', $self->nots) . ')';
                }
 
                $log->debug("Compiled term is [$newterm]", DEBUG);