Search in sources :

Example 1 with AllOperation

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

the class FastSearcherTestCase method testSinglePassGroupingIsNotForcedWithSingleNodeGroups.

@Test
public void testSinglePassGroupingIsNotForcedWithSingleNodeGroups() {
    MockDispatcher dispatcher = new MockDispatcher(ImmutableList.of(new SearchCluster.Node("host0", 123, 0), new SearchCluster.Node("host1", 123, 0)));
    FastSearcher fastSearcher = new FastSearcher(new MockBackend(), new FS4ResourcePool(1), dispatcher, new SummaryParameters(null), new ClusterParams("testhittype"), new CacheParams(100, 1e64), documentdbInfoConfig);
    Query q = new Query("?query=foo");
    GroupingRequest request1 = GroupingRequest.newInstance(q);
    request1.setRootOperation(new AllOperation());
    GroupingRequest request2 = GroupingRequest.newInstance(q);
    AllOperation all = new AllOperation();
    all.addChild(new EachOperation());
    all.addChild(new EachOperation());
    request2.setRootOperation(all);
    assertForceSinglePassIs(false, q);
    fastSearcher.search(q, new Execution(Execution.Context.createContextStub()));
    assertForceSinglePassIs(false, q);
}
Also used : Query(com.yahoo.search.Query) TraceNode(com.yahoo.yolean.trace.TraceNode) EachOperation(com.yahoo.search.grouping.request.EachOperation) Execution(com.yahoo.search.searchchain.Execution) MockBackend(com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) AllOperation(com.yahoo.search.grouping.request.AllOperation) Test(org.junit.Test)

Example 2 with AllOperation

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

the class GroupingExecutorTestCase method requireThatEmptyRequestsPass.

@Test
public void requireThatEmptyRequestsPass() {
    Query query = newQuery();
    GroupingRequest.newInstance(query).setRootOperation(new AllOperation());
    Result res = newExecution(new GroupingExecutor()).search(query);
    assertNotNull(res);
    assertEquals(0, res.hits().size());
}
Also used : Query(com.yahoo.search.Query) AllOperation(com.yahoo.search.grouping.request.AllOperation) Result(com.yahoo.search.Result) HitsAggregationResult(com.yahoo.searchlib.aggregation.HitsAggregationResult) CountAggregationResult(com.yahoo.searchlib.aggregation.CountAggregationResult) MinAggregationResult(com.yahoo.searchlib.aggregation.MinAggregationResult) MaxAggregationResult(com.yahoo.searchlib.aggregation.MaxAggregationResult) Test(org.junit.Test)

Example 3 with AllOperation

use of com.yahoo.search.grouping.request.AllOperation 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 4 with AllOperation

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

the class FastSearcherTestCase method testSinglePassGroupingIsForcedWithSingleNodeGroups.

@Test
public void testSinglePassGroupingIsForcedWithSingleNodeGroups() {
    FastSearcher fastSearcher = new FastSearcher(new MockBackend(), new FS4ResourcePool(1), new MockDispatcher(new SearchCluster.Node("host0", 123, 0)), new SummaryParameters(null), new ClusterParams("testhittype"), new CacheParams(100, 1e64), documentdbInfoConfig);
    Query q = new Query("?query=foo");
    GroupingRequest request1 = GroupingRequest.newInstance(q);
    request1.setRootOperation(new AllOperation());
    GroupingRequest request2 = GroupingRequest.newInstance(q);
    AllOperation all = new AllOperation();
    all.addChild(new EachOperation());
    all.addChild(new EachOperation());
    request2.setRootOperation(all);
    assertForceSinglePassIs(false, q);
    fastSearcher.search(q, new Execution(Execution.Context.createContextStub()));
    assertForceSinglePassIs(true, q);
}
Also used : Query(com.yahoo.search.Query) TraceNode(com.yahoo.yolean.trace.TraceNode) EachOperation(com.yahoo.search.grouping.request.EachOperation) Execution(com.yahoo.search.searchchain.Execution) MockBackend(com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) AllOperation(com.yahoo.search.grouping.request.AllOperation) Test(org.junit.Test)

Example 5 with AllOperation

use of com.yahoo.search.grouping.request.AllOperation 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

Query (com.yahoo.search.Query)5 AllOperation (com.yahoo.search.grouping.request.AllOperation)5 Test (org.junit.Test)5 EachOperation (com.yahoo.search.grouping.request.EachOperation)4 MockBackend (com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend)2 MarkerWordItem (com.yahoo.prelude.query.MarkerWordItem)2 WordItem (com.yahoo.prelude.query.WordItem)2 GroupingRequest (com.yahoo.search.grouping.GroupingRequest)2 AttributeFunction (com.yahoo.search.grouping.request.AttributeFunction)2 CountAggregator (com.yahoo.search.grouping.request.CountAggregator)2 Execution (com.yahoo.search.searchchain.Execution)2 TraceNode (com.yahoo.yolean.trace.TraceNode)2 Result (com.yahoo.search.Result)1 CountAggregationResult (com.yahoo.searchlib.aggregation.CountAggregationResult)1 HitsAggregationResult (com.yahoo.searchlib.aggregation.HitsAggregationResult)1 MaxAggregationResult (com.yahoo.searchlib.aggregation.MaxAggregationResult)1 MinAggregationResult (com.yahoo.searchlib.aggregation.MinAggregationResult)1