diff options
Diffstat (limited to 'modules/search')
-rw-r--r-- | modules/search/search.extender.inc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/modules/search/search.extender.inc b/modules/search/search.extender.inc index 1eae2caa6..6c0c7600b 100644 --- a/modules/search/search.extender.inc +++ b/modules/search/search.extender.inc @@ -415,10 +415,6 @@ class SearchQuery extends SelectQueryExtender { // Add default score. $this->addScore('i.relevance'); } - if (count($this->getOrderBy()) == 0) { - // Add default order. - $this->orderBy('calculated_score', 'DESC'); - } if (count($this->multiply)) { // Add the total multiplicator as many times as requested to maintain @@ -436,6 +432,11 @@ class SearchQuery extends SelectQueryExtender { // Convert scores to an expression. $this->addExpression('SUM(' . implode(' + ', $this->scores) . ')', 'calculated_score', $this->scoresArguments); + if (count($this->getOrderBy()) == 0) { + // Add default order after adding the expression. + $this->orderBy('calculated_score', 'DESC'); + } + // Add tag and useful metadata. $this ->addTag('search_' . $this->type) |