Exclude taxonomy terms from search_excerpt in snippet In search-result.tpl.php or in preprocess_search_result function, I want to keep $snippet. It is a great view to display search results.

But Apache Solr results, or Search module results, are displayed with terms that matches the query. These terms are designed to be hidden to anonymous. They can't be displayed in the snippet.


  ex: Marguerite Duras … histoire " avec DURAS. Celle de deux personnes qui se reconnaissent avant de se connaître. Une … "Qui est Marguerite Duras ?" Il avait découvert l'écrivain, il allait rencontrer la …


The term Marguerite Duras is an admin tag. By the way, it is nice that the score relevancy depends on it.

How is created the snippet, or search_excerpt ?  I tried the Taxonomy Hide module, but it doesn't affect search results.
The search result is a node view and hence the hook_node_view_alter works for it.

So you would could create a custom module and write the following function

function custom_node_view_alter(&amp;$build, $type)
{
    if (($build['#view_mode'] == 'search_result') &amp;&amp; ($type = 'node'))
    {
        unset($build['field_tags']);
    }
}


change the field_tags to the name of your taxonomy field in the content type.

$build['#view_mode'] this variable defines the view we are on. In this case we are on the search_result view. And the $type defines the module in this case it is the node. 

Use the following for Drupal 6

function custom_nodeapi(&amp;$node, $op, $a3, $a4) {


  switch ($op) {
     case 'search result':
          $node = node_load($node-&gt;nid);
        $node-&gt;build_mode = NODE_BUILD_SEARCH_RESULT;
        $node = node_build_content($node, FALSE, FALSE);
        $node-&gt;body = drupal_render($node-&gt;content);
      break;
  }
}