Author: yonik
Date: Thu Jun  4 17:28:56 2009
New Revision: 781801

URL: http://svn.apache.org/viewvc?rev=781801&view=rev
Log:
SOLR-1202: fix facet.mincount distributed facet when sorted=index

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=781801&r1=781800&r2=781801&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
 Thu Jun  4 17:28:56 2009
@@ -369,7 +369,8 @@
       facet_fields.add(dff.getKey(), fieldCounts);
 
       ShardFacetCount[] counts;
-      if (dff.sort.equals(FacetParams.FACET_SORT_COUNT)) {
+      boolean countSorted = dff.sort.equals(FacetParams.FACET_SORT_COUNT);
+      if (countSorted) {
         counts = dff.countSorted;
         if (counts == null || dff.needRefinements) {
           counts = dff.getCountSorted();
@@ -382,7 +383,10 @@
 
       int end = dff.limit < 0 ? counts.length : Math.min(dff.offset + 
dff.limit, counts.length);
       for (int i=dff.offset; i<end; i++) {
-        if (counts[i].count < dff.minCount) break;
+        if (counts[i].count < dff.minCount) {
+          if (countSorted) break;  // if sorted by count, we can break out of 
loop early
+          else continue;
+        }
         fieldCounts.add(counts[i].name, num(counts[i].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=781801&r1=781800&r2=781801&view=diff
==============================================================================
--- lucene/solr/trunk/src/test/org/apache/solr/TestDistributedSearch.java 
(original)
+++ lucene/solr/trunk/src/test/org/apache/solr/TestDistributedSearch.java Thu 
Jun  4 17:28:56 2009
@@ -543,7 +543,9 @@
 
     query("q","*:*", "rows",100, "facet","true", "facet.field",t1);
     query("q","*:*", "rows",100, "facet","true", "facet.field",t1, 
"facet.limit",-1, "facet.sort","count");
+    query("q","*:*", "rows",100, "facet","true", "facet.field",t1, 
"facet.limit",-1, "facet.sort","count", "facet.mincount",2);
     query("q","*:*", "rows",100, "facet","true", "facet.field",t1, 
"facet.limit",-1, "facet.sort","index");
+    query("q","*:*", "rows",100, "facet","true", "facet.field",t1, 
"facet.limit",-1, "facet.sort","index", "facet.mincount",2);
     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);


Reply via email to