commit 4241a13beb0a14e8bd81a520bd8e04ab6c7465aa

Author: Erick Erickson <erick@apache.org>
Date:   Thu Jul 13 10:39:33 2017 -0700

    SOLR-10908: CloudSolrStream.toExpression incorrectly handles fq clauses
This commit is contained in:
Erick Erickson 2017-07-13 10:48:22 -07:00
parent 801a44ca16
commit 19fd95b46c
3 changed files with 21 additions and 10 deletions

View File

@ -631,6 +631,8 @@ when using one of Exact*StatsCache (Mikhail Khludnev)
* SOLR-11024: ParallelStream should set the StreamContext when constructing SolrStreams (Joel Bernstein)
* SOLR-10908: CloudSolrStream.toExpression incorrectly handles fq clauses (Rohit Singh via Erick Erickson)
Optimizations
----------------------
* SOLR-10634: JSON Facet API: When a field/terms facet will retrieve all buckets (i.e. limit:-1)

View File

@ -172,18 +172,24 @@ public class CloudSolrStream extends TupleStream implements Expressible {
// collection
expression.addParameter(collection);
// parameters
ModifiableSolrParams mParams = new ModifiableSolrParams(SolrParams.toMultiMap(params.toNamedList()));
for (Entry<String, String[]> param : mParams.getMap().entrySet()) {
String value = String.join(",", param.getValue());
// SOLR-8409: This is a special case where the params contain a " character
// 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));
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
// 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));
}
}
// zkHost

View File

@ -74,12 +74,15 @@ public class StreamExpressionToExpessionTest extends LuceneTestCase {
String expressionString;
// Basic test
stream = new CloudSolrStream(StreamExpressionParser.parse("search(collection1, q=*:*, fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc, a_i asc\")"), factory);
stream = new CloudSolrStream(StreamExpressionParser.parse("search(collection1, q=*:*, fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc, a_i asc\", fq=\"a_s:one\", fq=\"a_s:two\")"), factory);
expressionString = stream.toExpression(factory).toString();
System.out.println("ExpressionString: " + expressionString.toString());
assertTrue(expressionString.contains("search(collection1,"));
assertTrue(expressionString.contains("q=\"*:*\""));
assertTrue(expressionString.contains("fl=\"id,a_s,a_i,a_f\""));
assertTrue(expressionString.contains("sort=\"a_f asc, a_i asc\""));
assertTrue(expressionString.contains("fq=\"a_s:one\""));
assertTrue(expressionString.contains("fq=\"a_s:two\""));
// Basic w/aliases
stream = new CloudSolrStream(StreamExpressionParser.parse("search(collection1, q=*:*, fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc, a_i asc\", aliases=\"id=izzy,a_s=kayden\")"), factory);