Apache Lucene open-source search software
SOLR-7614: make pivotRefinementCounter specific to each top level request
Yonik Seeley1bf8cf7a7eeb
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 6afe532fd41..e10ecd0db94 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -389,6 +389,10 @@ Bug Fixes* SOLR-7610: Fix VelocityResponseWriter's $resource.locale to accurately report locale in use.(ehatcher)+* SOLR-7614: Distributed pivot facet refinement was broken due to a single correlation counter+ used across multiple requests as if it was private to each request. (yonik)++Optimizations----------------------diff --git a/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java b/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.javaindex 324433174a5..fded4ac3f78 100644--- a/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java+++ b/solr/core/src/java/org/apache/solr/handler/component/FacetComponent.java@@ -65,12 +65,7 @@ public class FacetComponent extends SearchComponent {private static final String PIVOT_KEY = "facet_pivot";private static final String PIVOT_REFINE_PREFIX = "{!"+PivotFacet.REFINE_PARAM+"=";- /**- * Incremented counter used to track the values being refined in a given request.- * This counter is used in conjunction with {@link PivotFacet#REFINE_PARAM} to identify- * which refinement values are associated with which pivots.- */- int pivotRefinementCounter = 0;+@Overridepublic void prepare(ResponseBuilder rb) throws IOException {@@ -271,14 +266,14 @@ public class FacetComponent extends SearchComponent {if ( ! queuedRefinementsForShard.isEmpty() ) {- String fieldsKey = PivotFacet.REFINE_PARAM + pivotRefinementCounter;+ String fieldsKey = PivotFacet.REFINE_PARAM + fi.pivotRefinementCounter;String command;if (pivotFacet.localParams != null) {- command = PIVOT_REFINE_PREFIX + pivotRefinementCounter + " "+ command = PIVOT_REFINE_PREFIX + fi.pivotRefinementCounter + " "+ pivotFacet.facetStr.substring(2);} else {- command = PIVOT_REFINE_PREFIX + pivotRefinementCounter + "}"+ command = PIVOT_REFINE_PREFIX + fi.pivotRefinementCounter + "}"+ pivotFacet.getKey();}@@ -290,7 +285,7 @@ public class FacetComponent extends SearchComponent {}}- pivotRefinementCounter++;+ fi.pivotRefinementCounter++;}rb.addRequest(this, shardsRefineRequestPivot);@@ -981,13 +976,12 @@ public class FacetComponent extends SearchComponent {@Overridepublic void finishStage(ResponseBuilder rb) {- pivotRefinementCounter = 0;if (!rb.doFacets || rb.stage != ResponseBuilder.STAGE_GET_FIELDS) return;// wait until STAGE_GET_FIELDS// so that "result" is already stored in the response (for aesthetics)FacetInfo fi = rb._facetInfo;-+NamedList<Object> facet_counts = new SimpleOrderedMap<>();NamedList<Number> facet_queries = new SimpleOrderedMap<>();@@ -1111,6 +1105,12 @@ public class FacetComponent extends SearchComponent {* <b>This API is experimental and subject to change</b>*/public static class FacetInfo {+ /**+ * Incremented counter used to track the values being refined in a given request.+ * This counter is used in conjunction with {@link PivotFacet#REFINE_PARAM} to identify+ * which refinement values are associated with which pivots.+ */+ int pivotRefinementCounter = 0;public LinkedHashMap<String,QueryFacet> queryFacets;public LinkedHashMap<String,DistribFieldFacet> facets;