In my module I have this implementation where I have a hook_search_execute()
function which can be used for rewriting/extending default Drupal search. This function calls for executeFirstPass()
method and adds to the query the following $first->addExpression('SUM(i.score * t.count)', 'calculated_score');
When I'm trying to add my sorting as following $query->orderBy('calculated_score', 'ASC');
, I have an error.
However if I add $query->orderBy('n.title', 'ASC');
or $query->orderBy('n.created', 'ASC');
everything is fine and is sorting as it should be.
Does anyone have any ideas why this is happens?