public function DrupalApacheSolrService::getStatsSummary in Apache Solr Search 6.3
Same name and namespace in other branches
- 8 Drupal_Apache_Solr_Service.php \DrupalApacheSolrService::getStatsSummary()
- 7 Drupal_Apache_Solr_Service.php \DrupalApacheSolrService::getStatsSummary()
Get summary information about the Solr Core.
Overrides DrupalApacheSolrServiceInterface::getStatsSummary
File
- ./
Drupal_Apache_Solr_Service.php, line 306
Class
- DrupalApacheSolrService
- Starting point for the Solr API. Represents a Solr server resource and has methods for pinging, adding, deleting, committing, optimizing and searching.
Code
public function getStatsSummary() {
$stats = $this
->getStats();
$solr_version = $this
->getSolrVersion();
$summary = array(
'@pending_docs' => '',
'@autocommit_time_seconds' => '',
'@autocommit_time' => '',
'@deletes_by_id' => '',
'@deletes_by_query' => '',
'@deletes_total' => '',
'@schema_version' => '',
'@core_name' => '',
'@index_size' => '',
);
if (!empty($stats)) {
if ($solr_version <= 3) {
$docs_pending_xpath = $stats
->xpath('//stat[@name="docsPending"]');
$summary['@pending_docs'] = (int) trim(current($docs_pending_xpath));
$max_time_xpath = $stats
->xpath('//stat[@name="autocommit maxTime"]');
$max_time = (int) trim(current($max_time_xpath));
// Convert to seconds.
$summary['@autocommit_time_seconds'] = $max_time / 1000;
$summary['@autocommit_time'] = format_interval($max_time / 1000);
$deletes_id_xpath = $stats
->xpath('//stat[@name="deletesById"]');
$summary['@deletes_by_id'] = (int) trim(current($deletes_id_xpath));
$deletes_query_xpath = $stats
->xpath('//stat[@name="deletesByQuery"]');
$summary['@deletes_by_query'] = (int) trim(current($deletes_query_xpath));
$summary['@deletes_total'] = $summary['@deletes_by_id'] + $summary['@deletes_by_query'];
$schema = $stats
->xpath('/solr/schema[1]');
$summary['@schema_version'] = trim($schema[0]);
$core = $stats
->xpath('/solr/core[1]');
$summary['@core_name'] = trim($core[0]);
$size_xpath = $stats
->xpath('//stat[@name="indexSize"]');
$summary['@index_size'] = trim(current($size_xpath));
}
else {
$system_info = $this
->getSystemInfo();
$docs_pending_xpath = $stats
->xpath('//lst["stats"]/long[@name="docsPending"]');
$summary['@pending_docs'] = (int) trim(current($docs_pending_xpath));
$max_time_xpath = $stats
->xpath('//lst["stats"]/str[@name="autocommit maxTime"]');
$max_time = (int) trim(current($max_time_xpath));
// Convert to seconds.
$summary['@autocommit_time_seconds'] = $max_time / 1000;
$summary['@autocommit_time'] = format_interval($max_time / 1000);
$deletes_id_xpath = $stats
->xpath('//lst["stats"]/long[@name="deletesById"]');
$summary['@deletes_by_id'] = (int) trim(current($deletes_id_xpath));
$deletes_query_xpath = $stats
->xpath('//lst["stats"]/long[@name="deletesByQuery"]');
$summary['@deletes_by_query'] = (int) trim(current($deletes_query_xpath));
$summary['@deletes_total'] = $summary['@deletes_by_id'] + $summary['@deletes_by_query'];
$schema = $system_info->core->schema;
$summary['@schema_version'] = $schema;
$core = $stats
->xpath('//lst["core"]/str[@name="coreName"]');
$summary['@core_name'] = trim(current($core));
$size_xpath = $stats
->xpath('//lst["core"]/str[@name="indexSize"]');
$summary['@index_size'] = trim(current($size_xpath));
}
}
return $summary;
}