Search in sources :

Example 6 with Explanation

use of org.apache.solr.client.solrj.io.stream.expr.Explanation in project lucene-solr by apache.

the class StreamExpressionToExplanationTest method testSelectStream.

@Test
public void testSelectStream() throws Exception {
    SelectStream stream;
    // Basic test
    stream = new SelectStream(StreamExpressionParser.parse("select(\"a_s as fieldA\", search(collection1, q=*:*, fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc, a_i asc\"))"), factory);
    Explanation explanation = stream.toExplanation(factory);
    Assert.assertEquals("select", explanation.getFunctionName());
    Assert.assertEquals(SelectStream.class.getName(), explanation.getImplementingClass());
}
Also used : StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) Explanation(org.apache.solr.client.solrj.io.stream.expr.Explanation) Test(org.junit.Test)

Example 7 with Explanation

use of org.apache.solr.client.solrj.io.stream.expr.Explanation in project lucene-solr by apache.

the class StreamExpressionToExplanationTest method testFacetStream.

@Test
public void testFacetStream() throws Exception {
    FacetStream stream;
    String expressionString;
    // Basic test
    stream = new FacetStream(StreamExpressionParser.parse("facet(" + "collection1, " + "q=\"*:*\", " + "buckets=\"a_s\", " + "bucketSorts=\"sum(a_i) asc\", " + "bucketSizeLimit=100, " + "sum(a_i), sum(a_f), " + "min(a_i), min(a_f), " + "max(a_i), max(a_f), " + "avg(a_i), avg(a_f), " + "count(*)" + ")"), factory);
    expressionString = stream.toExpression(factory).toString();
    Explanation explanation = stream.toExplanation(factory);
    Assert.assertEquals("facet", explanation.getFunctionName());
    Assert.assertEquals(FacetStream.class.getName(), explanation.getImplementingClass());
    Assert.assertEquals(1, ((StreamExplanation) explanation).getChildren().size());
}
Also used : StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) Explanation(org.apache.solr.client.solrj.io.stream.expr.Explanation) Test(org.junit.Test)

Example 8 with Explanation

use of org.apache.solr.client.solrj.io.stream.expr.Explanation in project lucene-solr by apache.

the class StreamExpressionToExplanationTest method testUpdateStream.

@Test
public void testUpdateStream() throws Exception {
    StreamExpression expression = StreamExpressionParser.parse("update(" + "collection2, " + "batchSize=5, " + "search(" + "collection1, " + "q=*:*, " + "fl=\"id,a_s,a_i,a_f\", " + "sort=\"a_f asc, a_i asc\"))");
    UpdateStream updateStream = new UpdateStream(expression, factory);
    Explanation explanation = updateStream.toExplanation(factory);
    Assert.assertEquals("solr (collection2)", explanation.getFunctionName());
    Assert.assertEquals("Solr/Lucene", explanation.getImplementingClass());
    StreamExplanation updateExplanation = (StreamExplanation) explanation;
    Assert.assertEquals(1, updateExplanation.getChildren().size());
    Assert.assertEquals("update", updateExplanation.getChildren().get(0).getFunctionName());
    Assert.assertEquals(UpdateStream.class.getName(), updateExplanation.getChildren().get(0).getImplementingClass());
}
Also used : StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) StreamExpression(org.apache.solr.client.solrj.io.stream.expr.StreamExpression) StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) Explanation(org.apache.solr.client.solrj.io.stream.expr.Explanation) Test(org.junit.Test)

Example 9 with Explanation

use of org.apache.solr.client.solrj.io.stream.expr.Explanation in project lucene-solr by apache.

the class StreamExpressionToExplanationTest method testIntersectStream.

@Test
public void testIntersectStream() throws Exception {
    IntersectStream stream;
    String expressionString;
    // Basic test
    stream = new IntersectStream(StreamExpressionParser.parse("intersect(" + "search(collection1, q=\"id:(0 3 4)\", fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc, a_s asc\")," + "search(collection1, q=\"id:(1 2)\", fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc, a_s asc\")," + "on=\"a_f, a_s\")"), factory);
    Explanation explanation = stream.toExplanation(factory);
    Assert.assertEquals("intersect", explanation.getFunctionName());
    Assert.assertEquals(IntersectStream.class.getName(), explanation.getImplementingClass());
    Assert.assertEquals(2, ((StreamExplanation) explanation).getChildren().size());
}
Also used : StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) Explanation(org.apache.solr.client.solrj.io.stream.expr.Explanation) Test(org.junit.Test)

Example 10 with Explanation

use of org.apache.solr.client.solrj.io.stream.expr.Explanation in project lucene-solr by apache.

the class StreamExpressionToExplanationTest method testUniqueStream.

@Test
public void testUniqueStream() throws Exception {
    UniqueStream stream;
    // Basic test
    stream = new UniqueStream(StreamExpressionParser.parse("unique(search(collection1, q=*:*, fl=\"id,a_s,a_i,a_f\", sort=\"a_f asc, a_i asc\"), over=\"a_f\")"), factory);
    Explanation explanation = stream.toExplanation(factory);
    Assert.assertEquals("unique", explanation.getFunctionName());
    Assert.assertEquals(UniqueStream.class.getName(), explanation.getImplementingClass());
}
Also used : StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation) Explanation(org.apache.solr.client.solrj.io.stream.expr.Explanation) Test(org.junit.Test)

Aggregations

Explanation (org.apache.solr.client.solrj.io.stream.expr.Explanation)17 StreamExplanation (org.apache.solr.client.solrj.io.stream.expr.StreamExplanation)16 Test (org.junit.Test)15 StreamExpression (org.apache.solr.client.solrj.io.stream.expr.StreamExpression)3 IOException (java.io.IOException)1 MethodHandles (java.lang.invoke.MethodHandles)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 Entry (java.util.Map.Entry)1 Random (java.util.Random)1 Set (java.util.Set)1 TreeSet (java.util.TreeSet)1 ExecutorService (java.util.concurrent.ExecutorService)1 Future (java.util.concurrent.Future)1 Collectors (java.util.stream.Collectors)1