title: Changing the default operator from OR to AND in Solr (Magento Enterprise)
body: <p>I'm using Solr with Magento Enterprise. I'm trying to change the default search operator from <code>OR</code> to <code>AND</code> to make searches more specific by default.</p>
  
  <p>The first thing I tried was to to change <code>defaultOperator</code> in <code>schema.xml</code> which did not have the desired effect (it started using <code>AND</code> between fields, not keywords).</p>
  
  <pre><code>&lt;solrQueryParser defaultOperator="AND"/&gt;
  </code></pre>
  
  <p>I then read about <a href="http://wiki.apache.org/solr/LocalParams" rel="noreferrer">LocalParams</a> and tried adding that to several <code>requestHandler</code> sections in <code>solrconfig.xml</code> (I'm just guessing where it's supposed to go, I can't find any helpful documentation).</p>
  
  <pre><code>&lt;requestHandler name="magento_en" class="solr.SearchHandler"&gt;
      &lt;lst name="defaults"&gt;
          &lt;str name="q.op"&gt;AND&lt;/str&gt;
  </code></pre>
  
  <p>I also poked around in the code (<code>app/core/core/Enterprise/Search</code>), hard-coded <code>{!q.op=AND}</code> to the queries but still couldn't get it to work.</p>
  
  <p>I imagine it's a simple configuration change, can anyone point me in the right direction?</p>
  
  <p><strong>Edit:</strong> To clarify, a search for "red jacket" (without quotes) should return results for "red AND jacket". I'm only interested in products that are actually red jackets, not red shoes and/or blue jackets. A manual search for "red AND jacket" returns the results that I'm after.</p>
  
  <p>Currently a search performs these queries:</p>
  
  <pre><code>INFO: [] webapp=/solr path=/select params={start=0&amp;q=articles_title:red+jacket*+articles_summary:red+jacket*+articles_text:red+jacket*+cms_title:red+jacket*+cms_content:red+jacket*&amp;json.nl=map&amp;wt=json&amp;fq=store_id:1+store_id:0&amp;version=1.2&amp;rows=4} hits=7 status=0 QTime=1 
  09/01/2013 10:46:21 AM org.apache.solr.core.SolrCore execute
  INFO: [] webapp=/solr path=/select params={spellcheck=true&amp;sort=attr_sort_score_en+desc&amp;spellcheck.extendedResults=true&amp;json.nl=map&amp;wt=json&amp;spellcheck.collate=true&amp;version=1.2&amp;rows=1&amp;fl=id&amp;start=0&amp;q=(Red+jacket)&amp;spellcheck.dictionary=magento_spell_en&amp;q.op=AND&amp;spellcheck.count=2&amp;qt=magento_en&amp;fq=(visibility:3+OR+visibility:4)+AND+store_id:1} hits=645 status=0 QTime=5 
  09/01/2013 10:46:21 AM org.apache.solr.core.SolrCore execute
  INFO: [] webapp=/solr path=/select params={facet=on&amp;sort=score+desc&amp;json.nl=map&amp;wt=json&amp;version=1.2&amp;rows=24&amp;fl=id&amp;start=0&amp;facet.query=category_ids:8&amp;facet.query=category_ids:46&amp;facet.query=category_ids:88&amp;facet.query=category_ids:126&amp;facet.query=category_ids:168&amp;facet.query=category_ids:180&amp;facet.query=category_ids:207&amp;facet.query=category_ids:224&amp;facet.query=category_ids:242&amp;facet.query=category_ids:276&amp;q=(Red+jacket)&amp;q.op=AND&amp;facet.field=attr_nav_multi_colourway&amp;qt=magento_en&amp;fq=(visibility:3+OR+visibility:4)+AND+store_id:1} hits=645 status=0 QTime=5 
  09/01/2013 10:46:22 AM org.apache.solr.core.SolrCore execute
  INFO: [] webapp=/solr path=/select params={facet=on&amp;sort=attr_sort_score_en+desc&amp;json.nl=map&amp;wt=json&amp;rows=100&amp;version=1.2&amp;start=0&amp;facet.query=category_ids:8&amp;facet.query=category_ids:46&amp;facet.query=category_ids:88&amp;facet.query=category_ids:126&amp;facet.query=category_ids:168&amp;facet.query=category_ids:180&amp;facet.query=category_ids:207&amp;facet.query=category_ids:224&amp;facet.query=category_ids:242&amp;facet.query=category_ids:276&amp;q=(Red+jacket)&amp;q.op=AND&amp;facet.field=attr_nav_multi_colourway&amp;qt=magento_en&amp;fq=(visibility:3+OR+visibility:4)+AND+store_id:1} hits=645 status=0 QTime=6 
  09/01/2013 10:46:22 AM org.apache.solr.core.SolrCore execute
  INFO: [] webapp=/solr path=/select params={facet=on&amp;sort=attr_sort_score_en+desc&amp;json.nl=map&amp;wt=json&amp;rows=100&amp;version=1.2&amp;start=0&amp;facet.query=category_ids:8&amp;facet.query=category_ids:46&amp;facet.query=category_ids:88&amp;facet.query=category_ids:126&amp;facet.query=category_ids:168&amp;facet.query=category_ids:180&amp;facet.query=category_ids:207&amp;facet.query=category_ids:224&amp;facet.query=category_ids:242&amp;facet.query=category_ids:276&amp;q=(Red+jacket)&amp;q.op=AND&amp;facet.field=attr_nav_multi_colourway&amp;qt=magento_en&amp;fq=(visibility:3+OR+visibility:4)+AND+store_id:1} hits=645 status=0 QTime=3 
  </code></pre>