function apachesolr_index_report in Apache Solr Search 6.3
Same name and namespace in other branches
- 8 apachesolr.admin.inc \apachesolr_index_report()
- 5.2 apachesolr.admin.inc \apachesolr_index_report()
- 6 apachesolr.admin.inc \apachesolr_index_report()
- 6.2 apachesolr.admin.inc \apachesolr_index_report()
- 7 apachesolr.admin.inc \apachesolr_index_report()
1 string reference to 'apachesolr_index_report'
- apachesolr_menu in ./
apachesolr.module - Implements hook_menu().
File
- ./
apachesolr.admin.inc, line 599 - Administrative pages for the Apache Solr framework.
Code
function apachesolr_index_report($environment = NULL) {
if (!$environment) {
$env_id = apachesolr_default_environment();
drupal_goto('admin/reports/apachesolr/' . $env_id);
}
$environments = apachesolr_load_all_environments();
$environments_list = array();
foreach ($environments as $env) {
$var_status = array(
'@name' => $env['name'],
);
$environments_list[] = l(t('Statistics for @name', $var_status), 'admin/reports/apachesolr/' . $env['env_id']);
}
$output['environments_list'] = theme('item_list', $environments_list);
try {
$solr = apachesolr_get_solr($environment['env_id']);
$solr
->clearCache();
$data = $solr
->getLuke();
} catch (Exception $e) {
watchdog('Apache Solr', nl2br(check_plain($e
->getMessage())), NULL, WATCHDOG_ERROR);
drupal_set_message(nl2br(check_plain($e
->getMessage())), "warning");
return $output;
}
$messages = array();
$messages[] = array(
t('Number of documents in index'),
$data->index->numDocs,
);
$limit = variable_get('apachesolr_luke_limit', 20000);
if (isset($data->index->numDocs) && $data->index->numDocs > $limit) {
$messages[] = array(
t('Limit'),
t('You have more than @limit documents, so term frequencies are being omitted for performance reasons.', array(
'@limit' => $limit,
)),
);
$not_found = t('<em>Omitted</em>');
}
elseif (isset($data->index->numDocs)) {
$not_found = t('Not indexed');
try {
$solr = apachesolr_get_solr($environment['env_id']);
// Note: we use 2 since 1 fails on Ubuntu Hardy.
$data = $solr
->getLuke(2);
if (isset($data->index->numTerms)) {
$messages[] = array(
t('# of terms in index'),
$data->index->numTerms,
);
}
} catch (Exception $e) {
watchdog('Apache Solr', nl2br(check_plain($e
->getMessage())), NULL, WATCHDOG_ERROR);
$data->fields = array();
}
}
// Initializes output with information about which server's setting we are
// editing, as it is otherwise not transparent to the end user.
$fields = (array) $data->fields;
if ($fields) {
$messages[] = array(
t('# of fields in index'),
count($fields),
);
}
// Output the messages we have for this page
$output['apachesolr_index_report'] = theme('table', array(
t('Type'),
t('Value'),
), array_values($messages));
if ($fields) {
// Initializes table header.
$header = array(
t('Field name'),
t('Index type'),
t('Distinct terms'),
);
// Builds table rows.
$rows = array();
foreach ($fields as $name => $field) {
// TODO: try to map the name to something more meaningful.
$rows[$name] = array(
'name' => $name,
'type' => $field->type,
'terms' => isset($field->distinct) ? $field->distinct : $not_found,
);
}
ksort($rows);
// Output the fields we found for this environment
$output['field_table'] = theme('table', $header, array_values($rows));
}
else {
$output['field_table'] = '<p>' . t('No data on indexed fields.') . "</p>/n";
}
// Print in a similar way as the Drupal 7 version
$output_print = NULL;
foreach ($output as $print) {
$output_print .= $print;
}
return $output_print;
}