Search in sources :

Example 21 with StreamExplanation

use of org.apache.solr.client.solrj.io.stream.expr.StreamExplanation 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 22 with StreamExplanation

use of org.apache.solr.client.solrj.io.stream.expr.StreamExplanation 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 23 with StreamExplanation

use of org.apache.solr.client.solrj.io.stream.expr.StreamExplanation 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 24 with StreamExplanation

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

the class JoinStream method toExplanation.

@Override
public Explanation toExplanation(StreamFactory factory) throws IOException {
    StreamExplanation explanation = new StreamExplanation(getStreamNodeId().toString());
    explanation.setFunctionName(factory.getFunctionName(this.getClass()));
    explanation.setImplementingClass(this.getClass().getName());
    explanation.setExpressionType(ExpressionType.STREAM_DECORATOR);
    explanation.setExpression(toExpression(factory, false).toString());
    explanation.addHelper(eq.toExplanation(factory));
    for (TupleStream stream : streams) {
        explanation.addChild(stream.toExplanation(factory));
    }
    return explanation;
}
Also used : StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation)

Example 25 with StreamExplanation

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

the class ModelStream method toExplanation.

@Override
public Explanation toExplanation(StreamFactory factory) throws IOException {
    StreamExplanation explanation = new StreamExplanation(getStreamNodeId().toString());
    explanation.setFunctionName(factory.getFunctionName(this.getClass()));
    explanation.setImplementingClass(this.getClass().getName());
    explanation.setExpressionType(Explanation.ExpressionType.MACHINE_LEARNING_MODEL);
    explanation.setExpression(toExpression(factory).toString());
    return explanation;
}
Also used : StreamExplanation(org.apache.solr.client.solrj.io.stream.expr.StreamExplanation)

Aggregations

StreamExplanation (org.apache.solr.client.solrj.io.stream.expr.StreamExplanation)34 Explanation (org.apache.solr.client.solrj.io.stream.expr.Explanation)10 Test (org.junit.Test)8 ModifiableSolrParams (org.apache.solr.common.params.ModifiableSolrParams)7 StreamExpression (org.apache.solr.client.solrj.io.stream.expr.StreamExpression)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 Tuple (org.apache.solr.client.solrj.io.Tuple)2 StreamFactory (org.apache.solr.client.solrj.io.stream.expr.StreamFactory)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 MethodHandles (java.lang.invoke.MethodHandles)1 SQLException (java.sql.SQLException)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 Entry (java.util.Map.Entry)1 Random (java.util.Random)1