Can the Views Bulk Operations module be used to reindex nodes that fulfill some criteria (e.g. nodes of specific type)?

1 Answer 1


I didn't deal with that for a few time but since I found the answer my self I thought about posting that here in the hope that someone finds it useful. I dug into Views Bulk Operations and into the Search API devel, copied and modified some code.

For this to work we need to create a custom module and put in the module the following:

 * Implements hook_action_info
function MY_MODULE_api_action_info() {
   * Defines an array of actions to be performed on nodes
  return array(
      'MY_MODULE_api_reindex' => array(
          'type' => 'node',
          'label' => t('Reindex node'),
          'behavior' => array('changes_property'),
          'configurable' => FALSE,
          'vbo_configurable' => FALSE,
          'triggers' => array('any'),

function MY_MODULE_api_reindex(&$node, $context) {
   * function to implement the action defined above (see the key of the array
   * returned in vbo_search_api_action_info()
  //copied the code from the search_api_devel module
  //load all indexes
  $indexes = search_api_index_load_multiple(FALSE);
  foreach ($indexes as $index) {
      if ($index->enabled) {
        search_api_index_specific_items($index, array($node->nid));

There might be a better way to go around this problem. For example the code now loads the index for each visited node, whereas Search API supports indexing an array of nids. So potentially we could gather all nids and then submit to Search API

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.