diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/PolyFitEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/PolyFitEvaluator.java index 5320f18c617..5292c940469 100644 --- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/PolyFitEvaluator.java +++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/PolyFitEvaluator.java @@ -96,6 +96,11 @@ public class PolyFitEvaluator extends RecursiveNumericEvaluator implements ManyV list.add(yvalue); } - return list; + + VectorFunction vec = new VectorFunction(pf, list); + vec.addToContext("x", x); + vec.addToContext("y", y); + + return vec; } } diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/MathExpressionTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/MathExpressionTest.java index 3806b226cea..98a52a6ee35 100644 --- a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/MathExpressionTest.java +++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/MathExpressionTest.java @@ -2856,7 +2856,8 @@ public class MathExpressionTest extends SolrCloudTestCase { public void testPolyfit() throws Exception { String cexpr = "let(echo=true," + " a=array(0,1,2,3,4,5,6,7)," + - " fit=polyfit(a, 1))"; + " fit=polyfit(a, 1)," + + " predictions=predict(fit, a))"; ModifiableSolrParams paramsLoc = new ModifiableSolrParams(); paramsLoc.set("expr", cexpr); paramsLoc.set("qt", "/stream"); @@ -2876,6 +2877,18 @@ public class MathExpressionTest extends SolrCloudTestCase { assertTrue(out.get(5).intValue() == 5); assertTrue(out.get(6).intValue() == 6); assertTrue(out.get(7).intValue() == 7); + + + out = (List)tuples.get(0).get("predictions"); + assertTrue(out.size() == 8); + assertTrue(out.get(0).intValue() == 0); + assertTrue(out.get(1).intValue() == 1); + assertTrue(out.get(2).intValue() == 2); + assertTrue(out.get(3).intValue() == 3); + assertTrue(out.get(4).intValue() == 4); + assertTrue(out.get(5).intValue() == 5); + assertTrue(out.get(6).intValue() == 6); + assertTrue(out.get(7).intValue() == 7); } @Test