You are here

function apachesolr_index_status in Apache Solr Search 8

Same name and namespace in other branches
  1. 5.2 apachesolr.module \apachesolr_index_status()
  2. 6.3 apachesolr.index.inc \apachesolr_index_status()
  3. 6 apachesolr.module \apachesolr_index_status()
  4. 6.2 apachesolr.module \apachesolr_index_status()
  5. 7 apachesolr.index.inc \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 144
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, 'asn')
      ->condition('asn.status', 1)
      ->condition('asn.bundle', $bundles);
    $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,
  );
}