Changeset 457


Ignore:
Timestamp:
Jul 26, 2004, 5:25:54 PM (17 years ago)
Author:
kake
Message:

Two matches in the title beats one match in the title and one in the content.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/OpenGuides/SuperSearch.pm

    r456 r457  
    11package OpenGuides::SuperSearch;
    22use strict;
    3 our $VERSION = '0.05';
     3our $VERSION = '0.06';
    44
    55use CGI qw( :standard );
     
    504504        foreach my $page ( @pages ) {
    505505            if ( exists $subres{$page} ) {
    506                 $results{$page}{score} += $subres{$page};
     506                $results{$page}{score} += $subres{$page}{score};
    507507            } else {
    508508                delete $results{$page};
     
    563563    my $self = shift;
    564564    my %excludes = $self->_matched_items(tree => \@_);
    565     my %out = map {$_=>[0]} keys %{ $self->{wikitext} };
     565    my %out = map { $_ => { score => 0} } keys %{ $self->{wikitext} };
    566566
    567567    delete $out{$_} for keys %excludes;
     
    606606A match on page category or locale will score higher than a match on
    607607page content.
     608
     609=item *
     610
     611Two matches in the title beats one match in the title and one in the content.
    608612
    609613=back
  • trunk/t/36_supersearch_order.t

    r456 r457  
    99    plan skip_all => "DBD::SQLite not installed";
    1010} else {
    11     plan tests => 5;
     11    plan tests => 6;
    1212
    1313    CGI::Wiki::Setup::SQLite::setup( { dbname => "t/node.db" } );
     
    6464        or die "Can't write node";
    6565
    66     my %tt_vars = $search->run(
     66    %tt_vars = $search->run(
    6767                             return_tt_vars => 1,
    6868                             vars           => { search => "hammersmith" },
     
    7171        print "# $result->{name} scores $result->{score}\n";
    7272    }
    73     my %scores = map { $_->{name} => $_->{score} } @{$tt_vars{results} || []};
     73    %scores = map { $_->{name} => $_->{score} } @{$tt_vars{results} || []};
    7474    ok( $scores{Kake_Pugh} < $scores{The_Gate},
    7575        "content match scores less than locale match" );
     
    7777        "locale match scores less than title match" );
    7878
     79    # Check that two words in the title beats one in the title and
     80    # one in the content.
     81    $wiki->write_node( "Putney Tandoori", "Indian food" )
     82      or die "Couldn't write node";
     83    $wiki->write_node( "Putney", "There is a tandoori restaurant here" )
     84      or die "Couldn't write node";
     85
     86    %tt_vars = $search->run(
     87                             return_tt_vars => 1,
     88                             vars           => { search => "putney tandoori" },
     89                           );
     90    foreach my $result ( @{ $tt_vars{results} || [] } ) {
     91        print "# $result->{name} scores $result->{score}\n";
     92    }
     93    %scores = map { $_->{name} => $_->{score} } @{$tt_vars{results} || []};
     94    ok( $scores{Putney} < $scores{Putney_Tandoori},
     95        "two words in title beats one in title and one in content" );
    7996}
Note: See TracChangeset for help on using the changeset viewer.