I am trying to create an exposed filter that allows users to search Research Interests, and returns a list of employee profiles with that research interest.

Research Interests is a taxonomy term field. Some research interests are multiple words (e.g. Computational Biology) and some are a single word (e.g. Programming).

In Views, I set up an exposed filter on Content: Research Interests with Operator "Is One Of". This seems to work fine if I search for the right thing; if I type in "Computational Biology", it returns a list of employees with that term in their profile.

However....if I enter "Computational", I get no results. It seems that I need to enter the entire taxonomy term, not just one word of the term, in order to get results. I fear that users will find this confusing.

Is there any way to get Views to search a taxonomy term field as if it were a keyword search? So that a search for "Computational" would return results for "Computational Biology", "Computational Thinking", etc? Thank you!


patros’s picture

This is how I handled this situation in Drupal 6...

Create a php filter on the view, I called mine "Keyword Search Filter"...

$filters = $view->get_exposed_input();
if (isset($filters['k']) && (strlen(trim($filters['k'])) > 0)) {
  $keyword = strtolower(trim($filters['k']));
  $terms = taxonomy_node_get_terms($row->nid);
  $terms_list = '';
  foreach ($terms as $term) {
    $terms_list = $terms_list . ' ' . strtolower($term->name);
  if ((strpos(strtolower($row->title), $keyword) !== FALSE) || (strpos($terms_list, $keyword) !== FALSE)) {
    return FALSE;
  } else {
    return TRUE;
} else {
  return FALSE;

Additionally create an exposed filter, I called mine "Keyword Search Dummy Filter". I made mine against the node id, "is not equal to" and the filter identifier of "k". This is to hold the keyword value a user enters which is used by the php filter above.

I think performance probably isn't great but for my application there was a reasonably limited result set to start with.

Hope this helps.

P.S. As you read through you'll probably notice that this also searches against the title as well.