From: Frank Lichtenheld Date: Sat, 20 Oct 2007 17:12:14 +0000 (+0200) Subject: Packages::Search: ignore empty keywords after stemming X-Git-Url: https://git.deb.at/w?a=commitdiff_plain;h=00d2959ac17d719af9cce1c320092e2fbed182a7;p=deb%2Fpackages.git Packages::Search: ignore empty keywords after stemming Stemming can output empty strings, e.g. for numbers. Ignore these. Reported by Cyril Jaquier --- diff --git a/lib/Packages/Search.pm b/lib/Packages/Search.pm index d387267..be7bebd 100644 --- a/lib/Packages/Search.pm +++ b/lib/Packages/Search.pm @@ -209,10 +209,10 @@ sub do_xapian_search { push @tmp, $keyword; } my $stemmer = Lingua::Stem->new(); - my $stemmed_keywords = $stemmer->stem( @tmp ); + my @stemmed_keywords = grep { length($_) } @{$stemmer->stem( @tmp )}; my $db = Search::Xapian::Database->new( $dbpath ); - my $enq = $db->enquire( OP_OR, @$keywords, @$stemmed_keywords ); + my $enq = $db->enquire( OP_OR, @$keywords, @stemmed_keywords ); debug( "Xapian Query was: ".$enq->get_query()->get_description(), 1) if DEBUG; my @matches = $enq->matches(0, 999);