From 994ae6590c8a7ce3d6f3df64122773c4907019e3 Mon Sep 17 00:00:00 2001 From: Yonik Seeley Date: Wed, 3 Jun 2015 15:03:29 +0000 Subject: [PATCH] SOLR-7616: fix UniqueAgg.NumericAcc.resize git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1683357 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 4 ++++ .../core/src/java/org/apache/solr/search/facet/UniqueAgg.java | 2 +- .../src/test/org/apache/solr/search/facet/TestJsonFacets.java | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index e10ecd0db94..3b944d056c9 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -94,6 +94,10 @@ Bug Fixes * SOLR-7361: Slow loading SolrCores should not hold up all other SolrCores that have finished loading from serving requests. (Mark Miller, Timothy Potter, Ramkumar Aiyengar) +* SOLR-7616: Faceting on a numeric field with a unique() subfacet function on another numeric field + can result in incorrect results or an exception. (yonik) + + Optimizations ---------------------- (no changes) diff --git a/solr/core/src/java/org/apache/solr/search/facet/UniqueAgg.java b/solr/core/src/java/org/apache/solr/search/facet/UniqueAgg.java index 200f3130cd5..2ea752316f9 100644 --- a/solr/core/src/java/org/apache/solr/search/facet/UniqueAgg.java +++ b/solr/core/src/java/org/apache/solr/search/facet/UniqueAgg.java @@ -208,7 +208,7 @@ public class UniqueAgg extends StrAggValueSource { @Override public void resize(Resizer resizer) { - resizer.resize(sets, null); + sets = resizer.resize(sets, null); } @Override diff --git a/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java b/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java index 9978df23b7d..2ca1b0adf17 100644 --- a/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java +++ b/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacets.java @@ -932,6 +932,7 @@ public class TestJsonFacets extends SolrTestCaseHS { ",f8:{ type:field, field:${num_i}, sort:'index desc', offset:100, numBuckets:true }" + // test high offset ",f9:{ type:field, field:${num_i}, sort:'x desc', facet:{x:'avg(${num_d})'}, missing:true, allBuckets:true, numBuckets:true }" + // test stats ",f10:{ type:field, field:${num_i}, facet:{a:{query:'${cat_s}:A'}}, missing:true, allBuckets:true, numBuckets:true }" + // test subfacets + ",f11:{ type:field, field:${num_i}, facet:{a:'unique(${num_d})'} ,missing:true, allBuckets:true, sort:'a desc' }" + // test subfacet using unique on numeric field (this previously triggered a resizing bug) "}" ) , "facets=={count:6 " + @@ -945,6 +946,7 @@ public class TestJsonFacets extends SolrTestCaseHS { ",f8:{ buckets:[] , numBuckets:4 } " + ",f9:{ buckets:[{val:7,count:1,x:11.0},{val:2,count:1,x:4.0},{val:3,count:1,x:2.0},{val:-5,count:2,x:-7.0} ], numBuckets:4, allBuckets:{count:5,x:0.6},missing:{count:1,x:0.0} } " + // TODO: should missing exclude "x" because no values were collected? ",f10:{ buckets:[{val:-5,count:2,a:{count:0}},{val:2,count:1,a:{count:1}},{val:3,count:1,a:{count:1}},{val:7,count:1,a:{count:0}} ], numBuckets:4, allBuckets:{count:5},missing:{count:1,a:{count:0}} } " + + ",f11:{ buckets:[{val:-5,count:2,a:2},{val:2,count:1,a:1},{val:3,count:1,a:1},{val:7,count:1,a:1} ] , missing:{count:1,a:0} , allBuckets:{count:5,a:5} } " + "}" );