summaryrefslogtreecommitdiff
path: root/modules/node/node.module
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2006-12-16 09:51:22 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2006-12-16 09:51:22 +0000
commitc6a190ea1051e27d1b110fbac42482f07801a607 (patch)
tree7d1ccf222e3f52fdaebb4c231ffcc5ea2842e153 /modules/node/node.module
parent1776eadc92c0b2ca8d5b7687f34d52d2c42d1da8 (diff)
downloadbrdo-c6a190ea1051e27d1b110fbac42482f07801a607.tar.gz
brdo-c6a190ea1051e27d1b110fbac42482f07801a607.tar.bz2
- Teeny tiny API change: pass normalized ranking score out of node_search()
Diffstat (limited to 'modules/node/node.module')
-rw-r--r--modules/node/node.module6
1 files changed, 6 insertions, 0 deletions
diff --git a/modules/node/node.module b/modules/node/node.module
index 79fb616e8..0a1aefbfd 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -868,10 +868,12 @@ function node_search($op = 'search', $keys = NULL) {
$join2 = '';
// Used to avoid joining on node_comment_statistics twice
$stats_join = FALSE;
+ $total = 0;
if ($weight = (int)variable_get('node_rank_relevance', 5)) {
// Average relevance values hover around 0.15
$ranking[] = '%d * i.relevance';
$arguments2[] = $weight;
+ $total += $weight;
}
if ($weight = (int)variable_get('node_rank_recent', 5)) {
// Exponential decay with half-life of 6 months, starting at last indexed node
@@ -880,6 +882,7 @@ function node_search($op = 'search', $keys = NULL) {
$arguments2[] = (int)variable_get('node_cron_last', 0);
$join2 .= ' INNER JOIN {node} n ON n.nid = i.sid LEFT JOIN {node_comment_statistics} c ON c.nid = i.sid';
$stats_join = TRUE;
+ $total += $weight;
}
if (module_exists('comment') && $weight = (int)variable_get('node_rank_comments', 5)) {
// Inverse law that maps the highest reply count on the site to 1 and 0 to 0.
@@ -890,6 +893,7 @@ function node_search($op = 'search', $keys = NULL) {
if (!$stats_join) {
$join2 .= ' LEFT JOIN {node_comment_statistics} c ON c.nid = i.sid';
}
+ $total += $weight;
}
if (module_exists('statistics') && variable_get('statistics_count_content_views', 0) &&
$weight = (int)variable_get('node_rank_views', 5)) {
@@ -899,6 +903,7 @@ function node_search($op = 'search', $keys = NULL) {
$arguments2[] = $weight;
$arguments2[] = $scale;
$join2 .= ' LEFT JOIN {node_counter} nc ON nc.nid = i.sid';
+ $total += $weight;
}
$select2 = (count($ranking) ? implode(' + ', $ranking) : 'i.relevance') . ' AS score';
@@ -926,6 +931,7 @@ function node_search($op = 'search', $keys = NULL) {
'date' => $node->changed,
'node' => $node,
'extra' => $extra,
+ 'score' => $item->score / $total,
'snippet' => search_excerpt($keys, $node->body));
}
return $results;