1

I am using hook_apachesolr_exclude but its not working.I have created a custom field if that field is checked i want to exclude that node I wrote the given below code:

function a10_exclude_node_apachesolr_exclude($entity_id, $entity_type, $row, $env_id) {
    $result_node = node_load( $entity_id );
    if( isset( $result_node->field_exclude_from_search['und'][0]['value'] ) and $result_node->field_exclude_from_search['und'][0]['value'] == 1 ){
        return TRUE;
    }
    return FALSE;
}

even when i am writing die inside the hook, hook is not invoking.Please let me know how i can check the above hook is invoking or working.I have also tried the Apache Solr Node Exclude module, when i am checking the node to exclude it does not come inside the result but when again i uncheck the node same result come there and when i uncheck the two or more nodes they do not exclude from search result.

4
  • You should hook up xdebug, drop a breakpoint in your code, clear the Solr index and reindex it. If the breakpoint is hit and execution stops, the hook is invoked. die() is not really useful for debugging in a meaningful way. Short of that... can we rephrase the question to not mention ApacheSOlr Node Exclude so we can focus on the custom module? Otherwise , this module is reported to be working. drupal.org/project/apachesolr_exclude_node
    – Kevin
    Jun 28, 2016 at 14:15
  • I am indexing and reindexing the site from admin using index queued content option, is there any slor admin where we can login and delete the cache or somthing else? Jun 28, 2016 at 14:31
  • also the Apache Solr Node Exclude module is not showing the changes, do we need to flush cache or reindex site after excluding the node or any other option we need to do.. Jun 28, 2016 at 14:33
  • Changes are not immediate, you have to either flush the Solr index and re-index all content, run cron, or trigger a solr index update manually.
    – Kevin
    Jun 28, 2016 at 15:17

1 Answer 1

1

I have fixed the problem to exclude node from Apache Solr search by installing Apache Solr Exclude Node module. To configure this module, please follow the below steps:

  1. Enable excluding of nodes in the submission form settings fieldset in the content type settings (e.g. admin/structure/types/page).

  2. Find the vertical tabs fieldset "Apache Solr exclude" in the node edit form.

    Check "Exclude from Apache Solr" and save.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.