Apache Solr open-source search software
SOLR-11075: Refactor handling of params in CloudSolrStream and FacetStream
Erickb17ec1445dd5
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex e2c77b703fa..e6996dc71b6 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -87,6 +87,7 @@ Other Changes* SOLR-10964: Reduce SolrIndexSearcher casting in LTRRescorer. (Christine Poerschke)+* SOLR-11075: Refactor handling of params in CloudSolrStream and FacetStream (Erick Erickson)================== 7.0.0 ==================Versions of Major Componentsdiff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CloudSolrStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CloudSolrStream.javaindex 7fe98a3a06f..73bceb07b99 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CloudSolrStream.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/CloudSolrStream.java@@ -73,7 +73,7 @@ public class CloudSolrStream extends TupleStream implements Expressible {protected String zkHost;protected String collection;- protected SolrParams params;+ protected ModifiableSolrParams params;protected Map<String, String> fieldMappings;protected StreamComparator comp;private boolean trace;@@ -172,23 +172,13 @@ public class CloudSolrStream extends TupleStream implements Expressible {// collectionexpression.addParameter(collection);- ModifiableSolrParams mParams = new ModifiableSolrParams(SolrParams.toMultiMap(params.toNamedList()));- for (Entry<String, String[]> param : mParams.getMap().entrySet()) {-- if(param.getKey().equals("fq")) {- for(String fqParam : param.getValue()) {- // See comment below for params containg a " character- expression.addParameter(new StreamExpressionNamedParameter(param.getKey(),- fqParam.replace("\"", "\\\"")));- }- } else {- String value = String.join(",", param.getValue());-- // SOLR-8409: This is a special case where the params contain a " character+ for (Entry<String, String[]> param : params.getMap().entrySet()) {+ for (String val : param.getValue()) {+ // SOLR-8409: Escaping the " is a special case.// Do note that in any other BASE streams with parameters where a " might come into play// that this same replacement needs to take place.- value = value.replace("\"", "\\\"");- expression.addParameter(new StreamExpressionNamedParameter(param.getKey(), value));+ expression.addParameter(new StreamExpressionNamedParameter(param.getKey(),+ val.replace("\"", "\\\"")));}}diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.javaindex fb53e8464b0..e11bf023276 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/FacetStream.java@@ -66,7 +66,7 @@ public class FacetStream extends TupleStream implements Expressible {private List<Tuple> tuples = new ArrayList<Tuple>();private int index;private String zkHost;- private SolrParams params;+ private ModifiableSolrParams params;private String collection;protected transient SolrClientCache cache;protected transient CloudSolrClient cloudSolrClient;@@ -216,7 +216,7 @@ public class FacetStream extends TupleStream implements Expressible {private void init(String collection, SolrParams params, Bucket[] buckets, FieldComparator[] bucketSorts, Metric[] metrics, int bucketSizeLimit, String zkHost) throws IOException {this.zkHost = zkHost;- this.params = params;+ this.params = new ModifiableSolrParams(params);this.buckets = buckets;this.metrics = metrics;this.bucketSizeLimit = bucketSizeLimit;@@ -242,11 +242,11 @@ public class FacetStream extends TupleStream implements Expressible {expression.addParameter(collection);// parameters- ModifiableSolrParams tmpParams = new ModifiableSolrParams(params);- for (Entry<String, String[]> param : tmpParams.getMap().entrySet()) {- expression.addParameter(new StreamExpressionNamedParameter(param.getKey(),- String.join(",", param.getValue())));+ for (Entry<String, String[]> param : params.getMap().entrySet()) {+ for (String val : param.getValue()) {+ expression.addParameter(new StreamExpressionNamedParameter(param.getKey(), val));+ }}// buckets