You are here

function apachesolr_remove_entity in Apache Solr Search 6.3

Same name and namespace in other branches
  1. 8 apachesolr.module \apachesolr_remove_entity()
  2. 7 apachesolr.module \apachesolr_remove_entity()
2 calls to apachesolr_remove_entity()
apachesolr_entity_delete in ./apachesolr.module
Helper function for the hook_nodeapi().
apachesolr_index_entities_document in ./apachesolr.index.inc

File

./apachesolr.module, line 2040
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.
    $query = "DELETE FROM {{$indexer_table}} WHERE entity_type = '%s' AND entity_id = %d";
    db_query($query, array(
      $entity_type,
      $entity_id,
    ));
  }
  else {

    // Set status 0 so we try to delete from the index again in the future.
    $query = "UPDATE {{$indexer_table}} asn SET asn.changed = '%s', status = %d WHERE asn.entity_id = %d";
    db_query($query, array(
      APACHESOLR_REQUEST_TIME,
      0,
      $entity_id,
    ));
  }
}