fixing case of only negated words
[Evergreen.git] / Open-ILS / src / perlmods / OpenILS / Application / Storage / Driver / Pg / fts.pm
index c6c64df..867ab52 100644 (file)
@@ -3,11 +3,12 @@
        #-------------------------------------------------------------------------------
        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);
 
                $self = ref($self) || $self;
                $self = bless {} => $self;
 
-               $term =~ s/\pM//gos;
+               $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);