Author: yonik
Date: Fri Jun 20 11:38:20 2008
New Revision: 670028

URL: http://svn.apache.org/viewvc?rev=670028&view=rev
Log:
in facet refinement, skip over facet queries that don't look like refinements.  
add test that exercizes refinements.

Modified:
    
lucene/solr/trunk/src/java/org/apache/solr/handler/component/FacetComponent.java
    lucene/solr/trunk/src/test/org/apache/solr/TestDistributedSearch.java

Modified: 
lucene/solr/trunk/src/java/org/apache/solr/handler/component/FacetComponent.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/handler/component/FacetComponent.java?rev=670028&r1=670027&r2=670028&view=diff
==============================================================================
--- 
lucene/solr/trunk/src/java/org/apache/solr/handler/component/FacetComponent.java
 (original)
+++ 
lucene/solr/trunk/src/java/org/apache/solr/handler/component/FacetComponent.java
 Fri Jun 20 11:38:20 2008
@@ -40,7 +40,7 @@
  * @version $Id$
  * @since solr 1.3
  */
-public class FacetComponent extends SearchComponent
+public class  FacetComponent extends SearchComponent
 {
   public static final String COMPONENT_NAME = "facet";
   
@@ -167,7 +167,7 @@
             dff.initialLimit = dff.limit;
           }
 
-          // Uncomment the following line when testing to supress 
over-requesting facets and
+          // TEST: Uncomment the following line when testing to supress 
over-requesting facets and
           // thus cause more facet refinement queries.
           // if (dff.limit > 0) dff.initialLimit = dff.offset + dff.limit;
 
@@ -300,13 +300,24 @@
 
           // expect {!field f=field}value style params
           SolrParams qparams = QueryParsing.getLocalParams(facet_q,null);
+          if (qparams == null) continue;  // not a refinement
           String field = qparams.get(QueryParsing.F);
           String val = qparams.get(QueryParsing.V);
 
           // Find the right field.facet for this field
           DistribFieldFacet dff = fi.topFacets.get(field);
+          if (dff == null) continue;  // maybe this wasn't for facet count 
refinement
+
           // Find the right constraint count for this value
           ShardFacetCount sfc = dff.counts.get(val);
+
+          if (sfc == null) {
+            continue;
+            // Just continue, since other components might have added
+            // this facet.query for other purposes.  But if there are charset
+            // issues then the values coming back may not match the values 
sent.
+          }
+
 // TODO REMOVE
 // System.out.println("Got " + facet_q + " , refining count: " + sfc + " += " 
+ count);
 

Modified: lucene/solr/trunk/src/test/org/apache/solr/TestDistributedSearch.java
URL: 
http://svn.apache.org/viewvc/lucene/solr/trunk/src/test/org/apache/solr/TestDistributedSearch.java?rev=670028&r1=670027&r2=670028&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/TestDistributedSearch.java 
(original)
+++ lucene/solr/trunk/src/test/org/apache/solr/TestDistributedSearch.java Fri 
Jun 20 11:38:20 2008
@@ -487,10 +487,15 @@
             "debugQuery", "true");
 
     query("q","*:*", "rows",100, "facet","true", "facet.field",t1);
+    query("q","*:*", "rows",100, "facet","true", 
"facet.field",t1,"facet.limit",1);
     query("q","*:*", "rows",100, "facet","true", "facet.query","quick", 
"facet.query","all", "facet.query","*:*");
     query("q","*:*", "rows",100, "facet","true", "facet.field",t1, 
"facet.offset",1);
     query("q","*:*", "rows",100, "facet","true", "facet.field",t1, 
"facet.mincount",2);
 
+    // test faceting multiple things at once
+    query("q","*:*", "rows",100, "facet","true", "facet.query","quick", 
"facet.query","all", "facet.query","*:*"
+    ,"facet.field",t1);
+
     // test field that is valid in schema but missing in all shards
     query("q","*:*", "rows",100, "facet","true", "facet.field",missingField, 
"facet.mincount",2);
     // test field that is valid in schema and missing in some shards


Reply via email to