Search in sources :

Example 31 with Tuple

use of org.apache.solr.client.solrj.io.Tuple in project lucene-solr by apache.

the class DivideEvaluatorTest method divManyFieldsWithSubdivs.

@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);
}
Also used : StreamEvaluator(org.apache.solr.client.solrj.io.eval.StreamEvaluator) Tuple(org.apache.solr.client.solrj.io.Tuple) Test(org.junit.Test)

Example 32 with Tuple

use of org.apache.solr.client.solrj.io.Tuple in project lucene-solr by apache.

the class DivideEvaluatorTest method divTwoFieldWithNulls.

@Test(expected = IOException.class)
public void divTwoFieldWithNulls() throws Exception {
    StreamEvaluator evaluator = factory.constructEvaluator("div(a,b)");
    values.clear();
    evaluator.evaluate(new Tuple(values));
}
Also used : StreamEvaluator(org.apache.solr.client.solrj.io.eval.StreamEvaluator) Tuple(org.apache.solr.client.solrj.io.Tuple) Test(org.junit.Test)

Example 33 with Tuple

use of org.apache.solr.client.solrj.io.Tuple in project lucene-solr by apache.

the class DivideEvaluatorTest method divByZero.

@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));
}
Also used : StreamEvaluator(org.apache.solr.client.solrj.io.eval.StreamEvaluator) Tuple(org.apache.solr.client.solrj.io.Tuple) Test(org.junit.Test)

Example 34 with Tuple

use of org.apache.solr.client.solrj.io.Tuple in project lucene-solr by apache.

the class LessThanEqualToEvaluatorTest method lteDifferentTypes1.

@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));
}
Also used : StreamEvaluator(org.apache.solr.client.solrj.io.eval.StreamEvaluator) Tuple(org.apache.solr.client.solrj.io.Tuple) Test(org.junit.Test)

Example 35 with Tuple

use of org.apache.solr.client.solrj.io.Tuple in project lucene-solr by apache.

the class LessThanEqualToEvaluatorTest method lteTwoStrings.

@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);
}
Also used : StreamEvaluator(org.apache.solr.client.solrj.io.eval.StreamEvaluator) Tuple(org.apache.solr.client.solrj.io.Tuple) Test(org.junit.Test)

Aggregations

Tuple (org.apache.solr.client.solrj.io.Tuple)382 Test (org.junit.Test)259 StreamEvaluator (org.apache.solr.client.solrj.io.eval.StreamEvaluator)135 UpdateRequest (org.apache.solr.client.solrj.request.UpdateRequest)114 SolrClientCache (org.apache.solr.client.solrj.io.SolrClientCache)92 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)88 StreamFactory (org.apache.solr.client.solrj.io.stream.expr.StreamFactory)64 HashMap (java.util.HashMap)54 ArrayList (java.util.ArrayList)47 SolrParams (org.apache.solr.common.params.SolrParams)43 Map (java.util.Map)41 StreamExpression (org.apache.solr.client.solrj.io.stream.expr.StreamExpression)36 IOException (java.io.IOException)34 List (java.util.List)28 FieldComparator (org.apache.solr.client.solrj.io.comp.FieldComparator)23 StreamOperation (org.apache.solr.client.solrj.io.ops.StreamOperation)16 MultipleFieldComparator (org.apache.solr.client.solrj.io.comp.MultipleFieldComparator)15 SolrStream (org.apache.solr.client.solrj.io.stream.SolrStream)15 MeanMetric (org.apache.solr.client.solrj.io.stream.metrics.MeanMetric)15 MinMetric (org.apache.solr.client.solrj.io.stream.metrics.MinMetric)14