use rank_cd to improve relevance ranking collab/gmcharlt/rel_2_0_rank_cd
authorMichael Peters <mrpeters@library.in.gov>
Wed, 25 May 2011 17:05:08 +0000 (13:05 -0400)
committerGalen Charlton <gmc@esilibrary.com>
Wed, 20 Jul 2011 15:55:56 +0000 (11:55 -0400)
With the changes made to query parsing and searching in rel_2_0,
the relevance adjustment bumps specified in the search.relevance_adjustment
table can degrade search performance.  Removing all of the rows from
search.relevance_adjustment can improve search speed, but at the
cost of making relevance ranking problematic for some searches (e.g., as of
the date of this patch, doing a title search on "the help").

This patch implements a subset of the cover density ranking being introduced
in 2.1, specifically the following normalization options to rank_cd:

  2 divides the rank by the document length
  4 divides the rank by the mean harmonic distance between extents (this is implemented only by ts_rank_cd)
  8 divides the rank by the number of unique words in document

Original commit description from Mike Peters:
Patch to QueryParser.pm to fix search results sort order by rjackson courtesy of Steve Callender
[courtesy of Mike Rylander --gmc]

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm

index c1fb759..a730f16 100644 (file)
@@ -841,7 +841,7 @@ sub tsquery {
 sub rank {
     my $self = shift;
     return $self->{rank} if ($self->{rank});
-    return $self->{rank} = 'rank(' . $self->table_alias . '.index_vector, ' . $self->table_alias . '.tsq)';
+    return $self->{rank} = 'rank_cd(' . $self->table_alias . '.index_vector, ' . $self->table_alias . '.tsq,14)';
 }