function apachesolr_index_delete_entity_from_index in Apache Solr Search 6.3
Same name and namespace in other branches
- 8 apachesolr.index.inc \apachesolr_index_delete_entity_from_index()
- 7 apachesolr.index.inc \apachesolr_index_delete_entity_from_index()
Delete an entity from the index.
Also deletes all documents that have the deleted document as a parent.
Parameters
string $env_id:
string $entity_type:
string $entity_id:
Return value
TRUE on success, FALSE on failure.
1 call to apachesolr_index_delete_entity_from_index()
File
- ./
apachesolr.index.inc, line 648 - Functions related to Apache Solr indexing operations.
Code
function apachesolr_index_delete_entity_from_index($env_id, $entity_type, $entity_id) {
static $failed = FALSE;
if ($failed) {
return FALSE;
}
if (apachesolr_environment_variable_get($env_id, 'apachesolr_read_only', APACHESOLR_READ_WRITE) == APACHESOLR_READ_ONLY) {
return FALSE;
}
try {
$solr = apachesolr_get_solr($env_id);
$document_id = apachesolr_document_id($entity_id, $entity_type);
$query = "id:{$document_id} OR sm_parent_document_id:{$document_id}";
$solr
->deleteByQuery($query);
apachesolr_set_last_index_updated($env_id, APACHESOLR_REQUEST_TIME);
// Log the query used for deletion.
watchdog('Apache Solr', 'Deleted documents from index with query @query', array(
'@query' => $query,
), WATCHDOG_INFO);
return TRUE;
} catch (Exception $e) {
watchdog('Apache Solr', nl2br(check_plain($e
->getMessage())), NULL, WATCHDOG_ERROR);
// Don't keep trying queries if they are failing.
$failed = TRUE;
return FALSE;
}
}