-sub do_fulltext_search {
- my ($keyword, $file, $did2pkg, $packages, $read_entry, $opts) = @_;
- my @results;
-
- my @lines;
- my $regex;
- if ($opts->{case_bool}) {
- if ($opts->{exact}) {
- $regex = qr/\b\Q$keyword\E\b/o;
- } else {
- $regex = qr/\Q$keyword\E/o;
- }
- } else {
- if ($opts->{exact}) {
- $regex = qr/\b\Q$keyword\E\b/io;
- } else {
- $regex = qr/\Q$keyword\E/io;
+
+sub do_xapian_search {
+ my ($keywords, $dbpath, $did2pkg, $packages, $read_entry, $opts,
+ $results, $non_results) = @_;
+
+# NOTE: this needs to correspond with parse-packages!
+ my @tmp;
+ foreach my $keyword (@$keywords) {
+ $keyword =~ s;[^\w/+]+; ;og;
+ push @tmp, $keyword;
+ }
+ my $stemmer = Lingua::Stem->new();
+ my @stemmed_keywords = grep { length($_) } @{$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};
+
+ foreach (split /\000/o, $result) {
+ my @data = split /\s/, $_, 3;
+ debug ("Considering $data[0], arch = $data[2], relevance=".$match->get_percent(), 3) if DEBUG;
+# next unless $data[2] eq 'all' || $opts->{h_archs}{$data[2]};
+# debug ("Ok", 3) if DEBUG;
+ unless ($tmp_results{$data[0]}++) {
+ push @order, $data[0];
+ }