You are here

function apachesolr_index_page in Apache Solr Search 5.2

Same name and namespace in other branches
  1. 5 apachesolr.module \apachesolr_index_page()
  2. 6 apachesolr.admin.inc \apachesolr_index_page()
  3. 6.2 apachesolr.admin.inc \apachesolr_index_page()

Gets information about the fields already in solr index.

1 string reference to 'apachesolr_index_page'
apachesolr_menu in ./apachesolr.module
Implementation of hook_menu().

File

./apachesolr.admin.inc, line 107
Administrative pages for the Apache Solr framework.

Code

function apachesolr_index_page() {
  try {
    $solr = apachesolr_get_solr();

    // TODO: possibly clear this every page view if we are running multi-site.
    if (apachesolr_index_updated()) {
      $solr
        ->clearCache();
    }
    $data = $solr
      ->getLuke();
  } catch (Exception $e) {
    watchdog('Apache Solr', nl2br(check_plain($e
      ->getMessage())), WATCHDOG_ERROR);
    drupal_set_message(nl2br(check_plain($e
      ->getMessage())), "warning");
    $data->fields = array();
  }
  $output = '';
  if (isset($data->index->numDocs)) {
    $pending_docs = $delay_msg = $delete_msg = '';
    try {
      $stats_summary = $solr
        ->getStatsSummary();
      $solr_msg = '<p>' . t('Using schema.xml version: <strong>@schema_version</strong>', $stats_summary);
      if ($stats_summary['@core_name']) {
        $solr_msg .= '<br />' . t('Solr core name: <strong>@core_name</strong>', $stats_summary);
      }
      $delay_msg = '<br />' . t('<em>The server has a @autocommit_time delay before updates are processed.</em>', $stats_summary) . "</p>\n";
      $delete_msg = '<p>' . t('Number of pending deletions: @deletes_total', $stats_summary) . "</p>\n";
    } catch (Exception $e) {
      watchdog('Apache Solr', nl2br(check_plain($e
        ->getMessage())), WATCHDOG_ERROR);
    }
    $output .= $solr_msg . $delay_msg;
    $pending_msg = $stats_summary['@pending_docs'] ? t('(@pending_docs sent but not yet processed)', $stats_summary) : '';
    $output .= '<p>' . t('Number of documents in index: @num !pending', array(
      '@num' => $data->index->numDocs,
      '!pending' => $pending_msg,
    )) . "</p>\n";
    $output .= $delete_msg;
  }
  $output .= '<p>' . l(t('View more details on the search index contents'), 'admin/logs/apachesolr') . "</p>\n";

  // Display the Delete Index form.
  $output .= drupal_get_form('apachesolr_delete_index_form');
  return $output;
}