X-Git-Url: https://git.deb.at/?p=deb%2Fpackages.git;a=blobdiff_plain;f=lib%2FPackages%2FDoSearch.pm;h=c1b6dfdd01cd8c51420a530e68ff895eb9bab91b;hp=a94dd7bc33e46fd54415cbc50011d9e45b7128b4;hb=ee1229bf379cb681a4805bf97ecdea9e60a7efb8;hpb=bf6d5b1c3221cdd54d613778ce806804a3faf006 diff --git a/lib/Packages/DoSearch.pm b/lib/Packages/DoSearch.pm index a94dd7b..c1b6dfd 100644 --- a/lib/Packages/DoSearch.pm +++ b/lib/Packages/DoSearch.pm @@ -19,7 +19,7 @@ use Packages::DB; use Packages::Config qw( $DBDIR @SUITES @ARCHIVES $ROOT ); sub do_search { - my ($params, $opts, $html_header, $page_content) = @_; + my ($params, $opts, $page_content) = @_; $Params::Search::too_many_hits = 0; @@ -53,21 +53,14 @@ sub do_search { do_names_search( [ @keywords ], \%packages, $p_obj, \&read_entry_all, $opts, \@results, \@non_results ); -# my $fts0 = new Benchmark; -# do_fulltext_search( [ @keywords ], "$DBDIR/descriptions.txt", -# \%did2pkg, \%packages, -# \&read_entry_all, $opts, -# \@results, \@non_results ); my $fts1 = new Benchmark; do_xapian_search( [ @keywords ], "$DBDIR/xapian/", \%did2pkg, \%packages, \&read_entry_all, $opts, \@results, \@non_results ); my $fts2 = new Benchmark; -# my $fts_grep = timediff($fts1,$fts0); my $fts_xapian = timediff($fts2,$fts1); -# debug( "Fulltext search took ".timestr($fts_grep)." (grep)" ) if DEBUG; - debug( "Fulltext search took ".timestr($fts_xapian)." (Xapian)" ) + debug( "Fulltext search took ".timestr($fts_xapian) ) if DEBUG; } } @@ -86,6 +79,14 @@ sub do_search { if (@results) { my (%pkgs, %subsect, %sect, %archives, %desc, %binaries, %provided_by); + my %sort_by_relevance; + for (1 ... scalar @results) { +# debug("$results[$_][0] => $_", 4) if DEBUG; + $sort_by_relevance{$results[$_-1][0]} = $_; + } +# use Data::Dumper; +# debug( "sort_by_relevance=".Dumper(\%sort_by_relevance), 4); + unless ($opts->{source}) { foreach (@results) { my ($pkg_t, $archive, $suite, $arch, $section, $subsection, @@ -105,7 +106,12 @@ sub do_search { } my %uniq_pkgs = map { $_ => 1 } (keys %pkgs, keys %provided_by); - my @pkgs = sort keys %uniq_pkgs; + my @pkgs; + if ($searchon eq 'names') { + @pkgs = sort keys %uniq_pkgs; + } else { + @pkgs = sort { $sort_by_relevance{$a} <=> $sort_by_relevance{$b} } keys %uniq_pkgs; + } process_packages( $page_content, 'packages', \%pkgs, \@pkgs, $opts, \@keywords, \&process_package, \%provided_by, \%archives, \%sect, \%subsect, @@ -117,7 +123,7 @@ sub do_search { $version) = @$_; my $real_archive = ''; - if ($archive =~ /^(security|non-US)$/) { + if ($archive eq 'security') { $real_archive = $archive; $archive = 'us'; }