Apache Solr open-source search software
SOLR-348: short-circuit faceting if less than mincount docs match
Yonik Seeley1ce8c6feb34a
diff --git a/CHANGES.txt b/CHANGES.txtindex 925af1eb6a0..6d302a4ff25 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -136,6 +136,8 @@ Optimizationswhich flushes deleted without forcing the user to use <commit/> for this purpose.(klaas)+ 3. SOLR-348: short-circuit faceting if less than mincount docs match. (yonik)+Bug Fixes1. Make TextField respect sortMissingFirst and sortMissingLast fields.(J.J. Larrea via yonik)diff --git a/src/java/org/apache/solr/request/SimpleFacets.java b/src/java/org/apache/solr/request/SimpleFacets.javaindex f2043146bca..2a01adf4370 100644--- a/src/java/org/apache/solr/request/SimpleFacets.java+++ b/src/java/org/apache/solr/request/SimpleFacets.java@@ -248,7 +248,7 @@ public class SimpleFacets {final int nTerms=endTermIndex-startTermIndex;- if (nTerms>0) {+ if (nTerms>0 && docs.size() >= mincount) {// count collection array only needs to be as big as the number of terms we are// going to collect counts for.@@ -351,6 +351,8 @@ public class SimpleFacets {String startTerm = prefix==null ? "" : ft.toInternal(prefix);TermEnum te = r.terms(new Term(field,startTerm));TermDocs td = r.termDocs();++ if (docs.size() >= mincount) {do {Term t = te.term();@@ -392,6 +394,7 @@ public class SimpleFacets {}}} while (te.next());+ }if (sort) {for (CountPair<String,Integer> p : queue) {