From 66bfdcbdbab8f294341232946a30a61898228a34 Mon Sep 17 00:00:00 2001 From: yonik Date: Tue, 28 Mar 2017 19:52:51 -0400 Subject: [PATCH] SOLR-7452: change terminology from _m missing-bucket to _p partial-bucket for refinement --- .../solr/search/facet/FacetFieldProcessor.java | 6 +++--- .../search/facet/FacetRequestSortedMerger.java | 16 ++++++++-------- .../search/facet/TestJsonFacetRefinement.java | 11 +++++------ 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessor.java b/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessor.java index 97d8607aaf4..a29e78d9e6c 100644 --- a/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessor.java +++ b/solr/core/src/java/org/apache/solr/search/facet/FacetFieldProcessor.java @@ -530,13 +530,13 @@ abstract class FacetFieldProcessor extends FacetProcessor { protected SimpleOrderedMap refineFacets() throws IOException { List leaves = asList(fcontext.facetInfo.get("_l")); // We have not seen this bucket: do full faceting for this bucket, including all sub-facets List skip = asList(fcontext.facetInfo.get("_s")); // We have seen this bucket, so skip stats on it, and skip sub-facets except for the specified sub-facets that should calculate specified buckets. - List missing = asList(fcontext.facetInfo.get("_m")); // We have not seen this bucket, do full faceting for this bucket, and most sub-facets... but some sub-facets should only visit specified buckets. + List partial = asList(fcontext.facetInfo.get("_p")); // We have not seen this bucket, do full faceting for this bucket, and most sub-facets... but some sub-facets are partial and should only visit specified buckets. // For leaf refinements, we do full faceting for each leaf bucket. Any sub-facets of these buckets will be fully evaluated. Because of this, we should never // encounter leaf refinements that have sub-facets that return partial results. SimpleOrderedMap res = new SimpleOrderedMap<>(); - List bucketList = new ArrayList<>( leaves.size() + skip.size() + missing.size() ); + List bucketList = new ArrayList<>( leaves.size() + skip.size() + partial.size() ); res.add("buckets", bucketList); // TODO: an alternate implementations can fill all accs at once @@ -555,7 +555,7 @@ abstract class FacetFieldProcessor extends FacetProcessor { } // The only difference between skip and missing is the value of "skip" passed to refineBucket - for (List bucketAndFacetInfo : missing) { + for (List bucketAndFacetInfo : partial) { assert bucketAndFacetInfo.size() == 2; Object bucketVal = bucketAndFacetInfo.get(0); Map facetInfo = (Map) bucketAndFacetInfo.get(1); diff --git a/solr/core/src/java/org/apache/solr/search/facet/FacetRequestSortedMerger.java b/solr/core/src/java/org/apache/solr/search/facet/FacetRequestSortedMerger.java index f55fc0fc180..e05064c4148 100644 --- a/solr/core/src/java/org/apache/solr/search/facet/FacetRequestSortedMerger.java +++ b/solr/core/src/java/org/apache/solr/search/facet/FacetRequestSortedMerger.java @@ -161,7 +161,7 @@ abstract class FacetRequestSortedMerger leafBuckets = null; // "_l" missing buckets specified by bucket value only (no need to specify anything further) - ArrayList missingBuckets = null; // "_m" missing buckets that need to specify values for partial facets.. each entry is [bucketval, subs] + ArrayList partialBuckets = null; // "_p" missing buckets that have a partial sub-facet that need to specify those bucket values... each entry is [bucketval, subs] ArrayList skipBuckets = null; // "_s" present buckets that we need to recurse into because children facets have refinement requirements. each entry is [bucketval, subs] for (FacetBucket bucket : bucketList) { @@ -208,12 +208,12 @@ abstract class FacetRequestSortedMerger(); - missingBuckets.add( Arrays.asList(bucket.bucketValue, bucketRefinement) ); + if (partialBuckets==null) partialBuckets = new ArrayList<>(); + partialBuckets.add( Arrays.asList(bucket.bucketValue, bucketRefinement) ); } } - // if we didn't add to "_m" (missing), then we should add to "_l" (leaf missing) + // if we didn't add to "_p" (missing with partial sub-facets), then we should add to "_l" (missing leaf) if (bucketRefinement == null) { if (leafBuckets == null) leafBuckets = new ArrayList<>(); leafBuckets.add(bucket.bucketValue); @@ -231,12 +231,12 @@ abstract class FacetRequestSortedMerger(3); if (leafBuckets != null) refinement.put("_l",leafBuckets); - if (missingBuckets != null) refinement.put("_m", missingBuckets); + if (partialBuckets != null) refinement.put("_p", partialBuckets); if (skipBuckets != null) refinement.put("_s", skipBuckets); } diff --git a/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacetRefinement.java b/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacetRefinement.java index 5c863471d21..b4b022066ea 100644 --- a/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacetRefinement.java +++ b/solr/core/src/test/org/apache/solr/search/facet/TestJsonFacetRefinement.java @@ -36,7 +36,6 @@ import org.noggit.ObjectBuilder; public class TestJsonFacetRefinement extends SolrTestCaseHS { private static SolrInstances servers; // for distributed testing - private static int origTableSize; @BeforeClass public static void beforeTests() throws Exception { @@ -209,13 +208,13 @@ public class TestJsonFacetRefinement extends SolrTestCaseHS { "}" ); - // for testing missing _m, we need a partial facet within a partial facet + // for testing partial _p, we need a partial facet within a partial facet doTestRefine("{top:{type:terms, field:Afield, refine:true, limit:1, facet:{x : {type:terms, field:X, limit:1, refine:true} } } }", "{top: {buckets:[{val:'A', count:2, x:{buckets:[{val:x1, count:5},{val:x2, count:3}]} } ] } }", "{top: {buckets:[{val:'B', count:1, x:{buckets:[{val:x2, count:4},{val:x3, count:2}]} } ] } }", null, "=={top: {" + - "_m:[ ['A' , {x:{_l:[x1]}} ] ]" + + "_p:[ ['A' , {x:{_l:[x1]}} ] ]" + " } " + "}" ); @@ -329,7 +328,7 @@ public class TestJsonFacetRefinement extends SolrTestCaseHS { "}" ); - // test that sibling facets and stats are included for _m buckets, but skipped for _s buckets + // test that sibling facets and stats are included for _p buckets, but skipped for _s buckets client.testJQ(params(p, "q", "*:*", "json.facet", "{" + " ab :{type:terms, field:${cat_s}, limit:1, overrequest:0, refine:true, facet:{ xy:{type:terms, field:${xy_s}, limit:1, overrequest:0, refine:true}, qq:{query:'*:*'},ww:'sum(${num_d})' }}" + @@ -339,9 +338,9 @@ public class TestJsonFacetRefinement extends SolrTestCaseHS { "}" ) , "facets=={ count:8" + - ", ab:{ buckets:[ {val:A, count:4, xy:{buckets:[ {val:X,count:3}]} ,qq:{count:4}, ww:4.0 }] }" + // make sure qq and ww are included for _m buckets + ", ab:{ buckets:[ {val:A, count:4, xy:{buckets:[ {val:X,count:3}]} ,qq:{count:4}, ww:4.0 }] }" + // make sure qq and ww are included for _p buckets ", allf:{ buckets:[ {count:8, val:all, cat:{buckets:[{val:A,count:4}]} ,qq:{count:8}, ww:2.0 }] }" + // make sure qq and ww are excluded (not calculated again in another phase) for _s buckets - ", ab2:{ buckets:[ {val:A, count:4, xy:{buckets:[ {val:X,count:3}]} ,qq:{count:4}, ww:4.0 }] }" + // make sure qq and ww are included for _m buckets + ", ab2:{ buckets:[ {val:A, count:4, xy:{buckets:[ {val:X,count:3}]} ,qq:{count:4}, ww:4.0 }] }" + // make sure qq and ww are included for _p buckets ", allf2:{ buckets:[ {count:8, val:all, cat:{buckets:[{val:A,count:4}]} ,qq:{count:8}, ww:2.0 }] }" + // make sure qq and ww are excluded (not calculated again in another phase) for _s buckets "}" );