function NodeSearch::addNodeRankings
Same name in other branches
- 8.9.x core/modules/node/src/Plugin/Search/NodeSearch.php \Drupal\node\Plugin\Search\NodeSearch::addNodeRankings()
- 10 core/modules/node/src/Plugin/Search/NodeSearch.php \Drupal\node\Plugin\Search\NodeSearch::addNodeRankings()
- 11.x core/modules/node/src/Plugin/Search/NodeSearch.php \Drupal\node\Plugin\Search\NodeSearch::addNodeRankings()
Adds the configured rankings to the search query.
Parameters
$query: A query object that has been extended with the Search DB Extender.
1 call to NodeSearch::addNodeRankings()
- NodeSearch::findResults in core/
modules/ node/ src/ Plugin/ Search/ NodeSearch.php - Queries to find search results, and sets status messages.
File
-
core/
modules/ node/ src/ Plugin/ Search/ NodeSearch.php, line 439
Class
- NodeSearch
- Handles searching for node entities using the Search module index.
Namespace
Drupal\node\Plugin\SearchCode
protected function addNodeRankings(SelectExtender $query) {
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.