- my $first_keyword = shift @tmp;
- @$keywords = @tmp;
-
- my $numres = 0;
- my %tmp_results;
- # fgrep is seriously faster than using perl
- open DESC, '-|', 'fgrep', '-n', '--', $first_keyword, $file
- or die "couldn't open $file: $!";
- LINE:
- while (<DESC>) {
- foreach my $k (@$keywords) {
- next LINE unless /\Q$k\E/;
- }
- /^(\d+)/;
- my $nr = $1;
- debug( "Matched line $_", 2) if DEBUG;
- my $result = $did2pkg->{$nr};
+ my $stemmer = Lingua::Stem->new();
+ my $stemmed_keywords = $stemmer->stem( @tmp );
+
+ my $db = Search::Xapian::Database->new( $dbpath );
+ 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);
+
+ my (@order, %tmp_results);
+ foreach my $match ( @matches ) {
+ my $id = $match->get_docid();
+ my $result = $did2pkg->{$id};
+