You are here

public function SearchApiAbstractDataSourceController::getIndexStatus in Search API 7

Retrieves information on how many items have been indexed for a certain index.

Parameters

SearchApiIndex $index: The index whose index status should be returned.

Return value

array An associative array containing two keys (in this order):

  • indexed: The number of items already indexed in their latest version.
  • total: The total number of items that have to be indexed for this index.

Throws

SearchApiDataSourceException If any error state was encountered.

Overrides SearchApiDataSourceControllerInterface::getIndexStatus

1 method overrides SearchApiAbstractDataSourceController::getIndexStatus()
SearchApiExternalDataSourceController::getIndexStatus in includes/datasource_external.inc
Get information on how many items have been indexed for a certain index.

File

includes/datasource.inc, line 811
Contains the SearchApiDataSourceControllerInterface as well as a default base class.

Class

SearchApiAbstractDataSourceController
Provides a default base class for datasource controllers.

Code

public function getIndexStatus(SearchApiIndex $index) {
  if (!$this->table) {
    return array(
      'indexed' => 0,
      'total' => 0,
    );
  }
  $this
    ->checkIndex($index);
  $indexed = db_select($this->table, 'i')
    ->condition($this->indexIdColumn, $index->id)
    ->condition($this->changedColumn, 0)
    ->countQuery()
    ->execute()
    ->fetchField();
  $total = db_select($this->table, 'i')
    ->condition($this->indexIdColumn, $index->id)
    ->countQuery()
    ->execute()
    ->fetchField();
  return array(
    'indexed' => $indexed,
    'total' => $total,
  );
}