You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by dp...@apache.org on 2017/02/10 05:37:31 UTC

[1/3] lucene-solr:branch_6x: SOLR-9916: Adds Stream Evaluators to support evaluating values from tuples

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_6x f9194854d -> 7372df995


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AndEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AndEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AndEvaluatorTest.java
new file mode 100644
index 0000000..9daa928
--- /dev/null
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AndEvaluatorTest.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.AndEvaluator;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+public class AndEvaluatorTest extends LuceneTestCase {
+
+  StreamFactory factory;
+  Map<String, Object> values;
+  
+  public AndEvaluatorTest() {
+    super();
+    
+    factory = new StreamFactory()
+      .withFunctionName("and", AndEvaluator.class);
+    values = new HashedMap();
+  }
+    
+  @Test
+  public void andTwoBooleans() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("and(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b", true);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", false);
+    values.put("b", true);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", false);
+    values.put("b", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+  }
+  
+  @Test
+  public void andWithSubAndsBooleans() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("and(a,and(b,c))");
+    Object result;
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b", true);
+    values.put("c", true);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+
+    values.clear();
+    values.put("a", true);
+    values.put("b", true);
+    values.put("c", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b", false);
+    values.put("c", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", false);
+    values.put("b", true);
+    values.put("c", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", false);
+    values.put("b", false);
+    values.put("c", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/CompoundEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/CompoundEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/CompoundEvaluatorTest.java
new file mode 100644
index 0000000..8ae5657
--- /dev/null
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/CompoundEvaluatorTest.java
@@ -0,0 +1,85 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.AddEvaluator;
+import org.apache.solr.client.solrj.io.eval.AndEvaluator;
+import org.apache.solr.client.solrj.io.eval.GreaterThanEvaluator;
+import org.apache.solr.client.solrj.io.eval.IfThenElseEvaluator;
+import org.apache.solr.client.solrj.io.eval.LessThanEvaluator;
+import org.apache.solr.client.solrj.io.eval.MultiplyEvaluator;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
+import org.apache.solr.client.solrj.io.eval.SubtractEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+public class CompoundEvaluatorTest extends LuceneTestCase {
+
+  StreamFactory factory;
+  Map<String, Object> values;
+  
+  public CompoundEvaluatorTest() {
+    super();
+    
+    factory = new StreamFactory()
+      .withFunctionName("and", AndEvaluator.class)
+      .withFunctionName("gt", GreaterThanEvaluator.class)
+      .withFunctionName("lt", LessThanEvaluator.class)
+      .withFunctionName("add", AddEvaluator.class)
+      .withFunctionName("sub", SubtractEvaluator.class)
+      .withFunctionName("mult", MultiplyEvaluator.class)
+      .withFunctionName("if", IfThenElseEvaluator.class);
+    values = new HashedMap();
+  }
+    
+  @Test
+  public void compoundTest() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("add(mult(a,b),if(gt(c,d),e,f),g)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 10);
+    values.put("b", -3);
+    values.put("c", "foo");
+    values.put("d", "bar");
+    values.put("e", 9);
+    values.put("f", 2);
+    values.put("g", 5);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(-16L, result);
+    
+    values.clear();
+    values.put("a", .1);
+    values.put("b", -3);
+    values.put("c", "foo");
+    values.put("d", "bar");
+    values.put("e", 9);
+    values.put("f", 2);
+    values.put("g", 5);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(13.7, result);
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/DivideEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/DivideEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/DivideEvaluatorTest.java
new file mode 100644
index 0000000..680be63
--- /dev/null
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/DivideEvaluatorTest.java
@@ -0,0 +1,164 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for multitional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import java.io.IOException;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.DivideEvaluator;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+public class DivideEvaluatorTest extends LuceneTestCase {
+
+  StreamFactory factory;
+  Map<String, Object> values;
+  
+  public DivideEvaluatorTest() {
+    super();
+    
+    factory = new StreamFactory()
+      .withFunctionName("div", DivideEvaluator.class);
+    values = new HashedMap();
+  }
+    
+  @Test
+  public void divTwoFieldsWithValues() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(1.0/2, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(1.1/2, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2.1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(1.1/2.1, result);
+  }
+
+  @Test(expected = IOException.class)
+  public void divOneField() throws Exception{
+    factory.constructEvaluator("div(a)");
+  }
+  
+  @Test(expected = IOException.class)
+  public void divTwoFieldWithNulls() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
+    
+    values.clear();
+    evaluator.evaluate(new Tuple(values));
+  }
+  
+  @Test(expected = IOException.class)
+  public void divTwoFieldsWithNullDenominator() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
+    
+    values.clear();
+    values.put("a", 1);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+  @Test(expected = IOException.class)
+  public void divTwoFieldsWithNullNumerator() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
+    
+    values.clear();
+    values.put("b", 1);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+
+  @Test(expected = IOException.class)
+  public void divTwoFieldsWithMissingDenominator() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
+    
+    values.clear();
+    values.put("a", 1);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+  @Test(expected = IOException.class)
+  public void divTwoFieldsWithMissingNumerator() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
+    
+    values.clear();
+    values.put("b", 1);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+  
+  @Test(expected = IOException.class)
+  public void divManyFieldsWithValues() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("div(a,b,c,d)");
+  }
+  
+  @Test
+  public void divManyFieldsWithSubdivs() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("div(a,div(b,c))");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2);
+    values.put("c", 3);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals((1.0 / (2.0 / 3)), result);
+  }
+  
+  @Test(expected = IOException.class)
+  public void divByZero() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 0);
+    evaluator.evaluate(new Tuple(values));
+  }
+  
+  @Test
+  public void divZeroByValue() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 0);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(0L, result);
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/EqualsEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/EqualsEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/EqualsEvaluatorTest.java
new file mode 100644
index 0000000..2f9dd9c
--- /dev/null
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/EqualsEvaluatorTest.java
@@ -0,0 +1,263 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import java.io.IOException;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.EqualsEvaluator;
+import org.apache.solr.client.solrj.io.eval.RawValueEvaluator;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+public class EqualsEvaluatorTest extends LuceneTestCase {
+
+  StreamFactory factory;
+  Map<String, Object> values;
+  
+  public EqualsEvaluatorTest() {
+    super();
+    
+    factory = new StreamFactory()
+      .withFunctionName("eq", EqualsEvaluator.class)
+      .withFunctionName("val", RawValueEvaluator.class)
+      ;
+    values = new HashedMap();
+  }
+    
+  @Test
+  public void operationFieldName() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("eq(sum(a),val(9))");    
+    Object result;
+    
+    values.clear();
+    values.put("sum(a)", 9);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+
+  }
+  
+  @Test
+  public void eqTwoIntegers() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("eq(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 1.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 1.0);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", -1);
+    values.put("b", -1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 1.0);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+  }
+
+  @Test
+  public void eqTwoStrings() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("eq(a,b)");
+    Object result;
+    String foo = "foo";
+    String bar = "bar";
+    
+    values.clear();
+    values.put("a", "foo");
+    values.put("b", "foo");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", "foo");
+    values.put("b", "bar");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, false);
+    
+    values.clear();
+    values.put("a", "foo bar baz");
+    values.put("b", "foo bar baz");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", "foo bar baz");
+    values.put("b", "foo bar jaz");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", foo);
+    values.put("b", foo);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", foo);
+    values.put("b", bar);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+  }
+  
+  @Test
+  public void eqTwoBooleans() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("eq(a,b)");
+    Object result;
+    Boolean t = true;
+    Boolean f = false;
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b",true);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", false);
+    values.put("b",false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, false);
+    
+    values.clear();
+    values.put("a", false);
+    values.put("b", true);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", t);
+    values.put("b", f);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", t);
+    values.put("b", t);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", f);
+    values.put("b", f);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+  }
+
+  @Test(expected = IOException.class)
+  public void eqDifferentTypes1() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("eq(a,b)");
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b",1);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+  @Test(expected = IOException.class)
+  public void eqDifferentTypes2() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("eq(a,b)");
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b",false);
+    evaluator.evaluate(new Tuple(values));
+  }
+  
+  @Test(expected = IOException.class)
+  public void eqDifferentTypes3() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("eq(a,b)");
+    
+    values.clear();
+    values.put("a", "1");
+    values.put("b",1);
+    evaluator.evaluate(new Tuple(values));
+  }
+  
+  @Test(expected = IOException.class)
+  public void eqDifferentTypes4() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("eq(a,b)");
+    
+    values.clear();
+    values.put("a", "true");
+    values.put("b",true);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ExclusiveOrEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ExclusiveOrEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ExclusiveOrEvaluatorTest.java
new file mode 100644
index 0000000..c1cc677
--- /dev/null
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/ExclusiveOrEvaluatorTest.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.ExclusiveOrEvaluator;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+public class ExclusiveOrEvaluatorTest extends LuceneTestCase {
+
+  StreamFactory factory;
+  Map<String, Object> values;
+  
+  public ExclusiveOrEvaluatorTest() {
+    super();
+    
+    factory = new StreamFactory()
+      .withFunctionName("eor", ExclusiveOrEvaluator.class);
+    values = new HashedMap();
+  }
+    
+  @Test
+  public void eorTwoBooleans() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("eor(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b", true);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", false);
+    values.put("b", true);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", false);
+    values.put("b", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+  }
+  
+  @Test
+  public void eorWithSubAndsBooleans() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("eor(a,eor(b,c))");
+    Object result;
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b", true);
+    values.put("c", true);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+
+    values.clear();
+    values.put("a", true);
+    values.put("b", true);
+    values.put("c", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b", false);
+    values.put("c", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", false);
+    values.put("b", true);
+    values.put("c", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", false);
+    values.put("b", false);
+    values.put("c", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/GreaterThanEqualToEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/GreaterThanEqualToEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/GreaterThanEqualToEvaluatorTest.java
new file mode 100644
index 0000000..5968a15
--- /dev/null
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/GreaterThanEqualToEvaluatorTest.java
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import java.io.IOException;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.GreaterThanEqualToEvaluator;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+public class GreaterThanEqualToEvaluatorTest extends LuceneTestCase {
+
+  StreamFactory factory;
+  Map<String, Object> values;
+  
+  public GreaterThanEqualToEvaluatorTest() {
+    super();
+    
+    factory = new StreamFactory()
+      .withFunctionName("gte", GreaterThanEqualToEvaluator.class);
+    values = new HashedMap();
+  }
+    
+  @Test
+  public void gteTwoIntegers() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("gte(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 1.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 1.0);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", -1);
+    values.put("b", -1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 1.0);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 2);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 2);
+    values.put("b", 1.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 2.0);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 3);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", -1);
+    values.put("b", -2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 3);
+    values.put("b", 2.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 3.0);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+  }
+  
+  @Test
+  public void gteTwoStrings() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("gte(a,b)");
+    Object result;
+    String foo = "foo";
+    String bar = "bar";
+    
+    values.clear();
+    values.put("a", "foo");
+    values.put("b", "foo");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", "foo");
+    values.put("b", "bar");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", "foo bar baz");
+    values.put("b", "foo bar baz");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", "foo bar baz");
+    values.put("b", "foo bar jaz");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", foo);
+    values.put("b", foo);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", foo);
+    values.put("b", bar);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+  }
+  
+  @Test(expected = IOException.class)
+  public void gteTwoBooleans() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("gte(a,b)");
+
+    values.clear();
+    values.put("a", true);
+    values.put("b",true);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+  @Test(expected = IOException.class)
+  public void gteDifferentTypes1() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("gte(a,b)");
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b",1);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+  @Test(expected = IOException.class)
+  public void gteDifferentTypes2() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("gte(a,b)");
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b",false);
+    evaluator.evaluate(new Tuple(values));
+  }
+  
+  @Test(expected = IOException.class)
+  public void gteDifferentTypes3() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("gte(a,b)");
+    
+    values.clear();
+    values.put("a", "1");
+    values.put("b",1);
+    evaluator.evaluate(new Tuple(values));
+  }
+  
+  @Test(expected = IOException.class)
+  public void gteDifferentTypes4() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("gte(a,b)");
+    
+    values.clear();
+    values.put("a", "true");
+    values.put("b",true);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/GreaterThanEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/GreaterThanEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/GreaterThanEvaluatorTest.java
new file mode 100644
index 0000000..d31a79c
--- /dev/null
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/GreaterThanEvaluatorTest.java
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import java.io.IOException;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.GreaterThanEvaluator;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+public class GreaterThanEvaluatorTest extends LuceneTestCase {
+
+  StreamFactory factory;
+  Map<String, Object> values;
+  
+  public GreaterThanEvaluatorTest() {
+    super();
+    
+    factory = new StreamFactory()
+      .withFunctionName("gt", GreaterThanEvaluator.class);
+    values = new HashedMap();
+  }
+    
+  @Test
+  public void gtTwoIntegers() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("gt(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 1.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 1.0);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", -1);
+    values.put("b", -1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 1.0);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 2);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 2);
+    values.put("b", 1.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 2.0);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 3);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", -1);
+    values.put("b", -2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 3);
+    values.put("b", 2.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 3.0);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+  }
+  
+  @Test
+  public void gtTwoStrings() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("gt(a,b)");
+    Object result;
+    String foo = "foo";
+    String bar = "bar";
+    
+    values.clear();
+    values.put("a", "foo");
+    values.put("b", "foo");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", "foo");
+    values.put("b", "bar");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", "foo bar baz");
+    values.put("b", "foo bar baz");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", "foo bar baz");
+    values.put("b", "foo bar jaz");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", foo);
+    values.put("b", foo);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", foo);
+    values.put("b", bar);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+  }
+  
+  @Test(expected = IOException.class)
+  public void gtTwoBooleans() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("gt(a,b)");
+
+    values.clear();
+    values.put("a", true);
+    values.put("b",true);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+  @Test(expected = IOException.class)
+  public void gtDifferentTypes1() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("gt(a,b)");
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b",1);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+  @Test(expected = IOException.class)
+  public void gtDifferentTypes2() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("gt(a,b)");
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b",false);
+    evaluator.evaluate(new Tuple(values));
+  }
+  
+  @Test(expected = IOException.class)
+  public void gtDifferentTypes3() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("gt(a,b)");
+    
+    values.clear();
+    values.put("a", "1");
+    values.put("b",1);
+    evaluator.evaluate(new Tuple(values));
+  }
+  
+  @Test(expected = IOException.class)
+  public void gtDifferentTypes4() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("gt(a,b)");
+    
+    values.clear();
+    values.put("a", "true");
+    values.put("b",true);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/LessThanEqualToEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/LessThanEqualToEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/LessThanEqualToEvaluatorTest.java
new file mode 100644
index 0000000..114ea2d
--- /dev/null
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/LessThanEqualToEvaluatorTest.java
@@ -0,0 +1,256 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import java.io.IOException;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.LessThanEqualToEvaluator;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+public class LessThanEqualToEvaluatorTest extends LuceneTestCase {
+
+  StreamFactory factory;
+  Map<String, Object> values;
+  
+  public LessThanEqualToEvaluatorTest() {
+    super();
+    
+    factory = new StreamFactory()
+      .withFunctionName("lte", LessThanEqualToEvaluator.class);
+    values = new HashedMap();
+  }
+    
+  @Test
+  public void lteTwoIntegers() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("lte(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 1.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 1.0);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", -1);
+    values.put("b", -1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 1.0);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 2);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 2);
+    values.put("b", 1.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 2.0);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 3);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", -1);
+    values.put("b", -2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", -2);
+    values.put("b", -1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 3);
+    values.put("b", 2.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 3.0);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+  }
+  
+  @Test
+  public void lteTwoStrings() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("lte(a,b)");
+    Object result;
+    String foo = "foo";
+    String bar = "bar";
+    
+    values.clear();
+    values.put("a", "foo");
+    values.put("b", "foo");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", "foo");
+    values.put("b", "bar");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", "foo bar baz");
+    values.put("b", "foo bar baz");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", "foo bar baz");
+    values.put("b", "foo bar jaz");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", foo);
+    values.put("b", foo);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", foo);
+    values.put("b", bar);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+  }
+  
+  @Test(expected = IOException.class)
+  public void lteTwoBooleans() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("lte(a,b)");
+
+    values.clear();
+    values.put("a", true);
+    values.put("b",true);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+  @Test(expected = IOException.class)
+  public void lteDifferentTypes1() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("lte(a,b)");
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b",1);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+  @Test(expected = IOException.class)
+  public void lteDifferentTypes2() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("lte(a,b)");
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b",false);
+    evaluator.evaluate(new Tuple(values));
+  }
+  
+  @Test(expected = IOException.class)
+  public void lteDifferentTypes3() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("lte(a,b)");
+    
+    values.clear();
+    values.put("a", "1");
+    values.put("b",1);
+    evaluator.evaluate(new Tuple(values));
+  }
+  
+  @Test(expected = IOException.class)
+  public void lteDifferentTypes4() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("lte(a,b)");
+    
+    values.clear();
+    values.put("a", "true");
+    values.put("b",true);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/LessThanEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/LessThanEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/LessThanEvaluatorTest.java
new file mode 100644
index 0000000..5cc0274
--- /dev/null
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/LessThanEvaluatorTest.java
@@ -0,0 +1,249 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import java.io.IOException;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.LessThanEvaluator;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+public class LessThanEvaluatorTest extends LuceneTestCase {
+
+  StreamFactory factory;
+  Map<String, Object> values;
+  
+  public LessThanEvaluatorTest() {
+    super();
+    
+    factory = new StreamFactory()
+      .withFunctionName("lt", LessThanEvaluator.class);
+    values = new HashedMap();
+  }
+    
+  @Test
+  public void ltTwoIntegers() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("lt(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 1.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 1.0);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", -1);
+    values.put("b", -1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 1.0);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", 2);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 2);
+    values.put("b", 1.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 2.0);
+    values.put("b", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 3);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", -1);
+    values.put("b", -2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 3);
+    values.put("b", 2.0);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", 3.0);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+  }
+  
+  @Test
+  public void ltTwoStrings() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("lt(a,b)");
+    Object result;
+    String foo = "foo";
+    String bar = "bar";
+    
+    values.clear();
+    values.put("a", "foo");
+    values.put("b", "foo");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", "foo");
+    values.put("b", "bar");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", "foo bar baz");
+    values.put("b", "foo bar baz");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", "foo bar baz");
+    values.put("b", "foo bar jaz");
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", foo);
+    values.put("b", foo);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", foo);
+    values.put("b", bar);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+  }
+  
+  @Test(expected = IOException.class)
+  public void ltTwoBooleans() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("lt(a,b)");
+
+    values.clear();
+    values.put("a", true);
+    values.put("b",true);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+  @Test(expected = IOException.class)
+  public void ltDifferentTypes1() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("lt(a,b)");
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b",1);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+  @Test(expected = IOException.class)
+  public void ltDifferentTypes2() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("lt(a,b)");
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b",false);
+    evaluator.evaluate(new Tuple(values));
+  }
+  
+  @Test(expected = IOException.class)
+  public void ltDifferentTypes3() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("lt(a,b)");
+    
+    values.clear();
+    values.put("a", "1");
+    values.put("b",1);
+    evaluator.evaluate(new Tuple(values));
+  }
+  
+  @Test(expected = IOException.class)
+  public void ltDifferentTypes4() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("lt(a,b)");
+    
+    values.clear();
+    values.put("a", "true");
+    values.put("b",true);
+    evaluator.evaluate(new Tuple(values));
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/MultiplyEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/MultiplyEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/MultiplyEvaluatorTest.java
new file mode 100644
index 0000000..a2a6616
--- /dev/null
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/MultiplyEvaluatorTest.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for multitional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import java.io.IOException;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.MultiplyEvaluator;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+public class MultiplyEvaluatorTest extends LuceneTestCase {
+
+  StreamFactory factory;
+  Map<String, Object> values;
+  
+  public MultiplyEvaluatorTest() {
+    super();
+    
+    factory = new StreamFactory()
+      .withFunctionName("mult", MultiplyEvaluator.class);
+    values = new HashedMap();
+  }
+    
+  @Test
+  public void multTwoFieldsWithValues() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("mult(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(2L, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(2.2D, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2.1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(2.31D, result);
+  }
+
+  @Test(expected = IOException.class)
+  public void multOneField() throws Exception{
+    factory.constructEvaluator("mult(a)");
+  }
+  
+  @Test
+  public void multTwoFieldWithNulls() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("mult(a,b)");
+    Object result;
+    
+    values.clear();
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+  }
+  
+  @Test
+  public void multTwoFieldsWithNull() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("mult(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", null);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+
+    values.clear();
+    values.put("a", null);
+    values.put("b", 1.1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", null);    
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+  }
+
+  @Test
+  public void multTwoFieldsWithMissingField() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("mult(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+    
+    values.clear();
+    values.put("b", 1.1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+    
+    values.clear();
+    values.put("a", 1.1);    
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+  }
+
+  @Test
+  public void multManyFieldsWithValues() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("mult(a,b,c,d)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2);
+    values.put("c", 3);
+    values.put("d", 4);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(24L, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2);
+    values.put("c", 3);
+    values.put("d", 4);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(26.4D, result);
+    
+    values.clear();
+    values.put("a", 10.1);
+    values.put("b", 2.1);
+    values.put("c", 3.1);
+    values.put("d", 4.1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(269.5791D, result);
+  }
+  
+  @Test
+  public void multManyFieldsWithSubmults() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("mult(a,b,mult(c,d))");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2);
+    values.put("c", 3);
+    values.put("d", 4);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(24L, result);
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/NotEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/NotEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/NotEvaluatorTest.java
new file mode 100644
index 0000000..6116163
--- /dev/null
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/NotEvaluatorTest.java
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
+import org.apache.solr.client.solrj.io.eval.NotEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+public class NotEvaluatorTest extends LuceneTestCase {
+
+  StreamFactory factory;
+  Map<String, Object> values;
+  
+  public NotEvaluatorTest() {
+    super();
+    
+    factory = new StreamFactory()
+      .withFunctionName("not", NotEvaluator.class);
+    values = new HashedMap();
+  }
+    
+  @Test
+  public void notOneBooleans() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("not(a)");
+    Object result;
+    
+    values.clear();
+    values.put("a", true);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+    
+    values.clear();
+    values.put("a", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+  }
+  
+  @Test
+  public void notWithSubNotBooleans() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("not(not(a))");
+    Object result;
+    
+    values.clear();
+    values.put("a", true);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+
+    values.clear();
+    values.put("a", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);    
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/OrEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/OrEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/OrEvaluatorTest.java
new file mode 100644
index 0000000..00c6b7a
--- /dev/null
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/OrEvaluatorTest.java
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.OrEvaluator;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+public class OrEvaluatorTest extends LuceneTestCase {
+
+  StreamFactory factory;
+  Map<String, Object> values;
+  
+  public OrEvaluatorTest() {
+    super();
+    
+    factory = new StreamFactory()
+      .withFunctionName("or", OrEvaluator.class);
+    values = new HashedMap();
+  }
+    
+  @Test
+  public void orTwoBooleans() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("or(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b", true);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", false);
+    values.put("b", true);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", false);
+    values.put("b", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+  }
+  
+  @Test
+  public void orWithSubAndsBooleans() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("or(a,or(b,c))");
+    Object result;
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b", true);
+    values.put("c", true);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+
+    values.clear();
+    values.put("a", true);
+    values.put("b", true);
+    values.put("c", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", true);
+    values.put("b", false);
+    values.put("c", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", false);
+    values.put("b", true);
+    values.put("c", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(true, result);
+    
+    values.clear();
+    values.put("a", false);
+    values.put("b", false);
+    values.put("c", false);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Boolean);
+    Assert.assertEquals(false, result);
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/RawValueEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/RawValueEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/RawValueEvaluatorTest.java
new file mode 100644
index 0000000..0d637e1
--- /dev/null
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/RawValueEvaluatorTest.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.AddEvaluator;
+import org.apache.solr.client.solrj.io.eval.AndEvaluator;
+import org.apache.solr.client.solrj.io.eval.RawValueEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+public class RawValueEvaluatorTest extends LuceneTestCase {
+
+  StreamFactory factory;
+  Map<String, Object> values;
+  
+  public RawValueEvaluatorTest() {
+    super();
+    
+    factory = new StreamFactory()
+      .withFunctionName("val", RawValueEvaluator.class)
+      .withFunctionName("add", AddEvaluator.class)
+      .withFunctionName("and", AndEvaluator.class)
+      ;
+    values = new HashedMap();
+  }
+    
+  @Test
+  public void rawTypes() throws Exception{
+    Tuple tuple = new Tuple(values);
+    
+    Assert.assertEquals(10L, factory.constructEvaluator("val(10)").evaluate(tuple));
+    Assert.assertEquals(-10L, factory.constructEvaluator("val(-10)").evaluate(tuple));
+    Assert.assertEquals(0L, factory.constructEvaluator("val(0)").evaluate(tuple));
+    Assert.assertEquals(10.5, factory.constructEvaluator("val(10.5)").evaluate(tuple));
+    Assert.assertEquals(-10.5, factory.constructEvaluator("val(-10.5)").evaluate(tuple));
+    Assert.assertEquals(true, factory.constructEvaluator("val(true)").evaluate(tuple));
+    Assert.assertEquals(false, factory.constructEvaluator("val(false)").evaluate(tuple));
+    Assert.assertNull(factory.constructEvaluator("val(null)").evaluate(tuple));
+  }
+  
+  public void rawTypesAsPartOfOther() throws Exception{
+    Tuple tuple = new Tuple(values);
+    
+    Assert.assertEquals(15L, factory.constructEvaluator("add(val(10),val(5))").evaluate(tuple));
+    Assert.assertEquals(true, factory.constructEvaluator("and(val(true),val(true))").evaluate(tuple));
+    Assert.assertEquals(false, factory.constructEvaluator("and(val(false),val(false))").evaluate(tuple));
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/SubtractEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/SubtractEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/SubtractEvaluatorTest.java
new file mode 100644
index 0000000..58cef8d
--- /dev/null
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/SubtractEvaluatorTest.java
@@ -0,0 +1,188 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for subitional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import java.io.IOException;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
+import org.apache.solr.client.solrj.io.eval.SubtractEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+public class SubtractEvaluatorTest extends LuceneTestCase {
+
+  StreamFactory factory;
+  Map<String, Object> values;
+  
+  public SubtractEvaluatorTest() {
+    super();
+    
+    factory = new StreamFactory()
+      .withFunctionName("sub", SubtractEvaluator.class);
+    values = new HashedMap();
+  }
+    
+  @Test
+  public void subTwoFieldsWithValues() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(-1L, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(-.9D, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2.1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(-1L, result);
+  }
+
+  @Test(expected = IOException.class)
+  public void subOneField() throws Exception{
+    factory.constructEvaluator("sub(a)");
+  }
+  
+  @Test
+  public void subTwoFieldWithNulls() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b)");
+    Object result;
+    
+    values.clear();
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+  }
+  
+  @Test
+  public void subTwoFieldsWithNull() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", null);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", null);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", null);    
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+  }
+
+  @Test
+  public void subTwoFieldsWithMissingField() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+    
+    values.clear();
+    values.put("a", 1.1);    
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+  }
+
+  @Test
+  public void subManyFieldsWithValues() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b,c,d)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2);
+    values.put("c", 3);
+    values.put("d", 4);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(-8L, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2);
+    values.put("c", 3);
+    values.put("d", 4);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(-7.9D, result);
+    
+    values.clear();
+    values.put("a", 10.1);
+    values.put("b", 2.1);
+    values.put("c", 3.1);
+    values.put("d", 4.1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(.8D, result);
+  }
+  
+  @Test
+  public void subManyFieldsWithSubsubs() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("sub(a,b,sub(c,d))");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2);
+    values.put("c", 3);
+    values.put("d", 4);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(0L, result);
+        
+    values.clear();
+    values.put("a", 123456789123456789L);
+    values.put("b", 123456789123456789L);
+    values.put("c", 123456789123456789L);
+    values.put("d", 123456789123456789L);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(0L, result);
+  }
+}


[3/3] lucene-solr:branch_6x: SOLR-9916: Adds Stream Evaluators to support evaluating values from tuples

Posted by dp...@apache.org.
SOLR-9916: Adds Stream Evaluators to support evaluating values from tuples


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/7372df99
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/7372df99
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/7372df99

Branch: refs/heads/branch_6x
Commit: 7372df9957b75c08283af6db47234df1787f1490
Parents: f919485
Author: Dennis Gove <dp...@gmail.com>
Authored: Fri Feb 10 00:37:10 2017 -0500
Committer: Dennis Gove <dp...@gmail.com>
Committed: Fri Feb 10 00:37:10 2017 -0500

----------------------------------------------------------------------
 solr/CHANGES.txt                                |   6 +-
 .../org/apache/solr/handler/StreamHandler.java  |  94 +++++-
 .../solrj/io/eval/AbsoluteValueEvaluator.java   |  60 ++++
 .../solr/client/solrj/io/eval/AddEvaluator.java |  61 ++++
 .../solr/client/solrj/io/eval/AndEvaluator.java |  90 +++++
 .../client/solrj/io/eval/BooleanEvaluator.java  |  86 +++++
 .../client/solrj/io/eval/ComplexEvaluator.java  |  99 ++++++
 .../solrj/io/eval/ConditionalEvaluator.java     |  59 ++++
 .../client/solrj/io/eval/DivideEvaluator.java   |  78 +++++
 .../client/solrj/io/eval/EqualsEvaluator.java   | 112 +++++++
 .../solrj/io/eval/ExclusiveOrEvaluator.java     |  67 ++++
 .../client/solrj/io/eval/FieldEvaluator.java    |  62 ++++
 .../io/eval/GreaterThanEqualToEvaluator.java    |  99 ++++++
 .../solrj/io/eval/GreaterThanEvaluator.java     |  99 ++++++
 .../solrj/io/eval/IfThenElseEvaluator.java      |  62 ++++
 .../solrj/io/eval/LessThanEqualToEvaluator.java |  99 ++++++
 .../client/solrj/io/eval/LessThanEvaluator.java |  99 ++++++
 .../client/solrj/io/eval/MultiplyEvaluator.java |  62 ++++
 .../solr/client/solrj/io/eval/NotEvaluator.java |  62 ++++
 .../client/solrj/io/eval/NumberEvaluator.java   |  79 +++++
 .../solr/client/solrj/io/eval/OrEvaluator.java  |  90 +++++
 .../client/solrj/io/eval/RawValueEvaluator.java |  90 +++++
 .../client/solrj/io/eval/SimpleEvaluator.java   |  29 ++
 .../client/solrj/io/eval/StreamEvaluator.java   |  30 ++
 .../client/solrj/io/eval/SubtractEvaluator.java |  61 ++++
 .../solr/client/solrj/io/ops/AndOperation.java  | 101 ------
 .../client/solrj/io/ops/BooleanOperation.java   |  26 --
 .../client/solrj/io/ops/EqualsOperation.java    |  70 ----
 .../io/ops/GreaterThanEqualToOperation.java     |  70 ----
 .../solrj/io/ops/GreaterThanOperation.java      |  70 ----
 .../solr/client/solrj/io/ops/LeafOperation.java |  67 ----
 .../solrj/io/ops/LessThanEqualToOperation.java  |  70 ----
 .../client/solrj/io/ops/LessThanOperation.java  |  70 ----
 .../solr/client/solrj/io/ops/NotOperation.java  |  87 -----
 .../solr/client/solrj/io/ops/OrOperation.java   |  71 ----
 .../client/solrj/io/stream/HavingStream.java    |  46 ++-
 .../client/solrj/io/stream/SelectStream.java    |  71 +++-
 .../solrj/io/stream/expr/Explanation.java       |   1 +
 .../solrj/io/stream/expr/StreamFactory.java     |  34 ++
 .../io/stream/SelectWithEvaluatorsTest.java     | 259 ++++++++++++++
 .../solrj/io/stream/StreamExpressionTest.java   |  55 +--
 .../stream/eval/AbsoluteValueEvaluatorTest.java |  96 ++++++
 .../solrj/io/stream/eval/AddEvaluatorTest.java  | 336 +++++++++++++++++++
 .../solrj/io/stream/eval/AndEvaluatorTest.java  | 123 +++++++
 .../io/stream/eval/CompoundEvaluatorTest.java   |  85 +++++
 .../io/stream/eval/DivideEvaluatorTest.java     | 164 +++++++++
 .../io/stream/eval/EqualsEvaluatorTest.java     | 263 +++++++++++++++
 .../stream/eval/ExclusiveOrEvaluatorTest.java   | 123 +++++++
 .../eval/GreaterThanEqualToEvaluatorTest.java   | 249 ++++++++++++++
 .../stream/eval/GreaterThanEvaluatorTest.java   | 249 ++++++++++++++
 .../eval/LessThanEqualToEvaluatorTest.java      | 256 ++++++++++++++
 .../io/stream/eval/LessThanEvaluatorTest.java   | 249 ++++++++++++++
 .../io/stream/eval/MultiplyEvaluatorTest.java   | 179 ++++++++++
 .../solrj/io/stream/eval/NotEvaluatorTest.java  |  80 +++++
 .../solrj/io/stream/eval/OrEvaluatorTest.java   | 123 +++++++
 .../io/stream/eval/RawValueEvaluatorTest.java   |  69 ++++
 .../io/stream/eval/SubtractEvaluatorTest.java   | 188 +++++++++++
 57 files changed, 5055 insertions(+), 780 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 0f08b51..f730f7f 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -49,7 +49,11 @@ New Features
 * SOLR-9926: Allow passing arbitrary java system properties to zkcli. (Hrishikesh Gadre via Mark Miller)
 
 * SOLR-9885: Allow pre-startup Solr log management in Solr bin scripts to be disabled. (Mano Kovacs via Mark Miller)
-  
+ 
+* SOLR-9916: Adds Stream Evaluators to support evaluating values from tuples. Supports boolean,
+  numeric, and conditional evaluators. BooleanOperations have been removed in preference of
+  BooleanEvaluators. (Dennis Gove)
+ 
 Optimizations
 ----------------------
 * SOLR-9941: Clear the deletes lists at UpdateLog before replaying from log. This prevents redundantly pre-applying

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/handler/StreamHandler.java b/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
index 0b41ef4..825cbac 100644
--- a/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
+++ b/solr/core/src/java/org/apache/solr/handler/StreamHandler.java
@@ -29,21 +29,63 @@ import org.apache.solr.client.solrj.io.ModelCache;
 import org.apache.solr.client.solrj.io.SolrClientCache;
 import org.apache.solr.client.solrj.io.Tuple;
 import org.apache.solr.client.solrj.io.comp.StreamComparator;
+import org.apache.solr.client.solrj.io.eval.AbsoluteValueEvaluator;
+import org.apache.solr.client.solrj.io.eval.AddEvaluator;
+import org.apache.solr.client.solrj.io.eval.AndEvaluator;
+import org.apache.solr.client.solrj.io.eval.DivideEvaluator;
+import org.apache.solr.client.solrj.io.eval.EqualsEvaluator;
+import org.apache.solr.client.solrj.io.eval.ExclusiveOrEvaluator;
+import org.apache.solr.client.solrj.io.eval.GreaterThanEqualToEvaluator;
+import org.apache.solr.client.solrj.io.eval.GreaterThanEvaluator;
+import org.apache.solr.client.solrj.io.eval.IfThenElseEvaluator;
+import org.apache.solr.client.solrj.io.eval.LessThanEqualToEvaluator;
+import org.apache.solr.client.solrj.io.eval.LessThanEvaluator;
+import org.apache.solr.client.solrj.io.eval.MultiplyEvaluator;
+import org.apache.solr.client.solrj.io.eval.NotEvaluator;
+import org.apache.solr.client.solrj.io.eval.OrEvaluator;
+import org.apache.solr.client.solrj.io.eval.RawValueEvaluator;
+import org.apache.solr.client.solrj.io.eval.SubtractEvaluator;
 import org.apache.solr.client.solrj.io.graph.GatherNodesStream;
 import org.apache.solr.client.solrj.io.graph.ShortestPathStream;
-import org.apache.solr.client.solrj.io.ops.AndOperation;
 import org.apache.solr.client.solrj.io.ops.ConcatOperation;
 import org.apache.solr.client.solrj.io.ops.DistinctOperation;
-import org.apache.solr.client.solrj.io.ops.EqualsOperation;
-import org.apache.solr.client.solrj.io.ops.GreaterThanEqualToOperation;
-import org.apache.solr.client.solrj.io.ops.GreaterThanOperation;
 import org.apache.solr.client.solrj.io.ops.GroupOperation;
-import org.apache.solr.client.solrj.io.ops.LessThanEqualToOperation;
-import org.apache.solr.client.solrj.io.ops.LessThanOperation;
-import org.apache.solr.client.solrj.io.ops.NotOperation;
-import org.apache.solr.client.solrj.io.ops.OrOperation;
 import org.apache.solr.client.solrj.io.ops.ReplaceOperation;
-import org.apache.solr.client.solrj.io.stream.*;
+import org.apache.solr.client.solrj.io.stream.CloudSolrStream;
+import org.apache.solr.client.solrj.io.stream.CommitStream;
+import org.apache.solr.client.solrj.io.stream.ComplementStream;
+import org.apache.solr.client.solrj.io.stream.DaemonStream;
+import org.apache.solr.client.solrj.io.stream.ExceptionStream;
+import org.apache.solr.client.solrj.io.stream.ExecutorStream;
+import org.apache.solr.client.solrj.io.stream.FacetStream;
+import org.apache.solr.client.solrj.io.stream.FeaturesSelectionStream;
+import org.apache.solr.client.solrj.io.stream.FetchStream;
+import org.apache.solr.client.solrj.io.stream.HashJoinStream;
+import org.apache.solr.client.solrj.io.stream.HavingStream;
+import org.apache.solr.client.solrj.io.stream.InnerJoinStream;
+import org.apache.solr.client.solrj.io.stream.IntersectStream;
+import org.apache.solr.client.solrj.io.stream.JDBCStream;
+import org.apache.solr.client.solrj.io.stream.LeftOuterJoinStream;
+import org.apache.solr.client.solrj.io.stream.MergeStream;
+import org.apache.solr.client.solrj.io.stream.ModelStream;
+import org.apache.solr.client.solrj.io.stream.NullStream;
+import org.apache.solr.client.solrj.io.stream.OuterHashJoinStream;
+import org.apache.solr.client.solrj.io.stream.ParallelStream;
+import org.apache.solr.client.solrj.io.stream.PriorityStream;
+import org.apache.solr.client.solrj.io.stream.RandomStream;
+import org.apache.solr.client.solrj.io.stream.RankStream;
+import org.apache.solr.client.solrj.io.stream.ReducerStream;
+import org.apache.solr.client.solrj.io.stream.RollupStream;
+import org.apache.solr.client.solrj.io.stream.ScoreNodesStream;
+import org.apache.solr.client.solrj.io.stream.SelectStream;
+import org.apache.solr.client.solrj.io.stream.SortStream;
+import org.apache.solr.client.solrj.io.stream.StatsStream;
+import org.apache.solr.client.solrj.io.stream.StreamContext;
+import org.apache.solr.client.solrj.io.stream.TextLogitStream;
+import org.apache.solr.client.solrj.io.stream.TopicStream;
+import org.apache.solr.client.solrj.io.stream.TupleStream;
+import org.apache.solr.client.solrj.io.stream.UniqueStream;
+import org.apache.solr.client.solrj.io.stream.UpdateStream;
 import org.apache.solr.client.solrj.io.stream.expr.Explanation;
 import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
 import org.apache.solr.client.solrj.io.stream.expr.Expressible;
@@ -152,6 +194,7 @@ public class StreamHandler extends RequestHandlerBase implements SolrCoreAware,
       .withFunctionName("executor", ExecutorStream.class)
       .withFunctionName("null", NullStream.class)
       .withFunctionName("priority", PriorityStream.class)
+      
       // metrics
       .withFunctionName("min", MinMetric.class)
       .withFunctionName("max", MaxMetric.class)
@@ -167,14 +210,31 @@ public class StreamHandler extends RequestHandlerBase implements SolrCoreAware,
       .withFunctionName("group", GroupOperation.class)
       .withFunctionName("distinct", DistinctOperation.class)
       .withFunctionName("having", HavingStream.class)
-      .withFunctionName("and", AndOperation.class)
-      .withFunctionName("or", OrOperation.class)
-      .withFunctionName("not", NotOperation.class)
-      .withFunctionName("gt", GreaterThanOperation.class)
-      .withFunctionName("lt", LessThanOperation.class)
-      .withFunctionName("eq", EqualsOperation.class)
-      .withFunctionName("lteq", LessThanEqualToOperation.class)
-      .withFunctionName("gteq", GreaterThanEqualToOperation.class);
+      
+      // Stream Evaluators
+      .withFunctionName("val", RawValueEvaluator.class)
+      
+      // Boolean Stream Evaluators
+      .withFunctionName("and", AndEvaluator.class)
+      .withFunctionName("eor", ExclusiveOrEvaluator.class)
+      .withFunctionName("eq", EqualsEvaluator.class)
+      .withFunctionName("gt", GreaterThanEvaluator.class)
+      .withFunctionName("gteq", GreaterThanEqualToEvaluator.class)
+      .withFunctionName("lt", LessThanEvaluator.class)
+      .withFunctionName("lteq", LessThanEqualToEvaluator.class)
+      .withFunctionName("not", NotEvaluator.class)
+      .withFunctionName("or", OrEvaluator.class)
+      
+      // Number Stream Evaluators
+      .withFunctionName("abs", AbsoluteValueEvaluator.class)
+      .withFunctionName("add", AddEvaluator.class)
+      .withFunctionName("div", DivideEvaluator.class)
+      .withFunctionName("mult", MultiplyEvaluator.class)
+      .withFunctionName("sub", SubtractEvaluator.class)
+      
+      // Conditional Stream Evaluators
+      .withFunctionName("if", IfThenElseEvaluator.class)
+      ;
 
      // This pulls all the overrides and additions from the config
      List<PluginInfo> pluginInfos = core.getSolrConfig().getPluginInfos(Expressible.class.getName());

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/AbsoluteValueEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/AbsoluteValueEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/AbsoluteValueEvaluator.java
new file mode 100644
index 0000000..38b3bb5
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/AbsoluteValueEvaluator.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class AbsoluteValueEvaluator extends NumberEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public AbsoluteValueEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+    
+    if(1 != subEvaluators.size()){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting one value but found %d",expression,subEvaluators.size()));
+    }
+  }
+
+  @Override
+  public Number evaluate(Tuple tuple) throws IOException {
+    
+    List<BigDecimal> results = evaluateAll(tuple);
+    
+    // we're still doing these checks because if we ever add an array-flatten evaluator, 
+    // one found in the constructor could become != 1
+    if(1 != results.size()){
+      throw new IOException(String.format(Locale.ROOT,"%s(...) only works with a 1 value but %d were provided", constructingFactory.getFunctionName(getClass()), results.size()));
+    }
+    
+    if(null == results.get(0)){
+      return null;
+    }
+    
+    return normalizeType(results.get(0).abs());
+  }  
+
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/AddEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/AddEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/AddEvaluator.java
new file mode 100644
index 0000000..317741e
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/AddEvaluator.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class AddEvaluator extends NumberEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public AddEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+    
+    if(subEvaluators.size() < 2){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting at least two values but found %d",expression,subEvaluators.size()));
+    }
+  }
+
+  @Override
+  public Number evaluate(Tuple tuple) throws IOException {
+    
+    List<BigDecimal> results = evaluateAll(tuple);
+    
+    if(results.stream().anyMatch(item -> null == item)){
+      return null;
+    }
+    
+    BigDecimal result = null;
+    if(results.size() > 0){
+      result = results.get(0);
+      for(int idx = 1; idx < results.size(); ++idx){
+        result = result.add(results.get(idx));
+      }
+    }
+    
+    return normalizeType(result);
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/AndEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/AndEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/AndEvaluator.java
new file mode 100644
index 0000000..290bd98
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/AndEvaluator.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Locale;
+import java.util.stream.Collectors;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class AndEvaluator extends BooleanEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public AndEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+    
+    if(subEvaluators.size() < 2){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting at least two values but found %d",expression,subEvaluators.size()));
+    }
+  }
+
+  @Override
+  public Boolean evaluate(Tuple tuple) throws IOException {
+    
+    List<Object> results = evaluateAll(tuple);
+    
+    if(results.size() < 2){
+      String message = null;
+      if(1 == results.size()){
+        message = String.format(Locale.ROOT,"%s(...) only works with at least 2 values but 1 was provided", constructingFactory.getFunctionName(getClass())); 
+      }
+      else{
+        message = String.format(Locale.ROOT,"%s(...) only works with at least 2 values but 0 were provided", constructingFactory.getFunctionName(getClass()));
+      }
+      throw new IOException(message);
+    }
+    
+    Checker checker = constructChecker(results.get(0));
+    if(results.stream().anyMatch(result -> null == result && !checker.isNullAllowed())){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) because a null value was found", constructingFactory.getFunctionName(getClass())));
+    }
+    if(results.stream().anyMatch(result -> !checker.isCorrectType(result))){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) of differing types [%s]", constructingFactory.getFunctionName(getClass()), results.stream().map(item -> item.getClass().getSimpleName()).collect(Collectors.joining(","))));
+    }
+
+    for(int idx = 1; idx < results.size(); ++idx){
+      if(!checker.test(results.get(0), results.get(idx))){
+        return false;
+      }
+    }
+    
+    return true;
+  }
+  
+  private Checker constructChecker(Object fromValue) throws IOException{
+    if(null == fromValue){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) because a null value was found", constructingFactory.getFunctionName(getClass())));
+    }
+    else if(fromValue instanceof Boolean){
+      return new BooleanChecker(){
+        @Override
+        public boolean test(Object left, Object right) {
+          return (boolean)left && (boolean)right;
+        }
+      };
+    }
+    
+    throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) for values of type '%s'", constructingFactory.getFunctionName(getClass()), fromValue.getClass().getSimpleName()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/BooleanEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/BooleanEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/BooleanEvaluator.java
new file mode 100644
index 0000000..bf21f1d
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/BooleanEvaluator.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public abstract class BooleanEvaluator extends ComplexEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public BooleanEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+  }
+  
+  // restrict result to a Boolean
+  public abstract Boolean evaluate(Tuple tuple) throws IOException;
+  
+  public List<Object> evaluateAll(final Tuple tuple) throws IOException {
+    List<Object> results = new ArrayList<Object>();
+    for(StreamEvaluator subEvaluator : subEvaluators){
+      results.add(subEvaluator.evaluate(tuple));
+    }
+    
+    return results;
+  }
+  
+  public interface Checker {
+    default boolean isNullAllowed(){
+      return false;
+    }
+    boolean isCorrectType(Object value);
+    boolean test(Object left, Object right);
+  }
+  
+  public interface NullChecker extends Checker {
+    default boolean isNullAllowed(){
+      return true;
+    }
+    default boolean isCorrectType(Object value){
+      return true;
+    }
+    default boolean test(Object left, Object right){
+      return null == left && null == right;
+    }
+  }
+  
+  public interface BooleanChecker extends Checker {
+    default boolean isCorrectType(Object value){
+      return value instanceof Boolean;
+    }
+  }
+  
+  public interface NumberChecker extends Checker {
+    default boolean isCorrectType(Object value){
+      return value instanceof Number;
+    }
+  }
+  
+  public interface StringChecker extends Checker {
+    default boolean isCorrectType(Object value){
+      return value instanceof String;
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ComplexEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ComplexEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ComplexEvaluator.java
new file mode 100644
index 0000000..1e56d12
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ComplexEvaluator.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.UUID;
+
+import org.apache.solr.client.solrj.io.stream.expr.Explanation;
+import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParameter;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionValue;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public abstract class ComplexEvaluator implements StreamEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  protected UUID nodeId = UUID.randomUUID();
+  
+  protected StreamFactory constructingFactory;
+  protected List<StreamEvaluator> subEvaluators = new ArrayList<StreamEvaluator>();
+  
+  public ComplexEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    constructingFactory = factory;
+    
+    // We have to do this because order of the parameters matter
+    List<StreamExpressionParameter> parameters = factory.getOperandsOfType(expression, StreamExpressionParameter.class);
+    
+    for(StreamExpressionParameter parameter : parameters){
+      if(parameter instanceof StreamExpression){
+        // possible evaluator
+        StreamExpression streamExpression = (StreamExpression)parameter;
+        if(factory.doesRepresentTypes(streamExpression, ComplexEvaluator.class)){
+          subEvaluators.add(factory.constructEvaluator(streamExpression));
+        }
+        else if(factory.doesRepresentTypes(streamExpression, SimpleEvaluator.class)){
+          subEvaluators.add(factory.constructEvaluator(streamExpression));
+        }
+        else{
+          // Will be treated as a field name
+          subEvaluators.add(new FieldEvaluator(streamExpression.toString()));
+        }
+      }
+      else if(parameter instanceof StreamExpressionValue){
+        if(0 != ((StreamExpressionValue)parameter).getValue().length()){
+          // special case - if evaluates to a number, boolean, or null then we'll treat it 
+          // as a RawValueEvaluator
+          Object value = factory.constructPrimitiveObject(((StreamExpressionValue)parameter).getValue());
+          if(null == value || value instanceof Boolean || value instanceof Number){
+            subEvaluators.add(new RawValueEvaluator(value));
+          }
+          else if(value instanceof String){
+            subEvaluators.add(new FieldEvaluator((String)value));
+          }
+        }
+      }
+    }
+    
+    if(expression.getParameters().size() != subEvaluators.size()){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - unknown operands found - expecting only StreamEvaluators or field names", expression));
+    }
+  }
+
+  @Override
+  public StreamExpressionParameter toExpression(StreamFactory factory) throws IOException {
+    StreamExpression expression = new StreamExpression(factory.getFunctionName(getClass()));
+    
+    for(StreamEvaluator evaluator : subEvaluators){
+      expression.addParameter(evaluator.toExpression(factory));
+    }
+    return expression;
+  }
+
+  @Override
+  public Explanation toExplanation(StreamFactory factory) throws IOException {
+    return new Explanation(nodeId.toString())
+      .withExpressionType(ExpressionType.EVALUATOR)
+      .withFunctionName(factory.getFunctionName(getClass()))
+      .withImplementingClass(getClass().getName())
+      .withExpression(toExpression(factory).toString());
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ConditionalEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ConditionalEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ConditionalEvaluator.java
new file mode 100644
index 0000000..499e2f8
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ConditionalEvaluator.java
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public abstract class ConditionalEvaluator extends ComplexEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public ConditionalEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+  }
+  
+  public List<Object> evaluateAll(final Tuple tuple) throws IOException {
+    List<Object> results = new ArrayList<Object>();
+    for(StreamEvaluator subEvaluator : subEvaluators){
+      results.add(subEvaluator.evaluate(tuple));
+    }
+    
+    return results;
+  }
+  
+  public interface Checker {
+    default boolean isNullAllowed(){
+      return false;
+    }
+    boolean isCorrectType(Object value);
+    boolean test(Object left, Object right);
+  }
+    
+  public interface BooleanChecker extends Checker {
+    default boolean isCorrectType(Object value){
+      return value instanceof Boolean;
+    }
+  }  
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/DivideEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/DivideEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/DivideEvaluator.java
new file mode 100644
index 0000000..f21a7f3
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/DivideEvaluator.java
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.math.MathContext;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class DivideEvaluator extends NumberEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public DivideEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+    
+    if(2 != subEvaluators.size()){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting two values but found %d",expression,subEvaluators.size()));
+    }
+  }
+
+  @Override
+  public Number evaluate(Tuple tuple) throws IOException {
+    
+    List<BigDecimal> results = evaluateAll(tuple);
+    
+    // we're still doing these checks because if we ever add an array-flatten evaluator, 
+    // two found in the constructor could become != 2
+    if(2 != results.size()){
+      String message = null;
+      if(1 == results.size()){
+        message = String.format(Locale.ROOT,"%s(...) only works with a 2 values (numerator,denominator) but 1 was provided", constructingFactory.getFunctionName(getClass())); 
+      }
+      else{
+        message = String.format(Locale.ROOT,"%s(...) only works with a 2 values (numerator,denominator) but %d were provided", constructingFactory.getFunctionName(getClass()), results.size());
+      }
+      throw new IOException(message);
+    }
+    
+    BigDecimal numerator = results.get(0);
+    BigDecimal denominator = results.get(1);
+    
+    if(null == numerator){
+      throw new IOException(String.format(Locale.ROOT,"Unable to %s(...) with a null numerator", constructingFactory.getFunctionName(getClass())));
+    }
+    
+    if(null == denominator){
+      throw new IOException(String.format(Locale.ROOT,"Unable to %s(...) with a null denominator", constructingFactory.getFunctionName(getClass())));
+    }
+    
+    if(0 == denominator.compareTo(BigDecimal.ZERO)){
+      throw new IOException(String.format(Locale.ROOT,"Unable to %s(...) with a 0 denominator", constructingFactory.getFunctionName(getClass())));
+    }
+    
+    return normalizeType(numerator.divide(denominator, MathContext.DECIMAL64));
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/EqualsEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/EqualsEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/EqualsEvaluator.java
new file mode 100644
index 0000000..051a2de
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/EqualsEvaluator.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Locale;
+import java.util.stream.Collectors;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class EqualsEvaluator extends BooleanEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public EqualsEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+    
+    if(subEvaluators.size() < 2){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting at least two values but found %d",expression,subEvaluators.size()));
+    }
+  }
+
+  @Override
+  public Boolean evaluate(Tuple tuple) throws IOException {
+    
+    List<Object> results = evaluateAll(tuple);
+    
+    if(results.size() < 2){
+      String message = null;
+      if(1 == results.size()){
+        message = String.format(Locale.ROOT,"%s(...) only works with at least 2 values but 1 was provided", constructingFactory.getFunctionName(getClass())); 
+      }
+      else{
+        message = String.format(Locale.ROOT,"%s(...) only works with at least 2 values but 0 were provided", constructingFactory.getFunctionName(getClass()));
+      }
+      throw new IOException(message);
+    }
+    
+    Checker checker = constructChecker(results.get(0));
+    if(results.stream().anyMatch(result -> null == result && !checker.isNullAllowed())){
+      return false;
+    }
+    if(results.stream().anyMatch(result -> !checker.isCorrectType(result))){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) of differing types [%s]", constructingFactory.getFunctionName(getClass()), results.stream().map(item -> item.getClass().getSimpleName()).collect(Collectors.joining(","))));
+    }
+
+    for(int idx = 1; idx < results.size(); ++idx){
+      if(!checker.test(results.get(0), results.get(idx))){
+        return false;
+      }
+    }
+    
+    return true;
+  }
+  
+  private Checker constructChecker(Object fromValue) throws IOException{
+    if(null == fromValue){
+      return new NullChecker() {
+        @Override
+        public boolean test(Object left, Object right) {
+          return null == left && null == right;
+        }
+      };
+    }
+    else if(fromValue instanceof Boolean){
+      return new BooleanChecker(){
+        @Override
+        public boolean test(Object left, Object right) {
+          return (boolean)left.equals((boolean)right);
+        }
+      };
+    }
+    else if(fromValue instanceof Number){
+      return new NumberChecker(){
+        @Override
+        public boolean test(Object left, Object right) {
+          return 0 == (new BigDecimal(left.toString())).compareTo(new BigDecimal(right.toString()));
+        }
+      };
+    }
+    else if(fromValue instanceof String){
+      return new StringChecker(){
+        @Override
+        public boolean test(Object left, Object right) {
+          return left.equals(right);
+        }
+      };
+    }
+    
+    throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) for values of type '%s'", constructingFactory.getFunctionName(getClass()), fromValue.getClass().getSimpleName()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ExclusiveOrEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ExclusiveOrEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ExclusiveOrEvaluator.java
new file mode 100644
index 0000000..e63cab0
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/ExclusiveOrEvaluator.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Locale;
+import java.util.stream.Collectors;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class ExclusiveOrEvaluator extends BooleanEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public ExclusiveOrEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+    
+    if(subEvaluators.size() < 2){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting at least two values but found %d",expression,subEvaluators.size()));
+    }
+  }
+
+  @Override
+  public Boolean evaluate(Tuple tuple) throws IOException {
+    
+    List<Object> results = evaluateAll(tuple);
+    
+    if(results.size() < 2){
+      String message = null;
+      if(1 == results.size()){
+        message = String.format(Locale.ROOT,"%s(...) only works with at least 2 values but 1 was provided", constructingFactory.getFunctionName(getClass())); 
+      }
+      else{
+        message = String.format(Locale.ROOT,"%s(...) only works with at least 2 values but 0 were provided", constructingFactory.getFunctionName(getClass()));
+      }
+      throw new IOException(message);
+    }
+    
+    if(results.stream().anyMatch(result -> null == result)){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) because a null value was found", constructingFactory.getFunctionName(getClass())));
+    }
+    if(results.stream().anyMatch(result -> !(result instanceof Boolean))){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) of non-boolean values [%s]", constructingFactory.getFunctionName(getClass()), results.stream().map(item -> item.getClass().getSimpleName()).collect(Collectors.joining(","))));
+    }
+
+    return 1 == results.stream().filter(result -> (boolean)result).count();
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/FieldEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/FieldEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/FieldEvaluator.java
new file mode 100644
index 0000000..0ebe729
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/FieldEvaluator.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.Explanation;
+import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParameter;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionValue;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class FieldEvaluator extends SimpleEvaluator {
+  private static final long serialVersionUID = 1L;
+  
+  private String fieldName;
+  
+  public FieldEvaluator(String fieldName) {
+    if(fieldName.startsWith("'") && fieldName.endsWith("'") && fieldName.length() > 1){
+      fieldName = fieldName.substring(1, fieldName.length() - 1);
+    }
+    
+    this.fieldName = fieldName;
+  }
+  
+  @Override
+  public Object evaluate(Tuple tuple) {
+    return tuple.get(fieldName); // returns null if field doesn't exist in tuple
+  }
+  
+  @Override
+  public StreamExpressionParameter toExpression(StreamFactory factory) throws IOException {
+    return new StreamExpressionValue(fieldName);
+  }
+
+  @Override
+  public Explanation toExplanation(StreamFactory factory) throws IOException {
+    return new Explanation(nodeId.toString())
+      .withExpressionType(ExpressionType.EVALUATOR)
+      .withImplementingClass(getClass().getName())
+      .withExpression(toExpression(factory).toString());
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/GreaterThanEqualToEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/GreaterThanEqualToEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/GreaterThanEqualToEvaluator.java
new file mode 100644
index 0000000..ad79e82
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/GreaterThanEqualToEvaluator.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Locale;
+import java.util.stream.Collectors;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class GreaterThanEqualToEvaluator extends BooleanEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public GreaterThanEqualToEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+    
+    if(subEvaluators.size() < 2){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting at least two values but found %d",expression,subEvaluators.size()));
+    }
+  }
+
+  @Override
+  public Boolean evaluate(Tuple tuple) throws IOException {
+    
+    List<Object> results = evaluateAll(tuple);
+    
+    if(results.size() < 2){
+      String message = null;
+      if(1 == results.size()){
+        message = String.format(Locale.ROOT,"%s(...) only works with at least 2 values but 1 was provided", constructingFactory.getFunctionName(getClass())); 
+      }
+      else{
+        message = String.format(Locale.ROOT,"%s(...) only works with at least 2 values but 0 were provided", constructingFactory.getFunctionName(getClass()));
+      }
+      throw new IOException(message);
+    }
+    
+    Checker checker = constructChecker(results.get(0));
+    if(results.stream().anyMatch(result -> null == result)){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) because a null value was found", constructingFactory.getFunctionName(getClass())));
+    }
+    if(results.stream().anyMatch(result -> !checker.isCorrectType(result))){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) of differing types [%s]", constructingFactory.getFunctionName(getClass()), results.stream().map(item -> item.getClass().getSimpleName()).collect(Collectors.joining(","))));
+    }
+
+    for(int idx = 1; idx < results.size(); ++idx){
+      if(!checker.test(results.get(idx - 1), results.get(idx))){
+        return false;
+      }
+    }
+    
+    return true;
+  }
+  
+  private Checker constructChecker(Object fromValue) throws IOException{
+    if(null == fromValue){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) because a null value was found", constructingFactory.getFunctionName(getClass())));
+    }
+    else if(fromValue instanceof Number){
+      return new NumberChecker(){
+        @Override
+        public boolean test(Object left, Object right) {
+          return (new BigDecimal(left.toString())).compareTo(new BigDecimal(right.toString())) >= 0;
+        }
+      };
+    }
+    else if(fromValue instanceof String){
+      return new StringChecker(){
+        @Override
+        public boolean test(Object left, Object right) {
+          return ((String)left).compareToIgnoreCase((String)right) >= 0;
+        }
+      };
+    }
+    
+    throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) for values of type '%s'", constructingFactory.getFunctionName(getClass()), fromValue.getClass().getSimpleName()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/GreaterThanEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/GreaterThanEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/GreaterThanEvaluator.java
new file mode 100644
index 0000000..0b0e6e3
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/GreaterThanEvaluator.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Locale;
+import java.util.stream.Collectors;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class GreaterThanEvaluator extends BooleanEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public GreaterThanEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+    
+    if(subEvaluators.size() < 2){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting at least two values but found %d",expression,subEvaluators.size()));
+    }
+  }
+
+  @Override
+  public Boolean evaluate(Tuple tuple) throws IOException {
+    
+    List<Object> results = evaluateAll(tuple);
+    
+    if(results.size() < 2){
+      String message = null;
+      if(1 == results.size()){
+        message = String.format(Locale.ROOT,"%s(...) only works with at least 2 values but 1 was provided", constructingFactory.getFunctionName(getClass())); 
+      }
+      else{
+        message = String.format(Locale.ROOT,"%s(...) only works with at least 2 values but 0 were provided", constructingFactory.getFunctionName(getClass()));
+      }
+      throw new IOException(message);
+    }
+    
+    Checker checker = constructChecker(results.get(0));
+    if(results.stream().anyMatch(result -> null == result)){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) because a null value was found", constructingFactory.getFunctionName(getClass())));
+    }
+    if(results.stream().anyMatch(result -> !checker.isCorrectType(result))){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) of differing types [%s]", constructingFactory.getFunctionName(getClass()), results.stream().map(item -> item.getClass().getSimpleName()).collect(Collectors.joining(","))));
+    }
+
+    for(int idx = 1; idx < results.size(); ++idx){
+      if(!checker.test(results.get(idx - 1), results.get(idx))){
+        return false;
+      }
+    }
+    
+    return true;
+  }
+  
+  private Checker constructChecker(Object fromValue) throws IOException{
+    if(null == fromValue){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) because a null value was found", constructingFactory.getFunctionName(getClass())));
+    }
+    else if(fromValue instanceof Number){
+      return new NumberChecker(){
+        @Override
+        public boolean test(Object left, Object right) {
+          return (new BigDecimal(left.toString())).compareTo(new BigDecimal(right.toString())) > 0;
+        }
+      };
+    }
+    else if(fromValue instanceof String){
+      return new StringChecker(){
+        @Override
+        public boolean test(Object left, Object right) {
+          return ((String)left).compareToIgnoreCase((String)right) > 0;
+        }
+      };
+    }
+    
+    throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) for values of type '%s'", constructingFactory.getFunctionName(getClass()), fromValue.getClass().getSimpleName()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/IfThenElseEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/IfThenElseEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/IfThenElseEvaluator.java
new file mode 100644
index 0000000..346b743
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/IfThenElseEvaluator.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class IfThenElseEvaluator extends ConditionalEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public IfThenElseEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+    
+    if(3 != subEvaluators.size()){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting three values but found %d",expression,subEvaluators.size()));
+    }
+    
+    if(!(subEvaluators.get(0) instanceof BooleanEvaluator)){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting a boolean as the first parameter but found %s",expression,subEvaluators.get(0).getClass().getSimpleName()));
+    }
+
+  }
+
+  @Override
+  public Object evaluate(Tuple tuple) throws IOException {
+    
+    List<Object> results = evaluateAll(tuple);
+    
+    if(3 != results.size()){
+      String message = String.format(Locale.ROOT,"%s(...) only works with 3 values but %s were provided", constructingFactory.getFunctionName(getClass()), results.size());
+      throw new IOException(message);
+    }
+    
+    if(!(results.get(0) instanceof Boolean)){
+      throw new IOException(String.format(Locale.ROOT,"$s(...) only works with a boolean as the first parameter but found %s",results.get(0).getClass().getSimpleName()));
+    }
+  
+    return (boolean)results.get(0) ? results.get(1) : results.get(2);
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/LessThanEqualToEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/LessThanEqualToEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/LessThanEqualToEvaluator.java
new file mode 100644
index 0000000..cb2fc7a
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/LessThanEqualToEvaluator.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Locale;
+import java.util.stream.Collectors;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class LessThanEqualToEvaluator extends BooleanEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public LessThanEqualToEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+    
+    if(subEvaluators.size() < 2){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting at least two values but found %d",expression,subEvaluators.size()));
+    }
+  }
+
+  @Override
+  public Boolean evaluate(Tuple tuple) throws IOException {
+    
+    List<Object> results = evaluateAll(tuple);
+    
+    if(results.size() < 2){
+      String message = null;
+      if(1 == results.size()){
+        message = String.format(Locale.ROOT,"%s(...) only works with at least 2 values but 1 was provided", constructingFactory.getFunctionName(getClass())); 
+      }
+      else{
+        message = String.format(Locale.ROOT,"%s(...) only works with at least 2 values but 0 were provided", constructingFactory.getFunctionName(getClass()));
+      }
+      throw new IOException(message);
+    }
+    
+    Checker checker = constructChecker(results.get(0));
+    if(results.stream().anyMatch(result -> null == result)){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) because a null value was found", constructingFactory.getFunctionName(getClass())));
+    }
+    if(results.stream().anyMatch(result -> !checker.isCorrectType(result))){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) of differing types [%s]", constructingFactory.getFunctionName(getClass()), results.stream().map(item -> item.getClass().getSimpleName()).collect(Collectors.joining(","))));
+    }
+
+    for(int idx = 1; idx < results.size(); ++idx){
+      if(!checker.test(results.get(idx - 1), results.get(idx))){
+        return false;
+      }
+    }
+    
+    return true;
+  }
+  
+  private Checker constructChecker(Object fromValue) throws IOException{
+    if(null == fromValue){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) because a null value was found", constructingFactory.getFunctionName(getClass())));
+    }
+    else if(fromValue instanceof Number){
+      return new NumberChecker(){
+        @Override
+        public boolean test(Object left, Object right) {
+          return (new BigDecimal(left.toString())).compareTo(new BigDecimal(right.toString())) <= 0;
+        }
+      };
+    }
+    else if(fromValue instanceof String){
+      return new StringChecker(){
+        @Override
+        public boolean test(Object left, Object right) {
+          return ((String)left).compareToIgnoreCase((String)right) <= 0;
+        }
+      };
+    }
+    
+    throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) for values of type '%s'", constructingFactory.getFunctionName(getClass()), fromValue.getClass().getSimpleName()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/LessThanEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/LessThanEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/LessThanEvaluator.java
new file mode 100644
index 0000000..40796b8
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/LessThanEvaluator.java
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Locale;
+import java.util.stream.Collectors;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class LessThanEvaluator extends BooleanEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public LessThanEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+    
+    if(subEvaluators.size() < 2){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting at least two values but found %d",expression,subEvaluators.size()));
+    }
+  }
+
+  @Override
+  public Boolean evaluate(Tuple tuple) throws IOException {
+    
+    List<Object> results = evaluateAll(tuple);
+    
+    if(results.size() < 2){
+      String message = null;
+      if(1 == results.size()){
+        message = String.format(Locale.ROOT,"%s(...) only works with at least 2 values but 1 was provided", constructingFactory.getFunctionName(getClass())); 
+      }
+      else{
+        message = String.format(Locale.ROOT,"%s(...) only works with at least 2 values but 0 were provided", constructingFactory.getFunctionName(getClass()));
+      }
+      throw new IOException(message);
+    }
+    
+    Checker checker = constructChecker(results.get(0));
+    if(results.stream().anyMatch(result -> null == result)){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) because a null value was found", constructingFactory.getFunctionName(getClass())));
+    }
+    if(results.stream().anyMatch(result -> !checker.isCorrectType(result))){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) of differing types [%s]", constructingFactory.getFunctionName(getClass()), results.stream().map(item -> item.getClass().getSimpleName()).collect(Collectors.joining(","))));
+    }
+
+    for(int idx = 1; idx < results.size(); ++idx){
+      if(!checker.test(results.get(idx - 1), results.get(idx))){
+        return false;
+      }
+    }
+    
+    return true;
+  }
+  
+  private Checker constructChecker(Object fromValue) throws IOException{
+    if(null == fromValue){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) because a null value was found", constructingFactory.getFunctionName(getClass())));
+    }
+    else if(fromValue instanceof Number){
+      return new NumberChecker(){
+        @Override
+        public boolean test(Object left, Object right) {
+          return (new BigDecimal(left.toString())).compareTo(new BigDecimal(right.toString())) < 0;
+        }
+      };
+    }
+    else if(fromValue instanceof String){
+      return new StringChecker(){
+        @Override
+        public boolean test(Object left, Object right) {
+          return ((String)left).compareToIgnoreCase((String)right) < 0;
+        }
+      };
+    }
+    
+    throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) for values of type '%s'", constructingFactory.getFunctionName(getClass()), fromValue.getClass().getSimpleName()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/MultiplyEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/MultiplyEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/MultiplyEvaluator.java
new file mode 100644
index 0000000..44b0b26
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/MultiplyEvaluator.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.math.MathContext;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class MultiplyEvaluator extends NumberEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public MultiplyEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+    
+    if(subEvaluators.size() < 2){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting at least two values but found %d",expression,subEvaluators.size()));
+    }
+  }
+
+  @Override
+  public Number evaluate(Tuple tuple) throws IOException {
+    
+    List<BigDecimal> results = evaluateAll(tuple);
+    
+    if(results.stream().anyMatch(item -> null == item)){
+      return null;
+    }
+    
+    BigDecimal result = null;
+    if(results.size() > 0){
+      result = results.get(0);
+      for(int idx = 1; idx < results.size(); ++idx){
+        result = result.multiply(results.get(idx), MathContext.DECIMAL64);
+      }
+    }
+    
+    return normalizeType(result);
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/NotEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/NotEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/NotEvaluator.java
new file mode 100644
index 0000000..da2eeff
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/NotEvaluator.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Locale;
+import java.util.stream.Collectors;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class NotEvaluator extends BooleanEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public NotEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+    
+    if(1 != subEvaluators.size()){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting one value but found %d",expression,subEvaluators.size()));
+    }
+  }
+
+  @Override
+  public Boolean evaluate(Tuple tuple) throws IOException {
+    
+    List<Object> results = evaluateAll(tuple);
+    
+    if(1 != results.size()){
+      String message = String.format(Locale.ROOT,"%s(...) only works with 1 value but %d were provided", constructingFactory.getFunctionName(getClass()), results.size());
+      throw new IOException(message);
+    }
+
+    Object result = results.get(0);
+    if(null == result){
+      throw new IOException(String.format(Locale.ROOT,"Unable to evaluate %s(...) because a null value was found", constructingFactory.getFunctionName(getClass())));
+    }
+    if(!(result instanceof Boolean)){
+      throw new IOException(String.format(Locale.ROOT,"Unable to evaluate %s(...) of a non-boolean value [%s]", constructingFactory.getFunctionName(getClass()), results.stream().map(item -> item.getClass().getSimpleName()).collect(Collectors.joining(","))));
+    }
+    
+    return !((Boolean)result);
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/NumberEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/NumberEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/NumberEvaluator.java
new file mode 100644
index 0000000..f4491fd
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/NumberEvaluator.java
@@ -0,0 +1,79 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public abstract class NumberEvaluator extends ComplexEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public NumberEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+  }
+  
+  // restrict result to a Number
+  public abstract Number evaluate(Tuple tuple) throws IOException;
+  
+  public List<BigDecimal> evaluateAll(final Tuple tuple) throws IOException {
+    // evaluate each and confirm they are all either null or numeric
+    List<BigDecimal> results = new ArrayList<BigDecimal>();
+    for(StreamEvaluator subEvaluator : subEvaluators){
+      Object result = subEvaluator.evaluate(tuple);
+      
+      if(null == result){
+        results.add(null);
+      }
+      else if(result instanceof Number){
+        results.add(new BigDecimal(result.toString()));
+      }
+      else{
+        String message = String.format(Locale.ROOT,"Failed to evaluate to a numeric value - evaluator '%s' resulted in type '%s' and value '%s'", 
+                                        subEvaluator.toExpression(constructingFactory),
+                                        result.getClass().getName(),
+                                        result.toString());
+        throw new IOException(message);
+      }
+    }
+    
+    return results;
+  }
+  
+  public Number normalizeType(BigDecimal value){
+    if(null == value){
+      return null;
+    }
+    
+    if(value.signum() == 0 || value.scale() <= 0 || value.stripTrailingZeros().scale() <= 0){
+      return value.longValue();
+    }
+    
+    return value.doubleValue();
+
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/OrEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/OrEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/OrEvaluator.java
new file mode 100644
index 0000000..1cd9df8
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/OrEvaluator.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Locale;
+import java.util.stream.Collectors;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class OrEvaluator extends BooleanEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public OrEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+    
+    if(subEvaluators.size() < 2){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting at least two values but found %d",expression,subEvaluators.size()));
+    }
+  }
+
+  @Override
+  public Boolean evaluate(Tuple tuple) throws IOException {
+    
+    List<Object> results = evaluateAll(tuple);
+    
+    if(results.size() < 2){
+      String message = null;
+      if(1 == results.size()){
+        message = String.format(Locale.ROOT,"%s(...) only works with at least 2 values but 1 was provided", constructingFactory.getFunctionName(getClass())); 
+      }
+      else{
+        message = String.format(Locale.ROOT,"%s(...) only works with at least 2 values but 0 were provided", constructingFactory.getFunctionName(getClass()));
+      }
+      throw new IOException(message);
+    }
+    
+    Checker checker = constructChecker(results.get(0));
+    if(results.stream().anyMatch(result -> null == result && !checker.isNullAllowed())){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) because a null value was found", constructingFactory.getFunctionName(getClass())));
+    }
+    if(results.stream().anyMatch(result -> !checker.isCorrectType(result))){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) of differing types [%s]", constructingFactory.getFunctionName(getClass()), results.stream().map(item -> item.getClass().getSimpleName()).collect(Collectors.joining(","))));
+    }
+
+    for(int idx = 1; idx < results.size(); ++idx){
+      if(!checker.test(results.get(0), results.get(idx))){
+        return false;
+      }
+    }
+    
+    return true;
+  }
+  
+  private Checker constructChecker(Object fromValue) throws IOException{
+    if(null == fromValue){
+      throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) because a null value was found", constructingFactory.getFunctionName(getClass())));
+    }
+    else if(fromValue instanceof Boolean){
+      return new BooleanChecker(){
+        @Override
+        public boolean test(Object left, Object right) {
+          return (boolean)left || (boolean)right;
+        }
+      };
+    }
+    
+    throw new IOException(String.format(Locale.ROOT,"Unable to check %s(...) for values of type '%s'", constructingFactory.getFunctionName(getClass()), fromValue.getClass().getSimpleName()));
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/RawValueEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/RawValueEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/RawValueEvaluator.java
new file mode 100644
index 0000000..1751380
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/RawValueEvaluator.java
@@ -0,0 +1,90 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.Explanation;
+import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParameter;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionValue;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class RawValueEvaluator extends SimpleEvaluator {
+  private static final long serialVersionUID = 1L;
+  
+  private Object value;
+  
+  public RawValueEvaluator(Object value){
+    init(value);
+  }
+  
+  public RawValueEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    // We have to do this because order of the parameters matter
+    List<StreamExpressionParameter> parameters = factory.getOperandsOfType(expression, StreamExpressionValue.class);
+    
+    if(expression.getParameters().size() != parameters.size()){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - unknown operands found - expecting only raw values", expression));
+    }
+    
+    if(1 != parameters.size()){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - only 1 value can exist in a %s(...) evaluator", expression, factory.getFunctionName(getClass())));
+    }
+    
+    init(factory.constructPrimitiveObject(((StreamExpressionValue)parameters.get(0)).getValue()));
+  }
+  
+  private void init(Object value){
+    if(value instanceof Integer){
+      this.value = (Long)value;
+    }
+    else if(value instanceof Float){
+      this.value = ((Float)value).doubleValue();
+    }
+    else{
+      this.value = value;
+    }
+  }
+  
+  @Override
+  public Object evaluate(Tuple tuple) {
+    return value;
+  }
+  
+  @Override
+  public StreamExpressionParameter toExpression(StreamFactory factory) throws IOException {
+    StreamExpression expression = new StreamExpression(factory.getFunctionName(getClass()));
+    expression.addParameter(new StreamExpressionValue(value.toString()));
+    return expression;
+  }
+
+  @Override
+  public Explanation toExplanation(StreamFactory factory) throws IOException {
+    return new Explanation(nodeId.toString())
+      .withExpressionType(ExpressionType.EVALUATOR)
+      .withImplementingClass(getClass().getName())
+      .withExpression(toExpression(factory).toString());
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SimpleEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SimpleEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SimpleEvaluator.java
new file mode 100644
index 0000000..79d1799
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SimpleEvaluator.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.util.UUID;
+
+public abstract class SimpleEvaluator implements StreamEvaluator {
+  private static final long serialVersionUID = 1L;
+  
+  protected UUID nodeId = UUID.randomUUID();
+
+}


[2/3] lucene-solr:branch_6x: SOLR-9916: Adds Stream Evaluators to support evaluating values from tuples

Posted by dp...@apache.org.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/StreamEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/StreamEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/StreamEvaluator.java
new file mode 100644
index 0000000..6bc4d50
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/StreamEvaluator.java
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.io.Serializable;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.Expressible;
+
+public interface StreamEvaluator extends Expressible, Serializable {
+  Object evaluate(final Tuple tuple) throws IOException;
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SubtractEvaluator.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SubtractEvaluator.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SubtractEvaluator.java
new file mode 100644
index 0000000..3bf62b7
--- /dev/null
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/eval/SubtractEvaluator.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * 
+ */
+package org.apache.solr.client.solrj.io.eval;
+
+import java.io.IOException;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+
+public class SubtractEvaluator extends NumberEvaluator {
+  protected static final long serialVersionUID = 1L;
+  
+  public SubtractEvaluator(StreamExpression expression, StreamFactory factory) throws IOException{
+    super(expression, factory);
+    
+    if(subEvaluators.size() < 2){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting at least two values but found %d",expression,subEvaluators.size()));
+    }
+  }
+
+  @Override
+  public Number evaluate(Tuple tuple) throws IOException {
+    
+    List<BigDecimal> results = evaluateAll(tuple);
+    
+    if(results.stream().anyMatch(item -> null == item)){
+      return null;
+    }
+    
+    BigDecimal result = null;
+    if(results.size() > 0){
+      result = results.get(0);
+      for(int idx = 1; idx < results.size(); ++idx){
+        result = result.subtract(results.get(idx));
+      }
+    }
+    
+    return normalizeType(result);
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/AndOperation.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/AndOperation.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/AndOperation.java
deleted file mode 100644
index f095f63..0000000
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/AndOperation.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.client.solrj.io.ops;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.UUID;
-
-import org.apache.solr.client.solrj.io.Tuple;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
-import org.apache.solr.client.solrj.io.stream.expr.Expressible;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParameter;
-import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
-
-public class AndOperation implements BooleanOperation {
-
-  private static final long serialVersionUID = 1;
-  private UUID operationNodeId = UUID.randomUUID();
-
-  protected BooleanOperation leftOperand;
-  protected BooleanOperation rightOperand;
-
-  public void operate(Tuple tuple) {
-    leftOperand.operate(tuple);
-    rightOperand.operate(tuple);
-  }
-
-  public AndOperation(BooleanOperation leftOperand, BooleanOperation rightOperand) {
-    this.leftOperand = leftOperand;
-    this.rightOperand = rightOperand;
-  }
-
-  public AndOperation(StreamExpression expression, StreamFactory factory) throws IOException {
-      List<StreamExpression> operationExpressions = factory.getExpressionOperandsRepresentingTypes(expression, BooleanOperation.class);
-      if(operationExpressions != null && operationExpressions.size() == 2) {
-        StreamExpression left = operationExpressions.get(0);
-        StreamOperation leftOp = factory.constructOperation(left);
-        if(leftOp instanceof BooleanOperation) {
-          leftOperand = (BooleanOperation) leftOp;
-        } else {
-          throw new IOException("The And/Or Operation requires a BooleanOperation.");
-        }
-
-        StreamExpression right = operationExpressions.get(1);
-        StreamOperation rightOp = factory.constructOperation(right);
-        if(rightOp instanceof BooleanOperation) {
-          rightOperand = (BooleanOperation) rightOp;
-        } else {
-          throw new IOException("The And/Or Operation requires a BooleanOperation.");
-        }
-      } else {
-        throw new IOException("The And/Or Operation requires a BooleanOperations.");
-      }
-  }
-
-  public boolean evaluate() {
-    return leftOperand.evaluate() && rightOperand.evaluate();
-  }
-
-  @Override
-  public StreamExpressionParameter toExpression(StreamFactory factory) throws IOException {
-    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
-    if(leftOperand instanceof Expressible) {
-      expression.addParameter(leftOperand.toExpression(factory));
-    } else {
-      throw new IOException("This left operand of the AndOperation contains a non-expressible operation - it cannot be converted to an expression");
-    }
-
-    if(rightOperand instanceof Expressible) {
-      expression.addParameter(rightOperand.toExpression(factory));
-    } else {
-      throw new IOException("This the right operand of the AndOperation contains a non-expressible operation - it cannot be converted to an expression");
-    }
-    return expression;
-  }
-
-  @Override
-  public Explanation toExplanation(StreamFactory factory) throws IOException {
-    return new Explanation(operationNodeId.toString())
-        .withExpressionType(ExpressionType.OPERATION)
-        .withFunctionName(factory.getFunctionName(getClass()))
-        .withImplementingClass(getClass().getName())
-        .withExpression(toExpression(factory).toString());
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/BooleanOperation.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/BooleanOperation.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/BooleanOperation.java
deleted file mode 100644
index d455999..0000000
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/BooleanOperation.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.client.solrj.io.ops;
-
-/**
- *  A BooleanOperation returns true or false for each tuple that it evaluates. The HavingStream applies a BooleanOperation to
- *  determine which tuples to emit.
- */
-
-public interface BooleanOperation extends StreamOperation {
-  public abstract boolean evaluate();
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/EqualsOperation.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/EqualsOperation.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/EqualsOperation.java
deleted file mode 100644
index 1958551..0000000
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/EqualsOperation.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.client.solrj.io.ops;
-
-import java.io.IOException;
-import java.util.UUID;
-
-import org.apache.solr.client.solrj.io.Tuple;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
-import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
-
-public class EqualsOperation extends LeafOperation {
-
-  private static final long serialVersionUID = 1;
-  private UUID operationNodeId = UUID.randomUUID();
-
-  public void operate(Tuple tuple) {
-    this.tuple = tuple;
-  }
-
-  public EqualsOperation(String field, double val) {
-    super(field, val);
-  }
-
-  public EqualsOperation(StreamExpression expression, StreamFactory factory) throws IOException {
-    super(expression, factory);
-  }
-
-  public boolean evaluate() {
-    Double d = tuple.getDouble(field);
-
-    if(d == null) {
-      return false;
-    }
-
-    return d.doubleValue() == val;
-  }
-
-  public StreamExpression toExpression(StreamFactory factory) throws IOException {
-    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
-    expression.addParameter(field);
-    expression.addParameter(Double.toString(val));
-    return expression;
-  }
-
-  @Override
-  public Explanation toExplanation(StreamFactory factory) throws IOException {
-    return new Explanation(operationNodeId.toString())
-        .withExpressionType(ExpressionType.OPERATION)
-        .withFunctionName(factory.getFunctionName(getClass()))
-        .withImplementingClass(getClass().getName())
-        .withExpression(toExpression(factory).toString());
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/GreaterThanEqualToOperation.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/GreaterThanEqualToOperation.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/GreaterThanEqualToOperation.java
deleted file mode 100644
index 87c8364..0000000
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/GreaterThanEqualToOperation.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.client.solrj.io.ops;
-
-import java.io.IOException;
-import java.util.UUID;
-
-import org.apache.solr.client.solrj.io.Tuple;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
-import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
-
-public class GreaterThanEqualToOperation extends LeafOperation {
-
-  private static final long serialVersionUID = 1;
-  private UUID operationNodeId = UUID.randomUUID();
-
-  public void operate(Tuple tuple) {
-    this.tuple = tuple;
-  }
-
-  public GreaterThanEqualToOperation(String field, double val) {
-    super(field, val);
-  }
-
-  public GreaterThanEqualToOperation(StreamExpression expression, StreamFactory factory) throws IOException {
-    super(expression, factory);
-  }
-
-  public boolean evaluate() {
-    Double d = tuple.getDouble(field);
-
-    if(d == null) {
-      return false;
-    }
-
-    return d.doubleValue() >= val;
-  }
-
-  public StreamExpression toExpression(StreamFactory factory) throws IOException {
-    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
-    expression.addParameter(field);
-    expression.addParameter(Double.toString(val));
-    return expression;
-  }
-
-  @Override
-  public Explanation toExplanation(StreamFactory factory) throws IOException {
-    return new Explanation(operationNodeId.toString())
-        .withExpressionType(ExpressionType.OPERATION)
-        .withFunctionName(factory.getFunctionName(getClass()))
-        .withImplementingClass(getClass().getName())
-        .withExpression(toExpression(factory).toString());
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/GreaterThanOperation.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/GreaterThanOperation.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/GreaterThanOperation.java
deleted file mode 100644
index 664438a..0000000
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/GreaterThanOperation.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.client.solrj.io.ops;
-
-import java.io.IOException;
-import java.util.UUID;
-
-import org.apache.solr.client.solrj.io.Tuple;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
-import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
-
-public class GreaterThanOperation extends LeafOperation {
-
-  private static final long serialVersionUID = 1;
-  private UUID operationNodeId = UUID.randomUUID();
-
-  public void operate(Tuple tuple) {
-    this.tuple = tuple;
-  }
-
-  public GreaterThanOperation(String field, double val) {
-    super(field, val);
-  }
-
-  public GreaterThanOperation(StreamExpression expression, StreamFactory factory) throws IOException {
-    super(expression, factory);
-  }
-
-  public boolean evaluate() {
-    Double d = tuple.getDouble(field);
-
-    if(d == null) {
-      return false;
-    }
-
-    return d.doubleValue() > val;
-  }
-
-  public StreamExpression toExpression(StreamFactory factory) throws IOException {
-    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
-    expression.addParameter(field);
-    expression.addParameter(Double.toString(val));
-    return expression;
-  }
-
-  @Override
-  public Explanation toExplanation(StreamFactory factory) throws IOException {
-    return new Explanation(operationNodeId.toString())
-        .withExpressionType(ExpressionType.OPERATION)
-        .withFunctionName(factory.getFunctionName(getClass()))
-        .withImplementingClass(getClass().getName())
-        .withExpression(toExpression(factory).toString());
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/LeafOperation.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/LeafOperation.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/LeafOperation.java
deleted file mode 100644
index 691a328..0000000
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/LeafOperation.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.client.solrj.io.ops;
-
-import java.io.IOException;
-import java.util.UUID;
-
-import org.apache.solr.client.solrj.io.Tuple;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
-import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
-
-public abstract class LeafOperation implements BooleanOperation {
-
-  private static final long serialVersionUID = 1;
-  private UUID operationNodeId = UUID.randomUUID();
-
-  protected String field;
-  protected Double val;
-  protected Tuple tuple;
-
-  public void operate(Tuple tuple) {
-    this.tuple = tuple;
-  }
-
-  public LeafOperation(String field, double val) {
-    this.field = field;
-    this.val = val;
-  }
-
-  public LeafOperation(StreamExpression expression, StreamFactory factory) throws IOException {
-    this.field = factory.getValueOperand(expression, 0);
-    this.val = Double.parseDouble(factory.getValueOperand(expression, 1));
-  }
-
-  @Override
-  public Explanation toExplanation(StreamFactory factory) throws IOException {
-    return new Explanation(operationNodeId.toString())
-        .withExpressionType(ExpressionType.OPERATION)
-        .withFunctionName(factory.getFunctionName(getClass()))
-        .withImplementingClass(getClass().getName())
-        .withExpression(toExpression(factory).toString());
-  }
-
-  protected String quote(String s) {
-    if(s.contains("(")) {
-      return "'"+s+"'";
-    }
-
-    return s;
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/LessThanEqualToOperation.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/LessThanEqualToOperation.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/LessThanEqualToOperation.java
deleted file mode 100644
index 2da3274..0000000
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/LessThanEqualToOperation.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.client.solrj.io.ops;
-
-import java.io.IOException;
-import java.util.UUID;
-
-import org.apache.solr.client.solrj.io.Tuple;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
-import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
-
-public class LessThanEqualToOperation extends LeafOperation {
-
-  private static final long serialVersionUID = 1;
-  private UUID operationNodeId = UUID.randomUUID();
-
-  public void operate(Tuple tuple) {
-    this.tuple = tuple;
-  }
-
-  public LessThanEqualToOperation(String field, double val) {
-    super(field, val);
-  }
-
-  public LessThanEqualToOperation(StreamExpression expression, StreamFactory factory) throws IOException {
-    super(expression, factory);
-  }
-
-  public boolean evaluate() {
-    Double d = tuple.getDouble(field);
-
-    if(d == null) {
-      return true;
-    }
-
-    return d.doubleValue() <= val;
-  }
-
-  public StreamExpression toExpression(StreamFactory factory) throws IOException {
-    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
-    expression.addParameter(field);
-    expression.addParameter(Double.toString(val));
-    return expression;
-  }
-
-  @Override
-  public Explanation toExplanation(StreamFactory factory) throws IOException {
-    return new Explanation(operationNodeId.toString())
-        .withExpressionType(ExpressionType.OPERATION)
-        .withFunctionName(factory.getFunctionName(getClass()))
-        .withImplementingClass(getClass().getName())
-        .withExpression(toExpression(factory).toString());
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/LessThanOperation.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/LessThanOperation.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/LessThanOperation.java
deleted file mode 100644
index c1cec95..0000000
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/LessThanOperation.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.client.solrj.io.ops;
-
-import java.io.IOException;
-import java.util.UUID;
-
-import org.apache.solr.client.solrj.io.Tuple;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
-import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
-
-public class LessThanOperation extends LeafOperation {
-
-  private static final long serialVersionUID = 1;
-  private UUID operationNodeId = UUID.randomUUID();
-
-  public void operate(Tuple tuple) {
-    this.tuple = tuple;
-  }
-
-  public LessThanOperation(String field, double val) {
-    super(field, val);
-  }
-
-  public LessThanOperation(StreamExpression expression, StreamFactory factory) throws IOException {
-    super(expression, factory);
-  }
-
-  public boolean evaluate() {
-    Double d = tuple.getDouble(field);
-
-    if(d == null) {
-      return true;
-    }
-    
-    return d.doubleValue() < val;
-  }
-
-  public StreamExpression toExpression(StreamFactory factory) throws IOException {
-    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
-    expression.addParameter(field);
-    expression.addParameter(Double.toString(val));
-    return expression;
-  }
-
-  @Override
-  public Explanation toExplanation(StreamFactory factory) throws IOException {
-    return new Explanation(operationNodeId.toString())
-        .withExpressionType(ExpressionType.OPERATION)
-        .withFunctionName(factory.getFunctionName(getClass()))
-        .withImplementingClass(getClass().getName())
-        .withExpression(toExpression(factory).toString());
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/NotOperation.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/NotOperation.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/NotOperation.java
deleted file mode 100644
index 0e40b72..0000000
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/NotOperation.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.client.solrj.io.ops;
-
-import java.io.IOException;
-import java.util.List;
-import java.util.UUID;
-
-import org.apache.solr.client.solrj.io.Tuple;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
-import org.apache.solr.client.solrj.io.stream.expr.Expressible;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParameter;
-import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
-
-
-public class NotOperation implements BooleanOperation {
-
-  private static final long serialVersionUID = 1;
-  private UUID operationNodeId = UUID.randomUUID();
-
-  protected BooleanOperation operand;
-
-  public void operate(Tuple tuple) {
-    operand.operate(tuple);
-  }
-
-  public NotOperation(BooleanOperation operand) {
-    this.operand = operand;
-  }
-
-  public NotOperation(StreamExpression expression, StreamFactory factory) throws IOException {
-    List<StreamExpression> operationExpressions = factory.getExpressionOperandsRepresentingTypes(expression, BooleanOperation.class);
-    if(operationExpressions != null && operationExpressions.size() == 1) {
-      StreamExpression op = operationExpressions.get(0);
-      StreamOperation streamOp = factory.constructOperation(op);
-      if(streamOp instanceof BooleanOperation) {
-        operand = (BooleanOperation) streamOp;
-      } else {
-        throw new IOException("The NotOperation requires a BooleanOperation.");
-      }
-
-    } else {
-      throw new IOException("The NotOperation requires a BooleanOperations.");
-    }
-  }
-
-  public boolean evaluate() {
-    return !operand.evaluate();
-  }
-
-  @Override
-  public StreamExpressionParameter toExpression(StreamFactory factory) throws IOException {
-    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
-    if(operand instanceof Expressible) {
-      expression.addParameter(operand.toExpression(factory));
-    } else {
-      throw new IOException("The operand of the NotOperation contains a non-expressible operation - it cannot be converted to an expression");
-    }
-    return expression;
-  }
-
-  @Override
-  public Explanation toExplanation(StreamFactory factory) throws IOException {
-    return new Explanation(operationNodeId.toString())
-        .withExpressionType(ExpressionType.OPERATION)
-        .withFunctionName(factory.getFunctionName(getClass()))
-        .withImplementingClass(getClass().getName())
-        .withExpression(toExpression(factory).toString());
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/OrOperation.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/OrOperation.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/OrOperation.java
deleted file mode 100644
index faac5cd..0000000
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/ops/OrOperation.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.solr.client.solrj.io.ops;
-
-import java.io.IOException;
-import java.util.UUID;
-
-import org.apache.solr.client.solrj.io.stream.expr.Explanation;
-import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
-import org.apache.solr.client.solrj.io.stream.expr.Expressible;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
-import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParameter;
-import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
-
-public class OrOperation extends AndOperation {
-
-  private static final long serialVersionUID = 1;
-  private UUID operationNodeId = UUID.randomUUID();
-
-  public OrOperation(BooleanOperation leftOperand, BooleanOperation rightOperand) {
-    super(leftOperand, rightOperand);
-  }
-
-  public OrOperation(StreamExpression expression, StreamFactory factory) throws IOException {
-    super(expression, factory);
-  }
-
-  public boolean evaluate() {
-    return leftOperand.evaluate() || rightOperand.evaluate();
-  }
-
-  @Override
-  public StreamExpressionParameter toExpression(StreamFactory factory) throws IOException {
-    StreamExpression expression = new StreamExpression(factory.getFunctionName(this.getClass()));
-    if(leftOperand instanceof Expressible) {
-      expression.addParameter(leftOperand.toExpression(factory));
-    } else {
-      throw new IOException("This left operand of the OrOperation contains a non-expressible operation - it cannot be converted to an expression");
-    }
-
-    if(rightOperand instanceof Expressible) {
-      expression.addParameter(rightOperand.toExpression(factory));
-    } else {
-      throw new IOException("This the right operand of the OrOperation contains a non-expressible operation - it cannot be converted to an expression");
-    }
-    return expression;
-  }
-
-  @Override
-  public Explanation toExplanation(StreamFactory factory) throws IOException {
-    return new Explanation(operationNodeId.toString())
-        .withExpressionType(ExpressionType.OPERATION)
-        .withFunctionName(factory.getFunctionName(getClass()))
-        .withImplementingClass(getClass().getName())
-        .withExpression(toExpression(factory).toString());
-  }
-}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/HavingStream.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/HavingStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/HavingStream.java
index 38c1a6b..35e8952 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/HavingStream.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/HavingStream.java
@@ -23,8 +23,8 @@ import java.util.Locale;
 
 import org.apache.solr.client.solrj.io.Tuple;
 import org.apache.solr.client.solrj.io.comp.StreamComparator;
-import org.apache.solr.client.solrj.io.ops.BooleanOperation;
-import org.apache.solr.client.solrj.io.ops.StreamOperation;
+import org.apache.solr.client.solrj.io.eval.BooleanEvaluator;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
 import org.apache.solr.client.solrj.io.stream.expr.Explanation;
 import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
 import org.apache.solr.client.solrj.io.stream.expr.Expressible;
@@ -42,19 +42,19 @@ public class HavingStream extends TupleStream implements Expressible {
   private static final long serialVersionUID = 1;
 
   private TupleStream stream;
-  private BooleanOperation op;
+  private BooleanEvaluator evaluator;
 
   private transient Tuple currentGroupHead;
 
-  public HavingStream(TupleStream stream, BooleanOperation op) throws IOException {
-    init(stream, op);
+  public HavingStream(TupleStream stream, BooleanEvaluator evaluator) throws IOException {
+    init(stream, evaluator);
   }
 
 
   public HavingStream(StreamExpression expression, StreamFactory factory) throws IOException{
     // grab all parameters out
     List<StreamExpression> streamExpressions = factory.getExpressionOperandsRepresentingTypes(expression, Expressible.class, TupleStream.class);
-    List<StreamExpression> operationExpressions = factory.getExpressionOperandsRepresentingTypes(expression, BooleanOperation.class);
+    List<StreamExpression> evaluatorExpressions = factory.getExpressionOperandsRepresentingTypes(expression, BooleanEvaluator.class);
 
     // validate expression contains only what we want.
     if(expression.getParameters().size() != streamExpressions.size() + 1){
@@ -66,25 +66,23 @@ public class HavingStream extends TupleStream implements Expressible {
     }
 
 
-    BooleanOperation booleanOperation = null;
-    if(operationExpressions != null && operationExpressions.size() == 1) {
-      StreamExpression ex = operationExpressions.get(0);
-      StreamOperation operation = factory.constructOperation(ex);
-      if(operation instanceof BooleanOperation) {
-        booleanOperation = (BooleanOperation) operation;
-      } else {
-        throw new IOException("The HavingStream requires a BooleanOperation. A StreamOperation was provided.");
+    StreamEvaluator evaluator = null;
+    if(evaluatorExpressions != null && evaluatorExpressions.size() == 1) {
+      StreamExpression ex = evaluatorExpressions.get(0);
+      evaluator = factory.constructEvaluator(ex);
+      if(!(evaluator instanceof BooleanEvaluator)) {
+        throw new IOException("The HavingStream requires a BooleanEvaluator. A StreamEvaluator was provided.");
       }
     } else {
-      throw new IOException("The HavingStream requires a BooleanOperation.");
+      throw new IOException("The HavingStream requires a BooleanEvaluator.");
     }
 
-    init(factory.constructStream(streamExpressions.get(0)), booleanOperation);
+    init(factory.constructStream(streamExpressions.get(0)), (BooleanEvaluator)evaluator);
   }
 
-  private void init(TupleStream stream, BooleanOperation op) throws IOException{
+  private void init(TupleStream stream, BooleanEvaluator evaluator) throws IOException{
     this.stream = stream;
-    this.op = op;
+    this.evaluator = evaluator;
   }
 
   @Override
@@ -104,10 +102,10 @@ public class HavingStream extends TupleStream implements Expressible {
       expression.addParameter("<stream>");
     }
 
-    if(op instanceof Expressible) {
-      expression.addParameter(op.toExpression(factory));
+    if(evaluator instanceof Expressible) {
+      expression.addParameter(evaluator.toExpression(factory));
     } else {
-      throw new IOException("This ReducerStream contains a non-expressible operation - it cannot be converted to an expression");
+      throw new IOException("This HavingStream contains a non-expressible evaluator - it cannot be converted to an expression");
     }
 
     return expression;
@@ -125,7 +123,7 @@ public class HavingStream extends TupleStream implements Expressible {
         .withExpressionType(ExpressionType.STREAM_DECORATOR)
         .withExpression(toExpression(factory, false).toString())
         .withHelpers(new Explanation[]{
-            op.toExplanation(factory)
+            evaluator.toExplanation(factory)
         });
   }
 
@@ -154,9 +152,7 @@ public class HavingStream extends TupleStream implements Expressible {
         return tuple;
       }
 
-      op.operate(tuple);
-
-      if(op.evaluate()) {
+      if(evaluator.evaluate(tuple)){
         return tuple;
       }
     }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SelectStream.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SelectStream.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SelectStream.java
index b0a1e05..eed8182 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SelectStream.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/SelectStream.java
@@ -25,6 +25,7 @@ import java.util.Map;
 
 import org.apache.solr.client.solrj.io.Tuple;
 import org.apache.solr.client.solrj.io.comp.StreamComparator;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
 import org.apache.solr.client.solrj.io.ops.StreamOperation;
 import org.apache.solr.client.solrj.io.stream.expr.Explanation;
 import org.apache.solr.client.solrj.io.stream.expr.Explanation.ExpressionType;
@@ -32,6 +33,7 @@ import org.apache.solr.client.solrj.io.stream.expr.Expressible;
 import org.apache.solr.client.solrj.io.stream.expr.StreamExplanation;
 import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
 import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParameter;
+import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParser;
 import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionValue;
 import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
 
@@ -47,6 +49,7 @@ public class SelectStream extends TupleStream implements Expressible {
 
   private TupleStream stream;
   private Map<String,String> selectedFields;
+  private Map<StreamEvaluator,String> selectedEvaluators;
   private List<StreamOperation> operations;
 
   public SelectStream(TupleStream stream, List<String> selectedFields) throws IOException {
@@ -56,22 +59,25 @@ public class SelectStream extends TupleStream implements Expressible {
       this.selectedFields.put(selectedField, selectedField);
     }
     operations = new ArrayList<>();
+    selectedEvaluators = new HashMap<>();
   }
   
   public SelectStream(TupleStream stream, Map<String,String> selectedFields) throws IOException {
     this.stream = stream;
     this.selectedFields = selectedFields;
     operations = new ArrayList<>();
+    selectedEvaluators = new HashMap<>();
   }
   
   public SelectStream(StreamExpression expression,StreamFactory factory) throws IOException {
     // grab all parameters out
     List<StreamExpression> streamExpressions = factory.getExpressionOperandsRepresentingTypes(expression, Expressible.class, TupleStream.class);
-    List<StreamExpressionParameter> selectFieldsExpressions = factory.getOperandsOfType(expression, StreamExpressionValue.class);
+    List<StreamExpressionParameter> selectAsFieldsExpressions = factory.getOperandsOfType(expression, StreamExpressionValue.class);
     List<StreamExpression> operationExpressions = factory.getExpressionOperandsRepresentingTypes(expression, StreamOperation.class);
+    List<StreamExpression> evaluatorExpressions = factory.getExpressionOperandsRepresentingTypes(expression, StreamEvaluator.class);
     
     // validate expression contains only what we want.
-    if(expression.getParameters().size() != streamExpressions.size() + selectFieldsExpressions.size() + operationExpressions.size()){
+    if(expression.getParameters().size() != streamExpressions.size() + selectAsFieldsExpressions.size() + operationExpressions.size()){
       throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - unknown operands found", expression));
     }
     
@@ -79,14 +85,19 @@ public class SelectStream extends TupleStream implements Expressible {
       throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting single stream but found %d (must be TupleStream types)",expression, streamExpressions.size()));
     }
 
-    if(0 == selectFieldsExpressions.size()){
+    if(0 == selectAsFieldsExpressions.size()){
       throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting at least one select field but found %d",expression, streamExpressions.size()));
     }
+    
+    if(0 != evaluatorExpressions.size()){
+      throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - evaluators must be given a name, like 'add(...) as result' but found %d evaluators without names",expression, evaluatorExpressions.size()));
+    }
 
     stream = factory.constructStream(streamExpressions.get(0));
     
-    selectedFields = new HashMap<String,String>(selectFieldsExpressions.size());
-    for(StreamExpressionParameter parameter : selectFieldsExpressions){
+    selectedFields = new HashMap<String,String>();
+    selectedEvaluators = new HashMap<StreamEvaluator, String>();
+    for(StreamExpressionParameter parameter : selectAsFieldsExpressions){
       StreamExpressionValue selectField = (StreamExpressionValue)parameter;
       String value = selectField.getValue().trim();
       
@@ -99,7 +110,28 @@ public class SelectStream extends TupleStream implements Expressible {
         if(2 != parts.length){
           throw new IOException(String.format(Locale.ROOT,"Invalid expression %s - expecting select field of form 'fieldA' or 'fieldA as alias' but found %s",expression, value));
         }
-        selectedFields.put(parts[0].trim(), parts[1].trim());
+        
+        String asValue = parts[0].trim();
+        String asName = parts[1].trim();
+        
+        boolean handled = false;
+        if(asValue.contains("(")){
+          // possible evaluator
+          try{
+            StreamExpression asValueExpression = StreamExpressionParser.parse(asValue);
+            if(factory.doesRepresentTypes(asValueExpression, StreamEvaluator.class)){
+              selectedEvaluators.put(factory.constructEvaluator(asValueExpression), asName);
+              handled = true;
+            }
+          }
+          catch(Throwable e){
+            // it was not handled, so treat as a non-evaluator
+          }
+        }
+        
+        if(!handled){        
+          selectedFields.put(asValue, asName);
+        }
       }
       else{
         selectedFields.put(value,value);
@@ -134,7 +166,7 @@ public class SelectStream extends TupleStream implements Expressible {
       expression.addParameter("<stream>");
     }
     
-    // selects
+    // selected fields
     for(Map.Entry<String, String> selectField : selectedFields.entrySet()) {
       if(selectField.getKey().equals(selectField.getValue())){
         expression.addParameter(selectField.getKey());
@@ -144,6 +176,11 @@ public class SelectStream extends TupleStream implements Expressible {
       }
     }
     
+    // selected evaluators
+    for(Map.Entry<StreamEvaluator, String> selectedEvaluator : selectedEvaluators.entrySet()) {
+      expression.addParameter(String.format(Locale.ROOT, "%s as %s", selectedEvaluator.getKey().toExpression(factory), selectedEvaluator.getValue()));
+    }
+    
     for(StreamOperation operation : operations){
       expression.addParameter(operation.toExpression(factory));
     }
@@ -163,6 +200,10 @@ public class SelectStream extends TupleStream implements Expressible {
       .withExpressionType(ExpressionType.STREAM_DECORATOR)
       .withExpression(toExpression(factory, false).toString());   
     
+    for(StreamEvaluator evaluator : selectedEvaluators.keySet()){
+      explanation.addHelper(evaluator.toExplanation(factory));
+    }
+    
     for(StreamOperation operation : operations){
       explanation.addHelper(operation.toExplanation(factory));
     }
@@ -196,19 +237,27 @@ public class SelectStream extends TupleStream implements Expressible {
     }
 
     // create a copy with the limited set of fields
-    Tuple working = new Tuple(new HashMap<>());
+    Tuple workingToReturn = new Tuple(new HashMap<>());
+    Tuple workingForEvaluators = new Tuple(new HashMap<>());
     for(Object fieldName : original.fields.keySet()){
+      workingForEvaluators.put(fieldName, original.get(fieldName));
       if(selectedFields.containsKey(fieldName)){
-        working.put(selectedFields.get(fieldName), original.get(fieldName));
+        workingToReturn.put(selectedFields.get(fieldName), original.get(fieldName));
       }
     }
     
     // apply all operations
     for(StreamOperation operation : operations){
-      operation.operate(working);
+      operation.operate(workingToReturn);
+      operation.operate(workingForEvaluators);
+    }
+    
+    // Apply all evaluators
+    for(Map.Entry<StreamEvaluator, String> selectedEvaluator : selectedEvaluators.entrySet()) {
+      workingToReturn.put(selectedEvaluator.getValue(), selectedEvaluator.getKey().evaluate(workingForEvaluators));
     }
     
-    return working;
+    return workingToReturn;
   }
   
   /** Return the stream sort - ie, the order in which records are returned */

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/expr/Explanation.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/expr/Explanation.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/expr/Explanation.java
index e72d6ed..acaefbf 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/expr/Explanation.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/expr/Explanation.java
@@ -155,6 +155,7 @@ public class Explanation implements MapSerializable {
     public static final String DATASTORE = "datastore";
     public static final String METRIC = "metric";
     public static final String OPERATION = "operation";
+    public static final String EVALUATOR = "evaluator";
     public static final String EQUALITOR = "equalitor";
     public static final String SORTER = "sorter";
   }

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/expr/StreamFactory.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/expr/StreamFactory.java b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/expr/StreamFactory.java
index bf20a1e..f57319d 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/expr/StreamFactory.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/io/stream/expr/StreamFactory.java
@@ -26,12 +26,14 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Map.Entry;
+import java.util.stream.Collectors;
 
 import org.apache.solr.client.solrj.io.comp.ComparatorOrder;
 import org.apache.solr.client.solrj.io.comp.MultipleFieldComparator;
 import org.apache.solr.client.solrj.io.comp.StreamComparator;
 import org.apache.solr.client.solrj.io.eq.MultipleFieldEqualitor;
 import org.apache.solr.client.solrj.io.eq.StreamEqualitor;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
 import org.apache.solr.client.solrj.io.ops.StreamOperation;
 import org.apache.solr.client.solrj.io.stream.TupleStream;
 import org.apache.solr.client.solrj.io.stream.metrics.Metric;
@@ -87,6 +89,10 @@ public class StreamFactory implements Serializable {
     return expression.getParameters().get(parameterIndex);
   }
   
+  public List<String> getValueOperands(StreamExpression expression){
+    return getOperandsOfType(expression, StreamExpressionValue.class).stream().map(item -> ((StreamExpressionValue)item).getValue()).collect(Collectors.toList());
+  }
+  
   /** Given an expression, will return the value parameter at the given index, or null if doesn't exist */
   public String getValueOperand(StreamExpression expression, int parameterIndex){
     StreamExpressionParameter parameter = getOperand(expression, parameterIndex);
@@ -176,6 +182,19 @@ public class StreamFactory implements Serializable {
     return matchingStreamExpressions;   
   }
   
+  public boolean doesRepresentTypes(StreamExpression expression, Class ... clazzes){
+    if(functionNames.containsKey(expression.getFunctionName())){
+      for(Class clazz : clazzes){
+        if(!clazz.isAssignableFrom(functionNames.get(expression.getFunctionName()))){
+          return false;
+        }
+      }
+      return true;
+    }
+    
+    return false;    
+  }
+  
   public int getIntOperand(StreamExpression expression, String paramName, Integer defaultValue) throws IOException{
     StreamExpressionNamedParameter param = getNamedOperand(expression, paramName);
     
@@ -343,6 +362,21 @@ public class StreamFactory implements Serializable {
     throw new IOException(String.format(Locale.ROOT,"Invalid operation expression %s - function '%s' is unknown (not mapped to a valid StreamOperation)", expression, expression.getFunctionName()));
   }
 
+  public StreamEvaluator constructEvaluator(String expressionClause) throws IOException {
+    return constructEvaluator(StreamExpressionParser.parse(expressionClause));
+  }
+  public StreamEvaluator constructEvaluator(StreamExpression expression) throws IOException{
+    String function = expression.getFunctionName();
+    if(functionNames.containsKey(function)){
+      Class<? extends Expressible> clazz = functionNames.get(function);
+      if(Expressible.class.isAssignableFrom(clazz) && StreamEvaluator.class.isAssignableFrom(clazz)){
+        return (StreamEvaluator)createInstance(functionNames.get(function), new Class[]{ StreamExpression.class, StreamFactory.class }, new Object[]{ expression, this});
+      }
+    }
+    
+    throw new IOException(String.format(Locale.ROOT,"Invalid evaluator expression %s - function '%s' is unknown (not mapped to a valid StreamEvaluator)", expression, expression.getFunctionName()));
+  }
+
 
   public <T> T createInstance(Class<T> clazz, Class<?>[] paramTypes, Object[] params) throws IOException{
     Constructor<T> ctor;

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/SelectWithEvaluatorsTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/SelectWithEvaluatorsTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/SelectWithEvaluatorsTest.java
new file mode 100644
index 0000000..b91df8d
--- /dev/null
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/SelectWithEvaluatorsTest.java
@@ -0,0 +1,259 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.stream;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.LuceneTestCase.Slow;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.AddEvaluator;
+import org.apache.solr.client.solrj.io.eval.GreaterThanEvaluator;
+import org.apache.solr.client.solrj.io.eval.IfThenElseEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.cloud.AbstractDistribZkTestBase;
+import org.apache.solr.cloud.SolrCloudTestCase;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *  All base tests will be done with CloudSolrStream. Under the covers CloudSolrStream uses SolrStream so
+ *  SolrStream will get fully exercised through these tests.
+ *
+ **/
+
+@Slow
+@LuceneTestCase.SuppressCodecs({"Lucene3x", "Lucene40","Lucene41","Lucene42","Lucene45"})
+public class SelectWithEvaluatorsTest extends SolrCloudTestCase {
+
+  private static final String COLLECTIONORALIAS = "collection1";
+  private static final int TIMEOUT = DEFAULT_TIMEOUT;
+  private static final String id = "id";
+
+  private static boolean useAlias;
+
+  @BeforeClass
+  public static void setupCluster() throws Exception {
+    configureCluster(4)
+        .addConfig("conf", getFile("solrj").toPath().resolve("solr").resolve("configsets").resolve("streaming").resolve("conf"))
+        .addConfig("ml", getFile("solrj").toPath().resolve("solr").resolve("configsets").resolve("ml").resolve("conf"))
+        .configure();
+
+    String collection;
+    useAlias = random().nextBoolean();
+    if (useAlias) {
+      collection = COLLECTIONORALIAS + "_collection";
+    } else {
+      collection = COLLECTIONORALIAS;
+    }
+    CollectionAdminRequest.createCollection(collection, "conf", 2, 1).process(cluster.getSolrClient());
+    AbstractDistribZkTestBase.waitForRecoveriesToFinish(collection, cluster.getSolrClient().getZkStateReader(),
+        false, true, TIMEOUT);
+    if (useAlias) {
+      CollectionAdminRequest.createAlias(COLLECTIONORALIAS, collection).process(cluster.getSolrClient());
+    }
+  }
+
+  @Before
+  public void cleanIndex() throws Exception {
+    new UpdateRequest()
+        .deleteByQuery("*:*")
+        .commit(cluster.getSolrClient(), COLLECTIONORALIAS);
+  }
+
+  @Test
+  public void testSelectWithEvaluatorsStream() throws Exception {
+
+    new UpdateRequest()
+        .add(id, "1", "a_s", "foo", "b_i", "1", "c_d", "3.3", "d_b", "true")
+        .commit(cluster.getSolrClient(), COLLECTIONORALIAS);
+
+    String clause;
+    TupleStream stream;
+    List<Tuple> tuples;
+    
+    StreamFactory factory = new StreamFactory()
+      .withCollectionZkHost("collection1", cluster.getZkServer().getZkAddress())
+      .withFunctionName("search", CloudSolrStream.class)
+      .withFunctionName("select", SelectStream.class)
+      .withFunctionName("add", AddEvaluator.class)
+      .withFunctionName("if", IfThenElseEvaluator.class)
+      .withFunctionName("gt", GreaterThanEvaluator.class)
+      ;
+    
+    // Basic test
+    clause = "select("
+            +   "id,"
+            +   "add(b_i,c_d) as result,"
+            +   "search(collection1, q=*:*, fl=\"id,a_s,b_i,c_d,d_b\", sort=\"id asc\")"
+            + ")";
+    stream = factory.constructStream(clause);
+    tuples = getTuples(stream);
+    assertFields(tuples, "id", "result");
+    assertNotFields(tuples, "a_s", "b_i", "c_d", "d_b");
+    assertEquals(1, tuples.size());
+    assertDouble(tuples.get(0), "result", 4.3);
+    assertEquals(4.3, tuples.get(0).get("result"));
+
+  }
+  
+  protected List<Tuple> getTuples(TupleStream tupleStream) throws IOException {
+    tupleStream.open();
+    List<Tuple> tuples = new ArrayList<Tuple>();
+    for(Tuple t = tupleStream.read(); !t.EOF; t = tupleStream.read()) {
+      tuples.add(t);
+    }
+    tupleStream.close();
+    return tuples;
+  }
+  protected boolean assertOrder(List<Tuple> tuples, int... ids) throws Exception {
+    return assertOrderOf(tuples, "id", ids);
+  }
+  protected boolean assertOrderOf(List<Tuple> tuples, String fieldName, int... ids) throws Exception {
+    int i = 0;
+    for(int val : ids) {
+      Tuple t = tuples.get(i);
+      String tip = t.getString(fieldName);
+      if(!tip.equals(Integer.toString(val))) {
+        throw new Exception("Found value:"+tip+" expecting:"+val);
+      }
+      ++i;
+    }
+    return true;
+  }
+
+  protected boolean assertMapOrder(List<Tuple> tuples, int... ids) throws Exception {
+    int i = 0;
+    for(int val : ids) {
+      Tuple t = tuples.get(i);
+      List<Map> tip = t.getMaps("group");
+      int id = (int)tip.get(0).get("id");
+      if(id != val) {
+        throw new Exception("Found value:"+id+" expecting:"+val);
+      }
+      ++i;
+    }
+    return true;
+  }
+
+  protected boolean assertFields(List<Tuple> tuples, String ... fields) throws Exception{
+    for(Tuple tuple : tuples){
+      for(String field : fields){
+        if(!tuple.fields.containsKey(field)){
+          throw new Exception(String.format(Locale.ROOT, "Expected field '%s' not found", field));
+        }
+      }
+    }
+    return true;
+  }
+  protected boolean assertNotFields(List<Tuple> tuples, String ... fields) throws Exception{
+    for(Tuple tuple : tuples){
+      for(String field : fields){
+        if(tuple.fields.containsKey(field)){
+          throw new Exception(String.format(Locale.ROOT, "Unexpected field '%s' found", field));
+        }
+      }
+    }
+    return true;
+  }  
+
+  protected boolean assertGroupOrder(Tuple tuple, int... ids) throws Exception {
+    List<?> group = (List<?>)tuple.get("tuples");
+    int i=0;
+    for(int val : ids) {
+      Map<?,?> t = (Map<?,?>)group.get(i);
+      Long tip = (Long)t.get("id");
+      if(tip.intValue() != val) {
+        throw new Exception("Found value:"+tip.intValue()+" expecting:"+val);
+      }
+      ++i;
+    }
+    return true;
+  }
+
+  public boolean assertLong(Tuple tuple, String fieldName, long l) throws Exception {
+    long lv = (long)tuple.get(fieldName);
+    if(lv != l) {
+      throw new Exception("Longs not equal:"+l+" : "+lv);
+    }
+
+    return true;
+  }
+  
+  public boolean assertDouble(Tuple tuple, String fieldName, double expectedValue) throws Exception {
+    double value = (double)tuple.get(fieldName);
+    if(expectedValue != value) {
+      throw new Exception("Doubles not equal:"+value+" : "+expectedValue);
+    }
+
+    return true;
+  }
+  
+  public boolean assertString(Tuple tuple, String fieldName, String expected) throws Exception {
+    String actual = (String)tuple.get(fieldName);
+    
+    if( (null == expected && null != actual) ||
+        (null != expected && null == actual) ||
+        (null != expected && !expected.equals(actual))){
+      throw new Exception("Longs not equal:"+expected+" : "+actual);
+    }
+
+    return true;
+  }
+  
+  protected boolean assertMaps(List<Map> maps, int... ids) throws Exception {
+    if(maps.size() != ids.length) {
+      throw new Exception("Expected id count != actual map count:"+ids.length+":"+maps.size());
+    }
+
+    int i=0;
+    for(int val : ids) {
+      Map t = maps.get(i);
+      String tip = (String)t.get("id");
+      if(!tip.equals(Integer.toString(val))) {
+        throw new Exception("Found value:"+tip+" expecting:"+val);
+      }
+      ++i;
+    }
+    return true;
+  }
+
+  private boolean assertList(List list, Object... vals) throws Exception {
+
+    if(list.size() != vals.length) {
+      throw new Exception("Lists are not the same size:"+list.size() +" : "+vals.length);
+    }
+
+    for(int i=0; i<list.size(); i++) {
+      Object a = list.get(i);
+      Object b = vals[i];
+      if(!a.equals(b)) {
+        throw new Exception("List items not equals:"+a+" : "+b);
+      }
+    }
+
+    return true;
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/StreamExpressionTest.java
----------------------------------------------------------------------
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 5b806a8..ebc3250 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
@@ -33,16 +33,19 @@ import org.apache.solr.client.solrj.io.SolrClientCache;
 import org.apache.solr.client.solrj.io.Tuple;
 import org.apache.solr.client.solrj.io.comp.ComparatorOrder;
 import org.apache.solr.client.solrj.io.comp.FieldComparator;
-import org.apache.solr.client.solrj.io.ops.AndOperation;
+import org.apache.solr.client.solrj.io.eval.AddEvaluator;
+import org.apache.solr.client.solrj.io.eval.AndEvaluator;
+import org.apache.solr.client.solrj.io.eval.EqualsEvaluator;
+import org.apache.solr.client.solrj.io.eval.GreaterThanEqualToEvaluator;
+import org.apache.solr.client.solrj.io.eval.GreaterThanEvaluator;
+import org.apache.solr.client.solrj.io.eval.IfThenElseEvaluator;
+import org.apache.solr.client.solrj.io.eval.LessThanEqualToEvaluator;
+import org.apache.solr.client.solrj.io.eval.LessThanEvaluator;
+import org.apache.solr.client.solrj.io.eval.NotEvaluator;
+import org.apache.solr.client.solrj.io.eval.OrEvaluator;
+import org.apache.solr.client.solrj.io.eval.RawValueEvaluator;
 import org.apache.solr.client.solrj.io.ops.ConcatOperation;
-import org.apache.solr.client.solrj.io.ops.EqualsOperation;
-import org.apache.solr.client.solrj.io.ops.GreaterThanEqualToOperation;
-import org.apache.solr.client.solrj.io.ops.GreaterThanOperation;
 import org.apache.solr.client.solrj.io.ops.GroupOperation;
-import org.apache.solr.client.solrj.io.ops.LessThanEqualToOperation;
-import org.apache.solr.client.solrj.io.ops.LessThanOperation;
-import org.apache.solr.client.solrj.io.ops.NotOperation;
-import org.apache.solr.client.solrj.io.ops.OrOperation;
 import org.apache.solr.client.solrj.io.ops.ReplaceOperation;
 import org.apache.solr.client.solrj.io.stream.expr.StreamExpression;
 import org.apache.solr.client.solrj.io.stream.expr.StreamExpressionParser;
@@ -848,14 +851,14 @@ public class StreamExpressionTest extends SolrCloudTestCase {
         .withFunctionName("having", HavingStream.class)
         .withFunctionName("rollup", RollupStream.class)
         .withFunctionName("sum", SumMetric.class)
-        .withFunctionName("and", AndOperation.class)
-        .withFunctionName("or", OrOperation.class)
-        .withFunctionName("not", NotOperation.class)
-        .withFunctionName("gt", GreaterThanOperation.class)
-        .withFunctionName("lt", LessThanOperation.class)
-        .withFunctionName("eq", EqualsOperation.class)
-        .withFunctionName("lteq", LessThanEqualToOperation.class)
-        .withFunctionName("gteq", GreaterThanEqualToOperation.class);
+        .withFunctionName("and", AndEvaluator.class)
+        .withFunctionName("or", OrEvaluator.class)
+        .withFunctionName("not", NotEvaluator.class)
+        .withFunctionName("gt", GreaterThanEvaluator.class)
+        .withFunctionName("lt", LessThanEvaluator.class)
+        .withFunctionName("eq", EqualsEvaluator.class)
+        .withFunctionName("lteq", LessThanEqualToEvaluator.class)
+        .withFunctionName("gteq", GreaterThanEqualToEvaluator.class);
 
     stream = factory.constructStream("having(search(" + COLLECTIONORALIAS + ", q=*:*, fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc\"), eq(a_i, 9))");
     StreamContext context = new StreamContext();
@@ -956,14 +959,15 @@ public class StreamExpressionTest extends SolrCloudTestCase {
         .withFunctionName("having", HavingStream.class)
         .withFunctionName("rollup", RollupStream.class)
         .withFunctionName("sum", SumMetric.class)
-        .withFunctionName("and", AndOperation.class)
-        .withFunctionName("or", OrOperation.class)
-        .withFunctionName("not", NotOperation.class)
-        .withFunctionName("gt", GreaterThanOperation.class)
-        .withFunctionName("lt", LessThanOperation.class)
-        .withFunctionName("eq", EqualsOperation.class)
-        .withFunctionName("lteq", LessThanEqualToOperation.class)
-        .withFunctionName("gteq", GreaterThanEqualToOperation.class)
+        .withFunctionName("and", AndEvaluator.class)
+        .withFunctionName("or", OrEvaluator.class)
+        .withFunctionName("not", NotEvaluator.class)
+        .withFunctionName("gt", GreaterThanEvaluator.class)
+        .withFunctionName("lt", LessThanEvaluator.class)
+        .withFunctionName("eq", EqualsEvaluator.class)
+        .withFunctionName("lteq", LessThanEqualToEvaluator.class)
+        .withFunctionName("gteq", GreaterThanEqualToEvaluator.class)
+        .withFunctionName("val", RawValueEvaluator.class)
         .withFunctionName("parallel", ParallelStream.class);
 
     stream = factory.constructStream("parallel(" + COLLECTIONORALIAS + ", workers=2, sort=\"a_f asc\", having(search(" + COLLECTIONORALIAS + ", q=*:*, fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc\", partitionKeys=id), eq(a_i, 9)))");
@@ -2192,6 +2196,9 @@ public class StreamExpressionTest extends SolrCloudTestCase {
       .withFunctionName("select", SelectStream.class)
       .withFunctionName("replace", ReplaceOperation.class)
       .withFunctionName("concat", ConcatOperation.class)
+      .withFunctionName("add", AddEvaluator.class)
+      .withFunctionName("if", IfThenElseEvaluator.class)
+      .withFunctionName("gt", GreaterThanEvaluator.class)
       ;
     
     // Basic test

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AbsoluteValueEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AbsoluteValueEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AbsoluteValueEvaluatorTest.java
new file mode 100644
index 0000000..88d3447
--- /dev/null
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AbsoluteValueEvaluatorTest.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import java.io.IOException;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.AbsoluteValueEvaluator;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+public class AbsoluteValueEvaluatorTest extends LuceneTestCase {
+
+  StreamFactory factory;
+  Map<String, Object> values;
+  
+  public AbsoluteValueEvaluatorTest() {
+    super();
+    
+    factory = new StreamFactory()
+      .withFunctionName("abs", AbsoluteValueEvaluator.class);
+    values = new HashedMap();
+  }
+    
+  @Test
+  public void absoluteValueOneField() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("abs(a)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(1L, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(1.1D, result);
+    
+    values.clear();
+    values.put("a", -1.1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(1.1D, result);
+  }
+
+  @Test(expected = IOException.class)
+  public void absNoField() throws Exception{
+    factory.constructEvaluator("abs()");
+  }
+  
+  @Test(expected = IOException.class)
+  public void absTwoFields() throws Exception{
+    factory.constructEvaluator("abs(a,b)");
+  }
+  
+  @Test
+  public void absNoValue() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("abs(a)");
+    
+    values.clear();
+    Object result = evaluator.evaluate(new Tuple(values));
+    assertNull(result);
+  }
+  @Test
+  public void absNullValue() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("abs(a)");
+    
+    values.clear();
+    values.put("a", null);
+    Object result = evaluator.evaluate(new Tuple(values));
+    assertNull(result);
+  }
+}

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7372df99/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AddEvaluatorTest.java
----------------------------------------------------------------------
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AddEvaluatorTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AddEvaluatorTest.java
new file mode 100644
index 0000000..7115452
--- /dev/null
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/io/stream/eval/AddEvaluatorTest.java
@@ -0,0 +1,336 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.solr.client.solrj.io.stream.eval;
+
+import java.io.IOException;
+import java.util.Map;
+
+import junit.framework.Assert;
+
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.solr.client.solrj.io.Tuple;
+import org.apache.solr.client.solrj.io.eval.AddEvaluator;
+import org.apache.solr.client.solrj.io.eval.StreamEvaluator;
+import org.apache.solr.client.solrj.io.stream.expr.StreamFactory;
+import org.junit.Test;
+
+public class AddEvaluatorTest extends LuceneTestCase {
+
+  StreamFactory factory;
+  Map<String, Object> values;
+  
+  public AddEvaluatorTest() {
+    super();
+    
+    factory = new StreamFactory()
+      .withFunctionName("add", AddEvaluator.class);
+    values = new HashedMap();
+  }
+    
+  @Test
+  public void addTwoFieldsWithValues() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("add(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(3L, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(3.1D, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2.1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(3.2D, result);
+  }
+
+  @Test(expected = IOException.class)
+  public void addOneField() throws Exception{
+    factory.constructEvaluator("add(a)");
+  }
+  
+  @Test
+  public void addTwoFieldWithNulls() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("add(a,b)");
+    Object result;
+    
+    values.clear();
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+  }
+  
+  @Test
+  public void addTwoFieldsWithNull() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("add(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", null);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", null);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+    
+    values.clear();
+    values.put("a", null);
+    values.put("b", 1.1);    
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+  }
+
+  @Test
+  public void addTwoFieldsWithMissingField() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("add(a,b)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+    
+    values.clear();
+    values.put("b", 1.1);    
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertNull(result);
+  }
+
+  @Test
+  public void addManyFieldsWithValues() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("add(a,b,c,d)");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2);
+    values.put("c", 3);
+    values.put("d", 4);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(10L, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2);
+    values.put("c", 3);
+    values.put("d", 4);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(10.1D, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2.1);
+    values.put("c", 3.1);
+    values.put("d", 4.1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(10.4D, result);
+  }
+  
+  @Test
+  public void addManyFieldsWithSubAdds() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("add(a,b,add(c,d))");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2);
+    values.put("c", 3);
+    values.put("d", 4);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(10L, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2);
+    values.put("c", 3);
+    values.put("d", 4);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(10.1D, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2.1);
+    values.put("c", 3.1);
+    values.put("d", 4.1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(10.4D, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2.1);
+    values.put("c", 3.1);
+    values.put("d", 4.123456789123456);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(10.423456789123456, result);
+    
+    values.clear();
+    values.put("a", 123456789123456789L);
+    values.put("b", 123456789123456789L);
+    values.put("c", 123456789123456789L);
+    values.put("d", 123456789123456789L);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(4 * 123456789123456789L, result);
+  }
+  
+  @Test
+  public void addManyFieldsWithManySubAdds() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("add(add(a,b),add(c,d),add(c,a))");
+    Object result;
+    
+    values.clear();
+    values.put("a", 1);
+    values.put("b", 2);
+    values.put("c", 3);
+    values.put("d", 4);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(14L, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2);
+    values.put("c", 3);
+    values.put("d", 4);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(14.2D, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2.1);
+    values.put("c", 3.1);
+    values.put("d", 4.1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(14.6D, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2.1);
+    values.put("c", 3.1);
+    values.put("d", 4.123456789123456);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(14.623456789123456, result);
+    
+    values.clear();
+    values.put("a", 123456789123456789L);
+    values.put("b", 123456789123456789L);
+    values.put("c", 123456789123456789L);
+    values.put("d", 123456789123456789L);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(6 * 123456789123456789L, result);
+    
+    values.clear();
+    values.put("a", 4.123456789123456);
+    values.put("b", 4.123456789123456);
+    values.put("c", 4.123456789123456);
+    values.put("d", 4.123456789123456);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(6 * 4.123456789123456, result);
+  }
+  
+  @Test
+  public void addManyFieldsWithManySubAddsWithNegative() throws Exception{
+    StreamEvaluator evaluator = factory.constructEvaluator("add(add(a,b),add(c,d),add(c,a))");
+    Object result;
+    
+    values.clear();
+    values.put("a", -1);
+    values.put("b", 2);
+    values.put("c", 3);
+    values.put("d", 4);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(10L, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2);
+    values.put("c", -3);
+    values.put("d", 4);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(2.2D, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2.1);
+    values.put("c", -3.1);
+    values.put("d", 4.1);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(2.2D, result);
+    
+    values.clear();
+    values.put("a", 1.1);
+    values.put("b", 2.1);
+    values.put("c", -3.1);
+    values.put("d", 5.223456789123456);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(3.323456789123456, result);
+    
+    values.clear();
+    values.put("a", 123456789123456789L);
+    values.put("b", -123456789123456789L);
+    values.put("c", 123456789123456789L);
+    values.put("d", 123456789123456789L);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Long);
+    Assert.assertEquals(4 * 123456789123456789L, result);
+    
+    values.clear();
+    values.put("a", -4.123456789123456);
+    values.put("b", -4.123456789123456);
+    values.put("c", -4.123456789123456);
+    values.put("d", -4.123456789123456);
+    result = evaluator.evaluate(new Tuple(values));
+    Assert.assertTrue(result instanceof Double);
+    Assert.assertEquals(6 * -4.123456789123456, result);
+  }
+
+}