Search in sources :

Example 1 with CountAggregator

use of com.yahoo.search.grouping.request.CountAggregator in project vespa by vespa-engine.

the class VespaSerializerTestCase method requireThatGroupingContinuationsAreSerialized.

@Test
public void requireThatGroupingContinuationsAreSerialized() {
    Query query = new Query();
    query.getModel().getQueryTree().setRoot(new WordItem("foo"));
    assertEquals("default contains ([{\"implicitTransforms\": false}]\"foo\")", VespaSerializer.serialize(query));
    newGroupingRequest(query, new AllOperation().setGroupBy(new AttributeFunction("a")).addChild(new EachOperation().addOutput(new CountAggregator())), Continuation.fromString("BCBCBCBEBG"), Continuation.fromString("BCBKCBACBKCCK"));
    assertEquals("default contains ([{\"implicitTransforms\": false}]\"foo\") " + "| [{ 'continuations':['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]" + "all(group(attribute(a)) each(output(count())))", VespaSerializer.serialize(query));
    newGroupingRequest(query, new AllOperation().setGroupBy(new AttributeFunction("b")).addChild(new EachOperation().addOutput(new CountAggregator())), Continuation.fromString("BCBBBBBDBF"), Continuation.fromString("BCBJBPCBJCCJ"));
    assertEquals("default contains ([{\"implicitTransforms\": false}]\"foo\") " + "| [{ 'continuations':['BCBCBCBEBG', 'BCBKCBACBKCCK'] }]" + "all(group(attribute(a)) each(output(count()))) " + "| [{ 'continuations':['BCBBBBBDBF', 'BCBJBPCBJCCJ'] }]" + "all(group(attribute(b)) each(output(count())))", VespaSerializer.serialize(query));
}
Also used : EachOperation(com.yahoo.search.grouping.request.EachOperation) Query(com.yahoo.search.Query) CountAggregator(com.yahoo.search.grouping.request.CountAggregator) AllOperation(com.yahoo.search.grouping.request.AllOperation) MarkerWordItem(com.yahoo.prelude.query.MarkerWordItem) WordItem(com.yahoo.prelude.query.WordItem) AttributeFunction(com.yahoo.search.grouping.request.AttributeFunction) Test(org.junit.Test)

Example 2 with CountAggregator

use of com.yahoo.search.grouping.request.CountAggregator in project vespa by vespa-engine.

the class VespaSerializerTestCase method requireThatGroupingRequestsAreSerialized.

@Test
public void requireThatGroupingRequestsAreSerialized() {
    Query query = new Query();
    query.getModel().getQueryTree().setRoot(new WordItem("foo"));
    assertEquals("default contains ([{\"implicitTransforms\": false}]\"foo\")", VespaSerializer.serialize(query));
    newGroupingRequest(query, new AllOperation().setGroupBy(new AttributeFunction("a")).addChild(new EachOperation().addOutput(new CountAggregator())));
    assertEquals("default contains ([{\"implicitTransforms\": false}]\"foo\") " + "| all(group(attribute(a)) each(output(count())))", VespaSerializer.serialize(query));
    newGroupingRequest(query, new AllOperation().setGroupBy(new AttributeFunction("b")).addChild(new EachOperation().addOutput(new CountAggregator())));
    assertEquals("default contains ([{\"implicitTransforms\": false}]\"foo\") " + "| all(group(attribute(a)) each(output(count()))) " + "| all(group(attribute(b)) each(output(count())))", VespaSerializer.serialize(query));
}
Also used : EachOperation(com.yahoo.search.grouping.request.EachOperation) Query(com.yahoo.search.Query) CountAggregator(com.yahoo.search.grouping.request.CountAggregator) AllOperation(com.yahoo.search.grouping.request.AllOperation) MarkerWordItem(com.yahoo.prelude.query.MarkerWordItem) WordItem(com.yahoo.prelude.query.WordItem) AttributeFunction(com.yahoo.search.grouping.request.AttributeFunction) Test(org.junit.Test)

Aggregations

MarkerWordItem (com.yahoo.prelude.query.MarkerWordItem)2 WordItem (com.yahoo.prelude.query.WordItem)2 Query (com.yahoo.search.Query)2 AllOperation (com.yahoo.search.grouping.request.AllOperation)2 AttributeFunction (com.yahoo.search.grouping.request.AttributeFunction)2 CountAggregator (com.yahoo.search.grouping.request.CountAggregator)2 EachOperation (com.yahoo.search.grouping.request.EachOperation)2 Test (org.junit.Test)2