You are here

function _search_api_batch_indexing_create in Search API 7

Creates and sets a batch for indexing items.

Parameters

SearchApiIndex $index: The index for which items should be indexed.

int $batch_size: Number of items to index per batch.

int $limit: Maximum number of items to index. Negative values mean "no limit".

int $remaining: Remaining items to index.

bool $drush: Boolean specifying whether this was called from drush or not.

Return value

bool Whether the batch was created and set successfully.

2 calls to _search_api_batch_indexing_create()
search_api_admin_index_status_form_submit in ./search_api.admin.inc
Form submission handler for search_api_admin_index_status_form().
_drush_search_api_batch_indexing_create in ./search_api.drush.inc
Creates and sets a batch for indexing items for a particular index.

File

./search_api.module, line 3365
Provides a flexible framework for implementing search services.

Code

function _search_api_batch_indexing_create(SearchApiIndex $index, $batch_size, $limit, $remaining, $drush = FALSE) {
  if ($limit !== 0 && $batch_size !== 0) {
    $t = !empty($drush) ? 'dt' : 't';
    if ($limit < 0 || $limit > $remaining) {
      $limit = $remaining;
    }
    if ($batch_size < 0) {
      $batch_size = $remaining;
    }
    $batch = array(
      'title' => $t('Indexing items'),
      'operations' => array(
        array(
          '_search_api_batch_indexing_callback',
          array(
            $index,
            $batch_size,
            $limit,
            $drush,
          ),
        ),
      ),
      'progress_message' => $t('Completed about @percentage% of the indexing operation.'),
      'finished' => '_search_api_batch_indexing_finished',
      'file' => drupal_get_path('module', 'search_api') . '/search_api.module',
    );
    batch_set($batch);
    return TRUE;
  }
  return FALSE;
}