I have a problem with multifaceting in Solr 4.0 and would appreciate any 
insight.

My base query returns the documents and facet counts I expect. After adding an 
fq the result set of documents is smaller and the facet counts go down as 
expected.

What I want is the smaller result set but to have the facets counts ignore the 
fq. I see here 
http://wiki.apache.org/solr/SimpleFacetParameters#Tagging_and_excluding_Filters 
that the way to do that is to tag the fq and to exclude it in the facet.field.

I've implemented the syntax from the above documentation, and what I get is the 
before-I-added-the-fq facet counts (good), and the original result set of 
documents (bad). Any ideas as to what I could have missed?

Debug output on the original query:

  <lst name="responseHeader">
    <int name="status">0</int>
    <int name="QTime">15</int>
    <lst name="params">
      <str name="facet">on</str>
      <str name="facet.mincount">1</str>
      <str name="facet.limit">50</str>
      <str name="wt">xml</str>
      <str name="rows">2500</str>
      <str name="df">title_tracings_t</str>
      <str name="fl">flrid,nodeid</str>
      <str name="debugQuery">true</str>
      <str name="facet.sort">count</str>
      <str name="q">(hiccup)</str>
      <str name="debug.explain.structured">true</str>
      <arr name="facet.field">
        <str>interestlevel</str>
        <str>availability</str>
      </arr>
    </lst>
  </lst>
  <result name="response" numFound="68" start="0">
  ...
  <lst name="facet_counts">
    <lst name="facet_queries"/>
    <lst name="facet_fields">
      <lst name="interestlevel">
        <int name="K-3">32</int>
        <int name="3-6">18</int>
        <int name="AD">7</int>
        <int name="5-8">1</int>
      </lst>
      <lst name="availability">
        <int name="U">37</int>
        <int name="A">29</int>
        <int name="N">2</int>
      </lst>
    </lst>
    <lst name="facet_dates"/>
    <lst name="facet_ranges"/>
  </lst>

and the query after having added the fq and the tag/ex syntax:

  <lst name="responseHeader">
    <int name="status">0</int>
    <int name="QTime">17</int>
    <lst name="params">
      <str name="facet">on</str>
      <str name="facet.mincount">1</str>
      <str name="facet.limit">50</str>
      <str name="wt">xml</str>
      <str name="rows">2500</str>
      <str name="df">title_tracings_t</str>
      <str name="fl">flrid,nodeid</str>
      <str name="debugQuery">true</str>
      <str name="facet.sort">count</str>
      <str name="q">(hiccup)</str>
      <str name="debug.explain.structured">true</str>
      <arr name="facet.field">
        <str>{!ex=foo}interestlevel</str>
        <str>availability</str>
      </arr>
      <str name="fq">({!edismax tag=foo}interestlevel:AD)</str>
    </lst>
  </lst>
  <result name="response" numFound="68" start="0">
  ...
  <lst name="facet_counts">
    <lst name="facet_queries"/>
    <lst name="facet_fields">
      <lst name="interestlevel">
        <int name="K-3">32</int>
        <int name="3-6">18</int>
        <int name="AD">7</int>
        <int name="5-8">1</int>
      </lst>
      <lst name="availability">
        <int name="U">37</int>
        <int name="A">29</int>
        <int name="N">2</int>
      </lst>
    </lst>
    <lst name="facet_dates"/>
    <lst name="facet_ranges"/>
  </lst>

The only difference bewtween them is that the interestlevel facet is now 
"<str>{!ex=foo}interestlevel</str>" and the addition of the fq "<str 
name="fq">({!edismax tag=foo}interestlevel:AD)</str>".

The parsed fq:

      <str name="QParser">LuceneQParser</str>
      <arr name="filter_queries">
        <str>({!edismax tag=foo}interestlevel:AD)</str>
      </arr>
      <arr name="parsed_filter_queries">
        <str>title_tracings_t:{!edismax TO tag=foo} interestlevel:AD</str>
      </arr>

If I remove the local params altogether, leaving just the fq, the result set 
and facets are as expected:

    <result name="response" numFound="7" start="0">
    ...
    <lst name="facet_counts">
      <lst name="facet_queries"/>
      <lst name="facet_fields">
        <lst name="interestlevel">
          <int name="AD">7</int>
        </lst>
        <lst name="availability">
          <int name="U">4</int>
          <int name="A">3</int>
        </lst>
      </lst>
      <lst name="facet_dates"/>
      <lst name="facet_ranges"/>
    </lst>


I have some leads--possibly just red herrings--but have not made much progress 
on them so far:

* The query that implements the tag/ex syntax does not compile unless I include 
"!dismax" or "!edismax" in the new fq's local params. I don't know if this is 
relevant.

* Is the parsed fq info saying that the fq's local params (the tag=) with the 
df rather than with the fq's field?

* I might be running into https://issues.apache.org/jira/browse/SOLR-3819

Thanks for your help,

Mike O'Regan

Reply via email to