title: Solr boolean queries combined with index-time boosts
body: <p>I have a site using Solr 1.4.1 for relevancy/recommendations. I am using boolean-style queries in some places. I am using a query like <code>+(+type:aoh_company +aoh_dictionary_tids:623)</code> - and that provides the expected results, but the order of the results appear to be arbitrary.</p>
  
  <p>I am trying to control the ranking of the document by setting index-time boosts, but they seem to be ignored for these queries.</p>
  
  <h2>An example</h2>
  
  <ul>
  <li>The query URL is <code>http://localhost:4930/solr/prod/select?rows=5&amp;start=0&amp;q.alt=(type%3Aaoh_company)+(aoh_dictionary_tids%3A623)&amp;q=</code></li>
  <li>The results are returned in this order (with the index time boost value in parentheses):
  <ol>
  <li>17132 (1.22)</li>
  <li>17179 (1.02)</li>
  <li>17131 (1.10)</li>
  <li>17133 (1.10)</li>
  <li>17184 (1.10)</li>
  </ol></li>
  <li>Obviously, result #2 should not come before #3-5 based on the boost alone.</li>
  <li>Given this is a boolean query, there should not be much difference in ranking.</li>
  </ul>
  
  <h3>Debugging output</h3>
  
  <p>I tried debugging the query above by appending <code>debugQuery=true</code> to the query, so it becomes <code>http://localhost:4930/solr/prod/select?rows=5&amp;start=0&amp;q.alt=(type%3Aaoh_company)+(aoh_dictionary_tids%3A623)&amp;q=&amp;debugQuery=true</code></p>
  
  <p>It's very verbose, but here it is:</p>
  
  <pre><code>&lt;lst name="debug"&gt;
    &lt;null name="rawquerystring"/&gt;
    &lt;null name="querystring"/&gt;
    &lt;str name="parsedquery"&gt;+(+type:aoh_company +aoh_dictionary_tids:623)&lt;/str&gt;
    &lt;str name="parsedquery_toString"&gt;+(+type:aoh_company +aoh_dictionary_tids:623)&lt;/str&gt;
    &lt;lst name="explain"&gt;
      &lt;str name="50hves/node/17132"&gt;
      1.7819747 = (MATCH) sum of:
        0.9014403 = (MATCH) weight(type:aoh_company in 1805), product of:
          0.37135038 = queryWeight(type:aoh_company), product of:
            2.4274657 = idf(docFreq=457, maxDocs=1909)
            0.15297863 = queryNorm
          2.4274657 = (MATCH) fieldWeight(type:aoh_company in 1805), product of:
            1.0 = tf(termFreq(type:aoh_company)=1)
            2.4274657 = idf(docFreq=457, maxDocs=1909)
            1.0 = fieldNorm(field=type, doc=1805)
        0.88053435 = (MATCH) weight(aoh_dictionary_tids:623 in 1805), product of:
          0.9284928 = queryWeight(aoh_dictionary_tids:623), product of:
            6.069428 = idf(docFreq=11, maxDocs=1909)
            0.15297863 = queryNorm
          0.9483481 = (MATCH) fieldWeight(aoh_dictionary_tids:623 in 1805), product of:
            1.0 = tf(termFreq(aoh_dictionary_tids:623)=1)
            6.069428 = idf(docFreq=11, maxDocs=1909)
            0.15625 = fieldNorm(field=aoh_dictionary_tids, doc=1805)
      &lt;/str&gt;
      &lt;str name="50hves/node/17179"&gt;
      1.7819747 = (MATCH) sum of:
        0.9014403 = (MATCH) weight(type:aoh_company in 1896), product of:
          0.37135038 = queryWeight(type:aoh_company), product of:
            2.4274657 = idf(docFreq=457, maxDocs=1909)
            0.15297863 = queryNorm
          2.4274657 = (MATCH) fieldWeight(type:aoh_company in 1896), product of:
            1.0 = tf(termFreq(type:aoh_company)=1)
            2.4274657 = idf(docFreq=457, maxDocs=1909)
            1.0 = fieldNorm(field=type, doc=1896)
        0.88053435 = (MATCH) weight(aoh_dictionary_tids:623 in 1896), product of:
          0.9284928 = queryWeight(aoh_dictionary_tids:623), product of:
            6.069428 = idf(docFreq=11, maxDocs=1909)
            0.15297863 = queryNorm
          0.9483481 = (MATCH) fieldWeight(aoh_dictionary_tids:623 in 1896), product of:
            1.0 = tf(termFreq(aoh_dictionary_tids:623)=1)
            6.069428 = idf(docFreq=11, maxDocs=1909)
            0.15625 = fieldNorm(field=aoh_dictionary_tids, doc=1896)
      &lt;/str&gt;
      &lt;str name="50hves/node/17131"&gt;
      1.7819747 = (MATCH) sum of:
        0.9014403 = (MATCH) weight(type:aoh_company in 1905), product of:
          0.37135038 = queryWeight(type:aoh_company), product of:
            2.4274657 = idf(docFreq=457, maxDocs=1909)
            0.15297863 = queryNorm
          2.4274657 = (MATCH) fieldWeight(type:aoh_company in 1905), product of:
            1.0 = tf(termFreq(type:aoh_company)=1)
            2.4274657 = idf(docFreq=457, maxDocs=1909)
            1.0 = fieldNorm(field=type, doc=1905)
        0.88053435 = (MATCH) weight(aoh_dictionary_tids:623 in 1905), product of:
          0.9284928 = queryWeight(aoh_dictionary_tids:623), product of:
            6.069428 = idf(docFreq=11, maxDocs=1909)
            0.15297863 = queryNorm
          0.9483481 = (MATCH) fieldWeight(aoh_dictionary_tids:623 in 1905), product of:
            1.0 = tf(termFreq(aoh_dictionary_tids:623)=1)
            6.069428 = idf(docFreq=11, maxDocs=1909)
            0.15625 = fieldNorm(field=aoh_dictionary_tids, doc=1905)
      &lt;/str&gt;
      &lt;str name="50hves/node/17133"&gt;
      1.7819747 = (MATCH) sum of:
        0.9014403 = (MATCH) weight(type:aoh_company in 1906), product of:
          0.37135038 = queryWeight(type:aoh_company), product of:
            2.4274657 = idf(docFreq=457, maxDocs=1909)
            0.15297863 = queryNorm
          2.4274657 = (MATCH) fieldWeight(type:aoh_company in 1906), product of:
            1.0 = tf(termFreq(type:aoh_company)=1)
            2.4274657 = idf(docFreq=457, maxDocs=1909)
            1.0 = fieldNorm(field=type, doc=1906)
        0.88053435 = (MATCH) weight(aoh_dictionary_tids:623 in 1906), product of:
          0.9284928 = queryWeight(aoh_dictionary_tids:623), product of:
            6.069428 = idf(docFreq=11, maxDocs=1909)
            0.15297863 = queryNorm
          0.9483481 = (MATCH) fieldWeight(aoh_dictionary_tids:623 in 1906), product of:
            1.0 = tf(termFreq(aoh_dictionary_tids:623)=1)
            6.069428 = idf(docFreq=11, maxDocs=1909)
            0.15625 = fieldNorm(field=aoh_dictionary_tids, doc=1906)
      &lt;/str&gt;
      &lt;str name="50hves/node/17184"&gt;
      1.6058679 = (MATCH) sum of:
        0.9014403 = (MATCH) weight(type:aoh_company in 1892), product of:
          0.37135038 = queryWeight(type:aoh_company), product of:
            2.4274657 = idf(docFreq=457, maxDocs=1909)
            0.15297863 = queryNorm
          2.4274657 = (MATCH) fieldWeight(type:aoh_company in 1892), product of:
            1.0 = tf(termFreq(type:aoh_company)=1)
            2.4274657 = idf(docFreq=457, maxDocs=1909)
            1.0 = fieldNorm(field=type, doc=1892)
        0.7044275 = (MATCH) weight(aoh_dictionary_tids:623 in 1892), product of:
          0.9284928 = queryWeight(aoh_dictionary_tids:623), product of:
            6.069428 = idf(docFreq=11, maxDocs=1909)
            0.15297863 = queryNorm
          0.7586785 = (MATCH) fieldWeight(aoh_dictionary_tids:623 in 1892), product of:
            1.0 = tf(termFreq(aoh_dictionary_tids:623)=1)
            6.069428 = idf(docFreq=11, maxDocs=1909)
            0.125 = fieldNorm(field=aoh_dictionary_tids, doc=1892)
      &lt;/str&gt;
    &lt;/lst&gt;
    &lt;str name="QParser"&gt;DisMaxQParser&lt;/str&gt;
    &lt;str name="altquerystring"&gt;org.apache.lucene.search.BooleanQuery:+type:aoh_company +aoh_dictionary_tids:623&lt;/str&gt;
    &lt;null name="boostfuncs"/&gt;
    &lt;lst name="timing"&gt;
      &lt;double name="time"&gt;7.0&lt;/double&gt;
      &lt;lst name="prepare"&gt;
        &lt;double name="time"&gt;1.0&lt;/double&gt;
        &lt;lst name="org.apache.solr.handler.component.QueryComponent"&gt;
          &lt;double name="time"&gt;0.0&lt;/double&gt;
        &lt;/lst&gt;
        &lt;lst name="org.apache.solr.handler.component.FacetComponent"&gt;
        &lt;double name="time"&gt;0.0&lt;/double&gt;
      &lt;/lst&gt;
      &lt;lst name="org.apache.solr.handler.component.MoreLikeThisComponent"&gt;
      &lt;double name="time"&gt;0.0&lt;/double&gt;
    &lt;/lst&gt;
    &lt;lst name="org.apache.solr.handler.component.HighlightComponent"&gt;
      &lt;double name="time"&gt;0.0&lt;/double&gt;
    &lt;/lst&gt;
    &lt;lst name="org.apache.solr.handler.component.StatsComponent"&gt;
      &lt;double name="time"&gt;0.0&lt;/double&gt;
    &lt;/lst&gt;
    &lt;lst name="org.apache.solr.handler.component.SpellCheckComponent"&gt;
      &lt;double name="time"&gt;0.0&lt;/double&gt;
    &lt;/lst&gt;
    &lt;lst name="org.apache.solr.handler.component.DebugComponent"&gt;
      &lt;double name="time"&gt;0.0&lt;/double&gt;
    &lt;/lst&gt;
    &lt;/lst&gt;
    &lt;lst name="process"&gt;
      &lt;double name="time"&gt;6.0&lt;/double&gt;
      &lt;lst name="org.apache.solr.handler.component.QueryComponent"&gt;
        &lt;double name="time"&gt;0.0&lt;/double&gt;
      &lt;/lst&gt;
      &lt;lst name="org.apache.solr.handler.component.FacetComponent"&gt;
        &lt;double name="time"&gt;0.0&lt;/double&gt;
      &lt;/lst&gt;
      &lt;lst name="org.apache.solr.handler.component.MoreLikeThisComponent"&gt;
        &lt;double name="time"&gt;0.0&lt;/double&gt;
      &lt;/lst&gt;
      &lt;lst name="org.apache.solr.handler.component.HighlightComponent"&gt;
        &lt;double name="time"&gt;0.0&lt;/double&gt;
      &lt;/lst&gt;
      &lt;lst name="org.apache.solr.handler.component.StatsComponent"&gt;
        &lt;double name="time"&gt;0.0&lt;/double&gt;
      &lt;/lst&gt;
      &lt;lst name="org.apache.solr.handler.component.SpellCheckComponent"&gt;
        &lt;double name="time"&gt;0.0&lt;/double&gt;
      &lt;/lst&gt;
      &lt;lst name="org.apache.solr.handler.component.DebugComponent"&gt;
        &lt;double name="time"&gt;6.0&lt;/double&gt;
      &lt;/lst&gt;
    &lt;/lst&gt;
  &lt;/lst&gt;
  </code></pre>
  
  <p>As I read it, the first four results are scored <code>1.7819747</code>, and the fifth is scored <code>1.6058679</code>, and I can't see the boost values anywhere in there, so it seems that they are not a factor in the ranking equation.</p>
  
  <p>So what am I doing wrong. Is there something I need to do to make Solr take the boosts into consideration?<br>
  Is there a way to check the boost value stored in Solr? It looks right in the documents I send to it, but I can't find a way to see the stored value?</p>
  
  <p>Additionally, here's the relevant parts from my <code>schema.xml</code>:</p>
  
  <pre><code>&lt;types&gt;
    &lt;fieldType name="string" class="solr.StrField" sortMissingLast="true" omitNorms="true"/&gt;
    &lt;fieldType name="integer" class="solr.IntField" omitNorms="true"/&gt;
  &lt;/types&gt;
  &lt;fields&gt;
    &lt;field name="type" type="string" indexed="true" stored="true"/&gt;
    &lt;field name="aoh_dictionary_tids"  type="integer" indexed="true" stored="true" multiValued="true" omitNorms="false"/&gt;
  &lt;/fields&gt;
  </code></pre>
  
  <p>In his answer below, fyr mentioned that norms need to be enabled on the field for the boost value to apply. So I'd like to amend my question a bit:</p>
  
  <ul>
  <li>Is it enough to have norms enabled on one of the queried fields for the boost to apply?</li>
  <li>Does my <code>omitNorms="false"</code> on the field override the <code>omitNorms="true"</code> on the fieldType?</li>
  </ul>
  
  <p>Any help would be greatly appreciated.</p>