function SearchNode::addNodeRankings
Adds the configured rankings to the search query.
Parameters
\Drupal\Core\Database\Query\ExtendableInterface $query: A query object that has been extended with the Search DB Extender.
File
-
core/
modules/ search/ modules/ search_node/ src/ Plugin/ Search/ SearchNode.php, line 364
Class
- SearchNode
- Handles searching for node entities using the Search module index.
Namespace
Drupal\search_node\Plugin\SearchCode
protected function addNodeRankings(ExtendableInterface $query) : void {
if ($ranking = $this->getRankings()) {
$tables =& $query->getTables();
foreach ($ranking as $rank => $values) {
if (isset($this->configuration['rankings'][$rank]) && !empty($this->configuration['rankings'][$rank])) {
$node_rank = $this->configuration['rankings'][$rank];
// If the table defined in the ranking isn't already joined, then add
// it.
if (isset($values['join']) && !isset($tables[$values['join']['alias']])) {
$query->addJoin($values['join']['type'], $values['join']['table'], $values['join']['alias'], $values['join']['on']);
}
$arguments = $values['arguments'] ?? [];
$query->addScore($values['score'], $arguments, $node_rank);
}
}
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.