Adds a custom score expression to the search query.
Each score expression can optionally use a multiplier, and multiple expressions are combined.
$score: The score expression.
$arguments: Custom query arguments for that expression.
$multiply: If set, the score is multiplied with that value. Search query ensures that the search scores are still normalized.
object The updated query object.
public function addScore($score, $arguments = array(), $multiply = FALSE) {
if ($multiply) {
$i = count($this->multiply);
$score = "CAST(:multiply_{$i} AS DECIMAL) * COALESCE(( " . $score . "), 0) / CAST(:total_{$i} AS DECIMAL)";
$arguments[':multiply_' . $i] = $multiply;
$this->multiply[] = $multiply;
}
$this->scores[] = $score;
$this->scoresArguments += $arguments;
return $this;
}