Commit 03c18bb2 authored by Gábor Hojtsy's avatar Gábor Hojtsy
Browse files

#205795 by douggreen: search result normalization used a wrong calculation

parent 18d46e47
...@@ -926,9 +926,9 @@ function do_search($keywords, $type, $join1 = '', $where1 = '1', $arguments1 = a ...@@ -926,9 +926,9 @@ function do_search($keywords, $type, $join1 = '', $where1 = '1', $arguments1 = a
} }
// Calculate maximum keyword relevance, to normalize it. // Calculate maximum keyword relevance, to normalize it.
$select = "SELECT MAX(i.score * t.count) FROM {search_index} i $join WHERE $conditions GROUP BY i.type, i.sid HAVING COUNT(*) >= %d"; $select = "SELECT SUM(i.score * t.count) AS score FROM {search_index} i $join WHERE $conditions GROUP BY i.type, i.sid HAVING COUNT(*) >= %d ORDER BY score DESC";
$arguments = array_merge($arguments1, array($query[4])); $arguments = array_merge($arguments1, array($query[4]));
$normalize = db_result(db_query($select, $arguments)); $normalize = db_result(db_query_range($select, $arguments, 0, 1));
if (!$normalize) { if (!$normalize) {
return array(); return array();
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment