Act on a node being indexed for searching.
This hook is invoked during search indexing, after node_load(), and after the result of node_view() is added as $node->rendered to the node object.
\Drupal\Core\Entity\EntityInterface $node: The node being indexed.
$langcode: Language code of the variant of the node being indexed.
string Additional node information to be indexed.
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
function hook_node_update_index(\Drupal\Core\Entity\EntityInterface $node, $langcode) {
$text = '';
$comments = db_query('SELECT subject, comment, format FROM {comment} WHERE nid = :nid AND status = :status', array(
':nid' => $node->nid,
':status' => COMMENT_PUBLISHED,
));
foreach ($comments as $comment) {
$text .= '<h2>' . check_plain($comment->subject->value) . '</h2>' . $comment->comment_body->processed;
}
return $text;
}