From 00d2959ac17d719af9cce1c320092e2fbed182a7 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Sat, 20 Oct 2007 19:12:14 +0200 Subject: [PATCH] Packages::Search: ignore empty keywords after stemming Stemming can output empty strings, e.g. for numbers. Ignore these. Reported by Cyril Jaquier --- lib/Packages/Search.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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); -- 2.39.2