You are here

function apachesolr_commentsearch_delete_comment_from_index in Apache Solr Search 6.2

Removes a comment from the index.

Parameters

object $comment: The comment to remove.

Return value

boolean TRUE if comment removed from index, FALSE otherwise.

See also

apachesolr_delete_node_from_index()

1 call to apachesolr_commentsearch_delete_comment_from_index()
apachesolr_commentsearch_comment in contrib/apachesolr_commentsearch/apachesolr_commentsearch.module
Removes the comment from the index if the comment is deleted or unpublished.

File

contrib/apachesolr_commentsearch/apachesolr_commentsearch.module, line 140

Code

function apachesolr_commentsearch_delete_comment_from_index($comment) {
  static $failed = FALSE;
  if ($failed) {
    return FALSE;
  }
  try {
    $solr = apachesolr_get_solr();
    $solr
      ->deleteById(apachesolr_document_id($comment->cid, 'comment'));
    apachesolr_index_set_last_updated(time());
    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;
  }
}