You are here

function apachesolr_index_status in Apache Solr Search 7

Same name and namespace in other branches
  1. 8 apachesolr.index.inc \apachesolr_index_status()
  2. 5.2 apachesolr.module \apachesolr_index_status()
  3. 6.3 apachesolr.index.inc \apachesolr_index_status()
  4. 6 apachesolr.module \apachesolr_index_status()
  5. 6.2 apachesolr.module \apachesolr_index_status()

Returns the total number of documents that are able to be indexed and the number of documents left to be indexed.

This is a helper function for modules that implement hook_search_status().

Parameters

string $env_id: The machine name of the environment.

Return value

array An associative array with the key-value pairs:

  • remaining: The number of items left to index.
  • total: The total number of items to index.

See also

hook_search_status()

3 calls to apachesolr_index_status()
apachesolr_index_batch_index_entities in ./apachesolr.admin.inc
Batch Operation Callback
apachesolr_search_search_status in ./apachesolr_search.module
Implements hook_search_status().
apachesolr_status_page in ./apachesolr.admin.inc
Gets information about the fields already in solr index.

File

./apachesolr.index.inc, line 154
Functions related to Apache Solr indexing operations.

Code

function apachesolr_index_status($env_id) {
  $remaining = 0;
  $total = 0;
  foreach (entity_get_info() as $entity_type => $info) {
    $bundles = apachesolr_get_index_bundles($env_id, $entity_type);
    if (empty($bundles)) {
      continue;
    }
    $table = apachesolr_get_indexer_table($entity_type);
    $query = db_select($table, 'aie')
      ->condition('aie.status', 1)
      ->condition('aie.bundle', $bundles)
      ->addTag('apachesolr_index_' . $entity_type);
    $total += $query
      ->countQuery()
      ->execute()
      ->fetchField();
    $query = _apachesolr_index_get_next_set_query($env_id, $entity_type);
    $remaining += $query
      ->countQuery()
      ->execute()
      ->fetchField();
  }
  return array(
    'remaining' => $remaining,
    'total' => $total,
  );
}