diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index adffaaf5ed4..27b96967f96 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -466,6 +466,10 @@ Bug Fixes prevent an exception in one facet command from affecting another facet command. (yonik) +* SOLR-2110: Remove the restriction on names for local params + substitution/dereferencing. Properly encode local params in + distributed faceting. (yonik) + * SOLR-2114: Fixed parsing error in hsin function. The function signature has changed slightly. (gsingers) diff --git a/solr/src/java/org/apache/solr/handler/component/FacetComponent.java b/solr/src/java/org/apache/solr/handler/component/FacetComponent.java index 339f5997356..cb5bb61a830 100644 --- a/solr/src/java/org/apache/solr/handler/component/FacetComponent.java +++ b/solr/src/java/org/apache/solr/handler/component/FacetComponent.java @@ -106,10 +106,12 @@ public class FacetComponent extends SearchComponent String facetCommand; // add terms into the original facet.field command // do it via parameter reference to avoid another layer of encoding. + + String termsKeyEncoded = QueryParsing.encodeLocalParamVal(termsKey); if (dff.localParams != null) { - facetCommand = commandPrefix+termsKey + " " + dff.facetStr.substring(2); + facetCommand = commandPrefix+termsKeyEncoded + " " + dff.facetStr.substring(2); } else { - facetCommand = commandPrefix+termsKey+'}'+dff.field; + facetCommand = commandPrefix+termsKeyEncoded+'}'+dff.field; } if (refinements == null) { diff --git a/solr/src/java/org/apache/solr/search/QueryParsing.java b/solr/src/java/org/apache/solr/search/QueryParsing.java index e34de87c935..f6398e16729 100644 --- a/solr/src/java/org/apache/solr/search/QueryParsing.java +++ b/solr/src/java/org/apache/solr/search/QueryParsing.java @@ -214,6 +214,31 @@ public class QueryParsing { } } + public static String encodeLocalParamVal(String val) { + int len = val.length(); + int i; + for (i=0; i=len) return val; + + // We need to enclose in quotes... but now we need to escape + StringBuilder sb = new StringBuilder(val.length() + 4); + sb.append('\''); + for (i=0; i