diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/PlotStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/PlotStream.java index b652de977ee..c893240e1d1 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/PlotStream.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/PlotStream.java @@ -155,21 +155,31 @@ public class PlotStream extends TupleStream implements Expressible { finished = true; Map values = new HashMap<>(); - String plot= stringParams.get("type"); - StreamEvaluator xvalues = evaluatorParams.get("x"); - StreamEvaluator yvalues = evaluatorParams.get("y"); + // add all string based params + // these could come from the context, or they will just be treated as straight strings + for(Entry param : stringParams.entrySet()){ + if(streamContext.getLets().containsKey(param.getValue())){ + values.put(param.getKey(), streamContext.getLets().get(param.getValue())); + } + else{ + values.put(param.getKey(), param.getValue()); + } + } - List y = (List)yvalues.evaluateOverContext(); - List x = null; + // add all evaluators + for(Entry param : evaluatorParams.entrySet()){ + values.put(param.getKey(), param.getValue().evaluateOverContext()); + } - if(xvalues == null) { + List y = (List)values.get("y"); + List x = (List)values.get("x"); + + if(x == null) { //x is null so add a sequence x = new ArrayList(); for(int i=0; i) xvalues.evaluateOverContext(); } List> xy = new ArrayList(); @@ -180,7 +190,7 @@ public class PlotStream extends TupleStream implements Expressible { xy.add(pair); } - values.put("plot", plot); + values.put("plot", values.get("type")); values.put("data", xy); Tuple tup = new Tuple(values); diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java index d749ede9471..6bf320c7779 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java @@ -6065,7 +6065,7 @@ public class StreamExpressionTest extends SolrCloudTestCase { @Test public void testPlot() throws Exception { - String cexpr = "plot(type=scatter, x=array(1,2,3), y=array(5,6,3))"; + String cexpr = "let(a=array(3,2,3), plot(type=scatter, x=a, y=array(5,6,3)))"; ModifiableSolrParams paramsLoc = new ModifiableSolrParams(); paramsLoc.set("expr", cexpr); paramsLoc.set("qt", "/stream"); @@ -6080,7 +6080,7 @@ public class StreamExpressionTest extends SolrCloudTestCase { List> data = (List>)tuples.get(0).get("data"); assertTrue(data.size() == 3); List pair1 = data.get(0); - assertTrue(pair1.get(0).intValue() == 1); + assertTrue(pair1.get(0).intValue() == 3); assertTrue(pair1.get(1).intValue() == 5); List pair2 = data.get(1); assertTrue(pair2.get(0).intValue() == 2);