You are here

function apachesolr_remove_entity in Apache Solr Search 7

Same name and namespace in other branches
  1. 8 apachesolr.module \apachesolr_remove_entity()
  2. 6.3 apachesolr.module \apachesolr_remove_entity()

Remove a specific entity from a given Solr environment.

Parameters

string $env_id:

string $entity_type:

string $entity_id:

2 calls to apachesolr_remove_entity()
apachesolr_entity_delete in ./apachesolr.module
Implements hook_entity_delete().
apachesolr_index_entities_document in ./apachesolr.index.inc
Convert a certain entity from the apachesolr index table to a set of documents. 1 entity can be converted in multiple documents if the apachesolr_index_entity_to_documents decides to do so.

File

./apachesolr.module, line 2092
Integration with the Apache Solr search application.

Code

function apachesolr_remove_entity($env_id, $entity_type, $entity_id) {
  module_load_include('inc', 'apachesolr', 'apachesolr.index');
  $indexer_table = apachesolr_get_indexer_table($entity_type);
  if (apachesolr_index_delete_entity_from_index($env_id, $entity_type, $entity_id)) {

    // There was no exception, so delete from the table.
    db_delete($indexer_table)
      ->condition('entity_type', $entity_type)
      ->condition('entity_id', $entity_id)
      ->execute();
  }
  else {

    // Set status 0 so we try to delete from the index again in the future.
    db_update($indexer_table)
      ->condition('entity_id', $entity_id)
      ->fields(array(
      'changed' => REQUEST_TIME,
      'status' => 0,
    ))
      ->execute();
  }
}