You are here

function drush_search_api_reindex_items in Search API 7

Marks the given entities as needing to be re-indexed.

File

./search_api.drush.inc, line 479
Drush commands for SearchAPI.

Code

function drush_search_api_reindex_items($entity_type, $entities) {
  if (search_api_drush_static(__FUNCTION__)) {
    return;
  }

  // Validate list of entity ids.
  if (!empty($entities) && !preg_match('#^[0-9]*(,[0-9]*)*$#', $entities)) {
    drush_log(dt('Entities should be a single numeric entity ID or a list with the numeric entity IDs separated by comma.'), 'error');
    return;
  }
  $ids = explode(',', $entities);
  if (!empty($ids)) {
    search_api_track_item_change($entity_type, $ids);
    $combined_ids = array();
    foreach ($ids as $id) {
      $combined_ids[] = $entity_type . '/' . $id;
    }
    search_api_track_item_change('multiple', $combined_ids);
  }
}