Apache Lucene open-source search software
fix distributed facet counts when field may not exist in shard
Yonik Seeley160f664e5f0e
diff --git a/CHANGES.txt b/CHANGES.txtindex 452e9b3d136..cb14bdd3742 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -206,7 +206,7 @@ New Featuresquery faceting, highlighting, and debug information are supportedin distributed mode.(Sharad Agarwal, Patrick O'Leary, Sabyasachi Dalal, Stu Hood,- ryan, yonik)+ Jayson Minard, ryan, yonik)41. SOLR-356: Pluggable functions (value sources) that allowregistration of new functions via solrconfig.xmldiff --git a/src/java/org/apache/solr/handler/component/FacetComponent.java b/src/java/org/apache/solr/handler/component/FacetComponent.javaindex bdcec74f34e..151d49fa775 100644--- a/src/java/org/apache/solr/handler/component/FacetComponent.java+++ b/src/java/org/apache/solr/handler/component/FacetComponent.java@@ -233,7 +233,7 @@ public class FacetComponent extends SearchComponentfor (DistribFieldFacet dff : fi.topFacets.values()) {ShardFacetCount[] counts = dff.getSorted();int ntop = Math.min(counts.length, dff.offset + dff.limit);- long smallestCount = counts[ntop-1].count;+ long smallestCount = counts.length == 0 ? 0 : counts[ntop-1].count;for (int i=0; i<counts.length; i++) {ShardFacetCount sfc = counts[i];diff --git a/src/test/org/apache/solr/TestDistributedSearch.java b/src/test/org/apache/solr/TestDistributedSearch.javaindex d0f9ee158d8..6a67de267ad 100755--- a/src/test/org/apache/solr/TestDistributedSearch.java+++ b/src/test/org/apache/solr/TestDistributedSearch.java@@ -477,6 +477,7 @@ public class TestDistributedSearch extends TestCase {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);+ query("q","*:*", "rows",100, "facet","true", "facet.field","missing_field_t","facet.mincount",2);// index the same document to two servers and make sure things