function apachesolr_term_solr_reindex in Apachesolr Term 7
Reindexing callback for ApacheSolr, for taxonomy terms.
1 string reference to 'apachesolr_term_solr_reindex'
- apachesolr_term_apachesolr_entity_info_alter in ./
apachesolr_term.module - @file Indexer for the userhook_apachesolr_entity_info_alter entities for the Apachesolr module.
File
- ./
apachesolr_term.module, line 58 - Indexer for the userhook_apachesolr_entity_info_alter entities for the Apachesolr module.
Code
function apachesolr_term_solr_reindex() {
$indexer_table = apachesolr_get_indexer_table('taxonomy_term');
$transaction = db_transaction();
$env_id = apachesolr_default_environment();
try {
db_delete($indexer_table)
->condition('entity_type', 'taxonomy_term')
->execute();
$select = db_select('taxonomy_term_data', 't');
$select
->innerJoin('taxonomy_vocabulary', 'v', 't.vid = v.vid');
$select
->addField('t', 'tid', 'entity_id');
$select
->addField('v', 'machine_name', 'bundle');
$select
->addExpression(1, 'status');
$select
->addExpression("'taxonomy_term'", 'entity_type');
$select
->addExpression(REQUEST_TIME, 'changed');
$select
->condition('v.machine_name', apachesolr_get_index_bundles($env_id, 'taxonomy_term'), 'IN');
$insert = db_insert($indexer_table)
->fields(array(
'entity_id',
'bundle',
'status',
'entity_type',
'changed',
))
->from($select)
->execute();
} catch (Exception $e) {
$transaction
->rollback();
//drupal_set_message($e->getMessage(), 'error');
watchdog_exception('Apache Solr', $e);
return FALSE;
}
return TRUE;
}