You are here

function search_api_index_items in Search API 7

Indexes items for the specified index.

Only items marked as changed are indexed, in their order of change (if known).

Parameters

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

int $limit: (optional) The number of items which should be indexed at most. Defaults to -1, which means that all changed items should be indexed.

Return value

int Number of successfully indexed items.

Throws

SearchApiException If any error occurs during indexing.

2 calls to search_api_index_items()
search_api_cron in ./search_api.module
Implements hook_cron().
_search_api_batch_indexing_callback in ./search_api.module
Batch API callback for the indexing functionality.

File

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

Code

function search_api_index_items(SearchApiIndex $index, $limit = -1) {

  // Don't try to index on read-only indexes.
  if ($index->read_only) {
    return 0;
  }
  $ids = search_api_get_items_to_index($index, $limit);
  return $ids ? count(search_api_index_specific_items($index, $ids)) : 0;
}