function apachesolr_index_status in Apache Solr Search 6.3
Same name and namespace in other branches
- 8 apachesolr.index.inc \apachesolr_index_status()
- 5.2 apachesolr.module \apachesolr_index_status()
- 6 apachesolr.module \apachesolr_index_status()
- 6.2 apachesolr.module \apachesolr_index_status()
- 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 in ./
apachesolr_search.module - Implements of hook_search().
- apachesolr_status_page in ./
apachesolr.admin.inc - Gets information about the fields already in solr index.
File
- ./
apachesolr.index.inc, line 122 - Functions related to Apache Solr indexing operations.
Code
function apachesolr_index_status($env_id) {
$remaining = 0;
$total = 0;
$entity_type = 'node';
$bundles = apachesolr_get_index_bundles($env_id, $entity_type);
if (!empty($bundles)) {
$table = apachesolr_get_indexer_table($entity_type);
$query = "SELECT count(*)\n FROM {{$table}} asn\n WHERE (asn.status = 1) AND (asn.bundle IN (" . db_placeholders($bundles, 'varchar') . "))";
$total += db_result(db_query($query, $bundles));
$query = _apachesolr_index_get_next_set_query($env_id, $entity_type, TRUE);
$remaining += db_result(db_query($query['query'], $query['args']));
}
return array(
'remaining' => $remaining,
'total' => $total,
);
}