We expose CiviCRM contact tags (Tag Name) fields via Drupal Views in order to create simple contacts search by tag(s) via Drupal as front-end. Since almost every contact has more than one tag, "Allow multiple selections" option for exposed filter is being selected in order to narrow searches. However, search by multiple tags gives all contacts, not an "exact match" (mean, only contacts which have all of selected tags).


  • Bob has "black", "white", "yellow" tags;

  • Sarah has "red" and "yellow" tags.

  • Searching by "yellow" returns Bob and Sarah

  • Searching by "black" and "yellow" returns Bob and Sarah again, while we've expected to get Bob only.

How it would be possible to perform an exact match search?

Drupal 7.x, CiviCRM 6.21

P.S. civicrm.core.inc describes "civicrm_handler_filter_pseudo_constant" as exposed filter handler for civicrm tag field; civicrm_handler_filter_pseudo_constant extends views_handler_field_in_operator and allows only "Is one of" and "Is not one of" operators to choose from; wouldn't it be more logical to use something like "many_to_one" handler? If memory serves, it's being used for Drupal taxonomy and provides exact match for search nodes by multiple taxonomy terms.

  • isn't this something you can accomplish within Views filters by adding a filter group and including the Tag field multiple times with the relevant AND or OR to give you what you need? (warning I only skim read this)
    – petednz - fuzion
    Commented Oct 21, 2016 at 8:05
  • Wish it was so easy.. Have tried almost any possible (and some impossible) combination of Views filters: no luck so far.
    – yurg
    Commented Oct 23, 2016 at 23:08
  • Actually, even "native" advanced CiviCRM search works almost the same: search by two tags gives results concatenated by OR rather than AND.
    – yurg
    Commented Oct 24, 2016 at 8:54
  • 2
    Pull request against civicrm-drupal 7x-4.6 has been created in order to fix this github.com/civicrm/civicrm-drupal/commit/…
    – yurg
    Commented Oct 24, 2016 at 20:28

1 Answer 1


Indeed, civicrm_handler_filter_pseudo_constant.inc should be altered and

class civicrm_handler_filter_pseudo_constant extends views_handler_filter_in_operator

should be replaced by

class civicrm_handler_filter_pseudo_constant extends views_handler_filter_many_to_one 

Funny, I made a pull request in May 2016 (against wrong branch though so it was closed) and made it again in October. Hope this time it will pass.

Your Answer

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

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