Recency scoring was not functioning properly because the score contributed by the ranking factor was very very small compared to the score contributed by other factors, thus providing unexpected results.

This has been solved here: http://drupal.org/node/292217#comment-971566 and applied to this module's implementation.

Comments

BlakeLucchesi’s picture

The code in the 6.x-1.1 release does not normalize the timestamps before applying the exponential decay function. The code in HEAD now does.

/**
 * Implementation of hook_cron().
 *
 * Store the timestamp of the oldest node for recency normalization.
 */
function search_ranking_cron() {
  $oldest_time = db_result(db_query_range("SELECT changed FROM {node} ORDER BY changed ASC", 0, 1));
  variable_set('node_rank_recent_oldest_time', $oldest_time);
}

/**
 * Implementation of hook_ranking().
 */
function search_ranking_ranking() {
  variable_get('node_rank_recent_oldest_time', 0);
  $ranking['recent'] => array(
    'title' => t('Recently posted'),
    'score' => 'POW(2.718, -5 * (1 - (n.changed - %d) / %d))',
    'arguments' => array(
      $oldest_time,
      time() - $oldest_time
    ),
  );
  return $ranking;
}

$oldest_time is the oldest changed date of a node in the system calculated during cron. We use a linear normalization function on the timestamp (output of the normalization function is range [0,1]) before inserting the value into an exponential decay function.

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.