Gossamer Forum
Home : Products : Gossamer Links : Version 1.x :

Search score

Quote Reply
Search score
In the last version <%score%> was available in the search.cgi to rank the links.

It doesn't seem to be available now. I can't even figure out what to use to access it, since the line from the old search.cgi where the query was built was removed and moved elsewhere.

How to I find the score of a particular link in a search?



Quote Reply
Re: Search score In reply to
The score is no longer available unfortunately. You could get to it by editing DBSQL.pm sub query_index:

while (my $array = $search->fetchrow_arrayref) {
shift @$array;
push (@results, $array);
}

and comment out the shift statement. Then the output of db->query will be an array of records, but the first element of each will be the score. This makes it difficult to use array_to_hash as you have to shift off the score first.

I'm not sure of an elegant way to preserve the score, but I'll take a look.

Cheers,

Alex
Quote Reply
Re: Search score In reply to
Ok... if score isn't preserved, then why do we weight searches?

That was a GREAT feature, being able to give keywords more weight, and less to user-entered fields.

Ranking by score is one of the best features!

Since this is in a search, which is doing processing anyway, there should be a way to calculate the score for each link.

I noticed the routines got a lot more complex, and complicated in this last beta, but relevancy is a really important feature that shouldn't be phased out!! Smile

Quote Reply
Re: Search score In reply to
Results are returned sorted by score, you just can't view the score. The most relevant ones are still returned first though.

Cheers,

Alex
Quote Reply
Re: Search score In reply to
Well, I certainly don't have an answer for that, however, here is a workaround.

First update sub query_index:
Code:
while (my $array = $search->fetchrow_arrayref) {
my $temp = shift @$array;
push @$array, $temp;
push (@results, $array);
}
return \@results;

Then, update array_to_hash as follows

Code:
sub array_to_hash { --------------------------------------------------------
# Converts an array ref to a hash ref.
#
my ($self, $array_r) = @_;
(ref $array_r eq 'ARRAY') or return $self->error ('BADARGS', 'array_to_hash', $array_r);
my $i = 0;
my %tmp = map { ( $self->{'db_cols'}[$i] | | 'SCORE' ) => ${$array_r}[$i++] } @$array_r;
return \%tmp;
}

i believe <%SCORE%> will (hopefully) then be available. This is my hack though..., that I'm using till an elegant solution comes up Wink



[This message has been edited by kitsune (edited December 01, 1999).]