Apache Solr open-source search software
SOLR-4717: SimpleFacets uses localParams (merge from 4x)
Ryan McKinley4642adae8633
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 3ec9d9eb95f..2c77ceab571 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -142,6 +142,8 @@ New Features5.0) for basing the enumeration of cores. In the new way of doing things, acore.propeties file will mark the instanceDir for that core, and instanceDir willbe obsolete as well++* SOLR-4717: SimpleFacets now work with localParams (ryan)Bug Fixesdiff --git a/solr/core/src/java/org/apache/solr/request/SimpleFacets.java b/solr/core/src/java/org/apache/solr/request/SimpleFacets.javaindex 7987202a072..59737bab8ff 100644--- a/solr/core/src/java/org/apache/solr/request/SimpleFacets.java+++ b/solr/core/src/java/org/apache/solr/request/SimpleFacets.java@@ -105,17 +105,18 @@ public class SimpleFacets {/** The main set of documents all facet counts should be relative to */protected DocSet docsOrig;/** Configuration params behavior should be driven by */- protected SolrParams params;- protected SolrParams required;+ protected final SolrParams orig;+ protected final SolrParams required;/** Searcher to use for all calculations */- protected SolrIndexSearcher searcher;- protected SolrQueryRequest req;- protected ResponseBuilder rb;+ protected final SolrIndexSearcher searcher;+ protected final SolrQueryRequest req;+ protected final ResponseBuilder rb;protected SimpleOrderedMap<Object> facetResponse;// per-facet valuesprotected SolrParams localParams; // localParams on this particular facet command+ protected SolrParams params; // local+originalprotected String facetValue; // the field to or query to facet on (minus local params)protected DocSet docs; // the base docset for this particular facetprotected String key; // what name should the results be stored under@@ -134,7 +135,7 @@ public class SimpleFacets {this.req = req;this.searcher = req.getSearcher();this.docs = this.docsOrig = docs;- this.params = params;+ this.params = orig = params;this.required = new RequiredSolrParams(params);this.rb = rb;}@@ -147,7 +148,10 @@ public class SimpleFacets {key = param;threads = -1;- if (localParams == null) return;+ if (localParams == null) {+ return;+ }+ params = SolrParams.wrapDefaults(localParams, orig);// remove local params unless it's a queryif (type != FacetParams.FACET_QUERY) { // TODO Cut over to an Enum herediff --git a/solr/core/src/test/org/apache/solr/request/TestFaceting.java b/solr/core/src/test/org/apache/solr/request/TestFaceting.javaindex 2ab8be2dde9..184cdb1ccbc 100755--- a/solr/core/src/test/org/apache/solr/request/TestFaceting.java+++ b/solr/core/src/test/org/apache/solr/request/TestFaceting.java@@ -27,6 +27,7 @@ import org.apache.lucene.index.Term;import org.apache.lucene.index.TermsEnum;import org.apache.lucene.util.BytesRef;import org.apache.solr.SolrTestCaseJ4;+import org.apache.solr.common.params.CommonParams;import org.apache.solr.common.params.FacetParams;import org.junit.After;import org.junit.BeforeClass;