2 * Implements hook_entity_view_display_alter().
4 function {{ machine_name }}_entity_view_display_alter(\Drupal\Core\Entity\Display\EntityViewDisplayInterface $display, array $context) {
5 // Leave field labels out of the search index.
6 if ($context['entity_type'] == 'node' && $context['view_mode'] == 'search_index') {
7 foreach ($display->getComponents() as $name => $options) {
8 if (isset($options['label'])) {
9 $options['label'] = 'hidden';
10 $display->setComponent($name, $options);