Answers.Body: <p>Indeed, civicrm_handler_filter_pseudo_constant.inc should be altered and</p>
  
  <p><code>class civicrm_handler_filter_pseudo_constant extends views_handler_filter_in_operator</code>  </p>
  
  <p>should be replaced by </p>
  
  <pre><code>class civicrm_handler_filter_pseudo_constant extends views_handler_filter_many_to_one 
  </code></pre>
  
  <p>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.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-24T20:32:06.993Z
Answers.LastActivityDate: 2016-10-24T20:32:06.993Z
Answers.UserDisplayName: yurg
Body: <p>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).  </p>
  
  <p>Example:</p>
  
  <ul>
  <li><p>Bob has "black", "white", "yellow" tags; </p></li>
  <li><p>Sarah has "red" and "yellow" tags.    </p>
  
  <hr></li>
  <li><p>Searching by "yellow" returns Bob and Sarah</p></li>
  <li><p>Searching by "black" and "yellow" returns Bob and Sarah again, while we've expected to get Bob only.</p></li>
  </ul>
  
  <p>How it would be possible to perform an exact match search? </p>
  
  <p>Drupal 7.x, CiviCRM 6.21</p>
  
  <p>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. </p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-10-21T08:05:50.847Z
Comments.Text: 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)
Comments.UserDisplayName: petednz - fuzion
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-10-23T23:08:09.800Z
Comments.Text: Wish it was so easy.. Have tried almost any possible (and some impossible) combination of Views filters: no luck so far.
Comments.UserDisplayName: yurg
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-10-24T08:54:46.663Z
Comments.Text: Actually, even "native" advanced CiviCRM search works almost the same: search by two tags gives results concatenated by OR rather than AND.
Comments.UserDisplayName: yurg
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2016-10-24T20:28:50.253Z
Comments.Text: Pull request against civicrm-drupal 7x-4.6 has been created in order to fix this https://github.com/civicrm/civicrm-drupal/commit/4437514a8744d7fe67896161984082d5017cf354
Comments.UserDisplayName: yurg
Tags: <drupal><custom-fields><drupal-views><tags>
Title: Drupal Views Exposed Filter (operators) and CiviCRM Multiple Tags
ThreadText: # Drupal Views Exposed Filter (operators) and CiviCRM Multiple Tags
  
  (Asked by: username_0 on 2016-10-20)
  
  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).
  
  Example:
  
  * 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.
  
  **Tags:** drupal, custom-fields, drupal-views, tags
  
  > **Comments:**
  > **username_1**: 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)  
  > **username_0**: Wish it was so easy.. Have tried almost any possible (and some impossible) combination of Views filters: no luck so far.  
  > **username_0**: Actually, even "native" advanced CiviCRM search works almost the same: search by two tags gives results concatenated by OR rather than AND.  
  > **username_0**: Pull request against civicrm-drupal 7x-4.6 has been created in order to fix this https://github.com/civicrm/civicrm-drupal/commit/4437514a8744d7fe67896161984082d5017cf354  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2016-10-24. Score: 2 | Accepted answer
  
  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.
  
  
  ---
  
  