title: Trouble with negative facet query using solr for missing value
body: <p>I'm working on a product filter for our website and have run into some difficulties regards to using "facet.missing = true".</p>
  
  <p>I know that I'm supposed to use a query filter like "fq=-facetField:[* TO *]" to filter the results to products with that field missing.</p>
  
  <p>I have built a global filter helper for my application that builds the fq parameter dynamically for ALL queries to prevent any from missing out on user permission based filters which essentially looks like this (php):</p>
  
  <pre><code>$params['fq'] = sprintf('((%s) AND (%s))', $custom, $system);
  </code></pre>
  
  <p>Where $system is the global permission based filter, which might look like (not actual but similar):</p>
  
  <pre><code>(isdiscontinued:0 AND ishidden:0 AND contract:3)
  </code></pre>
  
  <p>$custom contains the actual filter query the user is building via the UI. Let's say the notebook bluetooth filter has the name fq_bluetooth with values: No, Yes, or the value is missing.  This would make the final fq look like:</p>
  
  <pre><code>((-fq_bluetooth:[* TO *]) AND ((isdiscontinued:0 AND ishidden:0 AND contract:3)))
  </code></pre>
  
  <p>However this returns 0 products for the query I'm sending for this category.</p>
  
  <p>If I modify the filter query to:</p>
  
  <pre><code>((fq_bluetooth:[* TO *]) AND ((isdiscontinued:0 AND ishidden:0 AND contract:3)))
  </code></pre>
  
  <p>Then I get the result could expected of the counts of Yes + No, disregarding the unspecified.</p>
  
  <p>How should I be formatting the filter query to get this to work properly?</p>
  
  <p>[edit]</p>
  
  <p>I might also want to combine the facets and maybe filter on only products with No bluetooth or ones where bluetooth isn't specified. So maybe like this (which of course doesn't work either):</p>
  
  <pre><code>((-fq_bluetooth:[* TO *] OR fq_bluetooth:"No") AND ((isdiscontinued:0 AND ishidden:0 AND contract:3)))
  </code></pre>
  
  <p>I'm noticing with debugQuery on, I'm seeing a filter query like:</p>
  
  <pre><code>fq_bluetooth:("No" OR -[* TO *])
  </code></pre>
  
  <p>being parsed as:</p>
  
  <pre><code>fq_bluetooth:No -fq_bluetooth:[* TO *]
  </code></pre>
  
  <p>I'm not seeing the OR in the parsed query - and from my research the fq parameter queries don't honor the OR operator(??).</p>
  
  <p>Maybe the OR is working, but as the negative query seems to be failing by itself, perhaps that's why I can't see the OR working when combined like this.</p>