function apachesolr_attachments_solr_reindex in Apache Solr Attachments 7
Same name and namespace in other branches
- 6.3 apachesolr_attachments.module \apachesolr_attachments_solr_reindex()
Reindexing callback for ApacheSolr, for file entities.
3 calls to apachesolr_attachments_solr_reindex()
- apachesolr_attachments_confirm_submit in ./
apachesolr_attachments.admin.inc - Form submit handler for the index confirmation form
- apachesolr_attachments_delete_index in ./
apachesolr_attachments.admin.inc - apachesolr_attachments_update_7003 in ./
apachesolr_attachments.install - Change DB tables to support multiple entity indexing.
1 string reference to 'apachesolr_attachments_solr_reindex'
- apachesolr_attachments_apachesolr_entity_info_alter in ./
apachesolr_attachments.module - @file Indexer for the userhook_apachesolr_entity_info_alter entities for the Apachesolr module.
File
- ./
apachesolr_attachments.module, line 267 - Provides a file attachment search implementation for use with the Apache Solr module
Code
function apachesolr_attachments_solr_reindex() {
module_load_include('inc', 'apachesolr_attachments', 'apachesolr_attachments.index');
$indexer_table = apachesolr_get_indexer_table('file');
$transaction = db_transaction();
$env_id = apachesolr_default_environment();
try {
$files = _apachesolr_attachments_get_all_files();
// If we do not have files, return success
if (empty($files)) {
return TRUE;
}
// Loop over all the files and add them to our indexing table
foreach ($files as $parent_entity_type => $parent_entities) {
foreach ($parent_entities as $parent_entity_info) {
// Fake our file class
$file = new stdClass();
foreach ($parent_entity_info->extraFields as $key => $value) {
if (strpos($key, '_fid')) {
$file->fid = $parent_entity_info->extraFields->{$key};
}
}
list($parent_entity_id) = entity_extract_ids($parent_entity_type, $parent_entity_info);
apachesolr_attachments_add_file_usage($file, $parent_entity_type, $parent_entity_id);
}
}
} catch (Exception $e) {
$transaction
->rollback();
drupal_set_message($e
->getMessage(), 'error');
watchdog_exception('Apache Solr Attachments', $e);
return FALSE;
}
return TRUE;
}