Search code examples
drupalsolrdrupal-7

Drupal 7 Apache solr search module


We have tried to remove the search result for the particular node in Drupal 7. We can't make that change. Is it possible to remove the Apache solr search result for the particular node?. Can any one help us?


Solution

  • You can perform this by adding a filter to the query in hook_apachesolr_query_alter() :

    /**
     * Implementation of hook_apachesolr_query_alter().
     * 
     * @param DrupalSolrQueryInterface $query
     * @see apachesolr.interface.inc
     */
    function yourmodule_apachesolr_query_alter(DrupalSolrQueryInterface $query) {
      $nid = 1234;
      $exclude = TRUE;
      $filter = apachesolr_site_hash() . '/node/' . $nid;
      $query->addFilter('id', $filter, $exclude);
    }