You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by va...@apache.org on 2018/09/11 18:16:48 UTC

lucene-solr:master: SOLR-11836: FacetStream works with bucketSizeLimit of -1 which will fetch all the buckets

Repository: lucene-solr
Updated Branches:
  refs/heads/master 398074d0f -> d35d2063a


SOLR-11836: FacetStream works with bucketSizeLimit of -1 which will fetch all the buckets


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/d35d2063
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/d35d2063
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/d35d2063

Branch: refs/heads/master
Commit: d35d2063a817b4b4a6975115860624686afe8964
Parents: 398074d
Author: Varun Thacker <va...@apache.org>
Authored: Tue Sep 11 10:58:04 2018 -0700
Committer: Varun Thacker <va...@apache.org>
Committed: Tue Sep 11 10:58:04 2018 -0700

----------------------------------------------------------------------
 solr/CHANGES.txt                                            | 3 +++
 solr/solr-ref-guide/src/stream-source-reference.adoc        | 2 +-
 .../org/apache/solr/client/solrj/io/stream/FacetStream.java | 7 +++++--
 .../apache/solr/client/solrj/io/stream/StreamingTest.java   | 9 +++++++++
 4 files changed, 18 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d35d2063/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index f9e5b56..c3ab65b 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -339,6 +339,9 @@ Bug Fixes
 
 * SOLR-12733: SolrMetricReporterTest failure (Erick Erickson, David Smiley)
 
+* SOLR-11836: FacetStream works with bucketSizeLimit of -1 which will fetch all the buckets.
+  (Alfonso Muñoz-Pomer Fuentes via Varun Thacker)
+
 Optimizations
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d35d2063/solr/solr-ref-guide/src/stream-source-reference.adoc
----------------------------------------------------------------------
diff --git a/solr/solr-ref-guide/src/stream-source-reference.adoc b/solr/solr-ref-guide/src/stream-source-reference.adoc
index 042463c..c31639a 100644
--- a/solr/solr-ref-guide/src/stream-source-reference.adoc
+++ b/solr/solr-ref-guide/src/stream-source-reference.adoc
@@ -131,7 +131,7 @@ The `facet` function provides aggregations that are rolled up over buckets. Unde
 * `q`: (Mandatory) The query to build the aggregations from.
 * `buckets`: (Mandatory) Comma separated list of fields to rollup over. The comma separated list represents the dimensions in a multi-dimensional rollup.
 * `bucketSorts`: Comma separated list of sorts to apply to each dimension in the buckets parameters. Sorts can be on the computed metrics or on the bucket values.
-* `bucketSizeLimit`: The number of buckets to include. This value is applied to each dimension.
+* `bucketSizeLimit`: The number of buckets to include. This value is applied to each dimension. '-1' will fetch all the buckets.
 * `metrics`: List of metrics to compute for the buckets. Currently supported metrics are `sum(col)`, `avg(col)`, `min(col)`, `max(col)`, `count(*)`.
 
 === facet Syntax

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d35d2063/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java
index 4010ff42..4564ba0 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java
@@ -161,8 +161,8 @@ public class FacetStream extends TupleStream implements Expressible  {
     int limitInt = 0;
     try{
       limitInt = Integer.parseInt(limitStr);
-      if(limitInt <= 0){
-        throw new IOException(String.format(Locale.ROOT,"invalid expression %s - limit '%s' must be greater than 0.",expression, limitStr));
+      if(limitInt <= 0 && limitInt != -1){
+        throw new IOException(String.format(Locale.ROOT,"invalid expression %s - limit '%s' must be greater than 0 or -1.",expression, limitStr));
       }
     }
     catch(NumberFormatException e){
@@ -223,6 +223,9 @@ public class FacetStream extends TupleStream implements Expressible  {
     this.buckets = buckets;
     this.metrics = metrics;
     this.bucketSizeLimit   = bucketSizeLimit;
+    if (this.bucketSizeLimit == -1) {
+      this.bucketSizeLimit = Integer.MAX_VALUE;
+    }
     this.collection = collection;
     this.bucketSorts = bucketSorts;
     

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d35d2063/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.java
index 8f21100..ea3ec36 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamingTest.java
@@ -1076,6 +1076,15 @@ public void testParallelRankStream() throws Exception {
       assertEquals(7.5, avgi.doubleValue(), 0.1);
       assertEquals(5.5, avgf.doubleValue(), 0.1);
       assertEquals(2, count.doubleValue(), 0.1);
+
+      sorts[0] = new FieldComparator("a_s", ComparatorOrder.ASCENDING);
+
+      facetStream = new FacetStream(zkHost, COLLECTIONORALIAS, sParamsA, buckets, metrics, sorts, -1);
+      facetStream.setStreamContext(streamContext);
+      tuples = getTuples(facetStream);
+
+      assertEquals(3, tuples.size());
+
     } finally {
       solrClientCache.close();
     }