function apachesolr_user_solr_reindex in Apachesolr User 7
Reindexing callback for ApacheSolr, for users.
1 string reference to 'apachesolr_user_solr_reindex'
- apachesolr_user_apachesolr_entity_info_alter in ./
apachesolr_user.module - @file Indexer for the user entities for the Apachesolr module.
File
- ./
apachesolr_user.module, line 116 - Indexer for the user entities for the Apachesolr module.
Code
function apachesolr_user_solr_reindex($env_id = NULL, $bundle = NULL) {
$indexer_table = apachesolr_get_indexer_table('user');
$transaction = db_transaction();
if (empty($env_id)) {
$env_id = apachesolr_default_environment();
}
try {
db_delete($indexer_table)
->condition('entity_type', 'user')
->execute();
// We know there's only one bundle type, so if that doesn't get indexed just
// skip this entirely.
if (apachesolr_get_index_bundles($env_id, 'user')) {
$select = db_select('users', 'u');
$select
->addExpression("'user'", 'entity_type');
$select
->addExpression("'user'", 'bundle');
$select
->addField('u', 'uid', 'entity_id');
$select
->addField('u', 'status', 'status');
$select
->addExpression(REQUEST_TIME, 'changed');
$insert = db_insert($indexer_table)
->fields(array(
'entity_id',
'status',
'entity_type',
'bundle',
'changed',
))
->from($select)
->execute();
}
} catch (Exception $e) {
$transaction
->rollback();
drupal_set_message($e
->getMessage(), 'error');
watchdog_exception('Apache Solr', $e);
return FALSE;
}
return TRUE;
}