/** * Implements hook_node_update_index(). */ function {{ machine_name }}_node_update_index(\Drupal\node\NodeInterface $node) { $text = ''; $ratings = db_query('SELECT title, description FROM {my_ratings} WHERE nid = :nid', [':nid' => $node->id()]); foreach ($ratings as $rating) { $text .= '

' . Html::escape($rating->title) . '

' . Xss::filter($rating->description); } return $text; }