You are here

public function Drupal_Apache_Solr_Service::getStatsSummary in Apache Solr Search 5.2

Same name and namespace in other branches
  1. 6 Drupal_Apache_Solr_Service.php \Drupal_Apache_Solr_Service::getStatsSummary()
  2. 6.2 Drupal_Apache_Solr_Service.php \Drupal_Apache_Solr_Service::getStatsSummary()

Get summary information about the Solr Core.

File

./Drupal_Apache_Solr_Service.php, line 120

Class

Drupal_Apache_Solr_Service

Code

public function getStatsSummary() {
  $stats = $this
    ->getStats();
  $summary = array(
    '@pending_docs' => '',
    '@autocommit_time_seconds' => '',
    '@autocommit_time' => '',
    '@deletes_by_id' => '',
    '@deletes_by_query' => '',
    '@deletes_total' => '',
    '@schema_version' => '',
    '@core_name' => '',
  );
  if (!empty($stats)) {
    $docs_pending_xpath = $stats
      ->xpath('//stat[@name="docsPending"]');
    $summary['@pending_docs'] = (int) trim($docs_pending_xpath[0]);
    $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($deletes_id_xpath[0]);
    $deletes_query_xpath = $stats
      ->xpath('//stat[@name="deletesByQuery"]');
    $summary['@deletes_by_query'] = (int) trim($deletes_query_xpath[0]);
    $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]);
  }
  return $summary;
}