Snippet to quickly (re)index search results for a specific node type

Adrian Rollett bio photo By Adrian Rollett

Had the need to do this, saving the snippet here.

<?php

$query = db_select('node', 'n')
          ->fields('n', array('nid'))
          ->condition('type', 'content_type_machine_name', '=')
          ->execute();

while ($record = $query->fetchObject()) {
  _node_index_node($record);
}

Post Comment