Commit 9020a9a2 authored by webchick's avatar webchick
Browse files

#331719 follow-up by chx: Remove ambiguity from search score queries.

parent 0aeda0f1
...@@ -1333,13 +1333,13 @@ function node_search($op = 'search', $keys = NULL) { ...@@ -1333,13 +1333,13 @@ function node_search($op = 'search', $keys = NULL) {
$total = 1; $total = 1;
$arguments2 = array(); $arguments2 = array();
$join2 = ''; $join2 = '';
$select2 = 'i.relevance AS score'; $select2 = 'i.relevance AS calculated_score';
} }
else { else {
$total = $rankings['total']; $total = $rankings['total'];
$arguments2 = $rankings['arguments']; $arguments2 = $rankings['arguments'];
$join2 = implode(' ', $rankings['join']); $join2 = implode(' ', $rankings['join']);
$select2 = '('. implode(' + ', $rankings['score']) .') AS score'; $select2 = '('. implode(' + ', $rankings['score']) .') AS calculated_score';
} }
// Do search. // Do search.
...@@ -1369,7 +1369,7 @@ function node_search($op = 'search', $keys = NULL) { ...@@ -1369,7 +1369,7 @@ function node_search($op = 'search', $keys = NULL) {
'date' => $node->changed, 'date' => $node->changed,
'node' => $node, 'node' => $node,
'extra' => $extra, 'extra' => $extra,
'score' => $total ? ($item->score / $total) : 0, 'score' => $total ? ($item->calculated_score / $total) : 0,
'snippet' => search_excerpt($keys, $node->body), 'snippet' => search_excerpt($keys, $node->body),
); );
} }
......
...@@ -903,8 +903,8 @@ function _search_parse_query(&$word, &$scores, $not = FALSE) { ...@@ -903,8 +903,8 @@ function _search_parse_query(&$word, &$scores, $not = FALSE) {
* *
* @param $columns2 * @param $columns2
* (optional) Inserted into the SELECT pat of the second query. Must contain * (optional) Inserted into the SELECT pat of the second query. Must contain
* a column selected as 'score'. * a column selected as 'calculated_score'.
* defaults to 'i.relevance AS score' * defaults to 'i.relevance AS calculated_score'
* *
* @param $join2 * @param $join2
* (optional) Inserted into the JOIN par of the second SQL query. * (optional) Inserted into the JOIN par of the second SQL query.
...@@ -915,14 +915,14 @@ function _search_parse_query(&$word, &$scores, $not = FALSE) { ...@@ -915,14 +915,14 @@ function _search_parse_query(&$word, &$scores, $not = FALSE) {
* *
* @param $sort_parameters * @param $sort_parameters
* (optional) SQL arguments for sorting the final results. * (optional) SQL arguments for sorting the final results.
* Default: 'ORDER BY score DESC' * Default: 'ORDER BY calculated_score DESC'
* *
* @return * @return
* An array of SIDs for the search results. * An array of SIDs for the search results.
* *
* @ingroup search * @ingroup search
*/ */
function do_search($keywords, $type, $join1 = '', $where1 = '1 = 1', $arguments1 = array(), $columns2 = 'i.relevance AS score', $join2 = '', $arguments2 = array(), $sort_parameters = 'ORDER BY score DESC') { function do_search($keywords, $type, $join1 = '', $where1 = '1 = 1', $arguments1 = array(), $columns2 = 'i.relevance AS calculated_score', $join2 = '', $arguments2 = array(), $sort_parameters = 'ORDER BY calculated_score DESC') {
$query = search_parse_query($keywords); $query = search_parse_query($keywords);
if ($query[2] == '') { if ($query[2] == '') {
......
...@@ -148,7 +148,7 @@ class SearchMatchTestCase extends DrupalWebTestCase { ...@@ -148,7 +148,7 @@ class SearchMatchTestCase extends DrupalWebTestCase {
// Get result scores. // Get result scores.
$scores = array(); $scores = array();
foreach ($set as $item) { foreach ($set as $item) {
$scores[] = $item->score; $scores[] = $item->calculated_score;
} }
// Check order. // Check order.
......
Supports Markdown
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