Search in sources :

Example 11 with GroupingRequest

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

the class GroupingExecutorTestCase method requireThatRequestsAreTransformed.

@Test
public void requireThatRequestsAreTransformed() {
    Query query = newQuery();
    GroupingRequest req = GroupingRequest.newInstance(query);
    req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(output(max(bar))))"));
    try {
        newExecution(new GroupingExecutor(), new GroupingListThrower()).search(query);
        fail();
    } catch (GroupingListException e) {
        assertNotNull(e.lst);
        assertEquals(1, e.lst.size());
        Grouping grp = e.lst.get(0);
        assertNotNull(grp);
    }
}
Also used : Query(com.yahoo.search.Query) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) Grouping(com.yahoo.searchlib.aggregation.Grouping) Test(org.junit.Test)

Example 12 with GroupingRequest

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

the class GroupingExecutorTestCase method requireThatPassRequestsSingleLevel.

@Test
public void requireThatPassRequestsSingleLevel() {
    Query query = newQuery();
    GroupingRequest req = GroupingRequest.newInstance(query);
    req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(output(max(bar))))"));
    GroupingCollector clt = new GroupingCollector();
    newExecution(new GroupingExecutor(), clt).search(query);
    assertEquals(2, clt.lst.size());
    Grouping grp = clt.lst.get(0);
    assertEquals(0, grp.getFirstLevel());
    assertEquals(0, grp.getLastLevel());
    grp = clt.lst.get(1);
    assertEquals(1, grp.getFirstLevel());
    assertEquals(1, grp.getLastLevel());
}
Also used : Query(com.yahoo.search.Query) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) Grouping(com.yahoo.searchlib.aggregation.Grouping) Test(org.junit.Test)

Example 13 with GroupingRequest

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

the class GroupingExecutorTestCase method execute.

private List<Grouping> execute(String groupingExpression) {
    Query query = newQuery();
    GroupingRequest req = GroupingRequest.newInstance(query);
    req.setRootOperation(GroupingOperation.fromString(groupingExpression));
    GroupingCollector collector = new GroupingCollector();
    newExecution(new GroupingExecutor(), collector).search(query);
    return collector.lst;
}
Also used : Query(com.yahoo.search.Query) GroupingRequest(com.yahoo.search.grouping.GroupingRequest)

Example 14 with GroupingRequest

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

the class GroupingExecutorTestCase method requireThatEachBelowAllDoesNotBlowUp.

@Test
public void requireThatEachBelowAllDoesNotBlowUp() {
    Query query = newQuery();
    GroupingRequest req = GroupingRequest.newInstance(query);
    req.setRootOperation(GroupingOperation.fromString("all(each(output(summary(bar))))"));
    Result res = newExecution(new GroupingExecutor()).search(query);
    assertNotNull(res);
    assertEquals(1, res.hits().size());
}
Also used : Query(com.yahoo.search.Query) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) 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 15 with GroupingRequest

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

the class GroupingExecutorTestCase method requireThatGroupingIsParallel.

@Test
public void requireThatGroupingIsParallel() {
    Query query = newQuery();
    GroupingRequest req = GroupingRequest.newInstance(query);
    req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(output(max(bar))) as(max)" + "               each(output(min(bar))) as(min))"));
    GroupingCounter cnt = new GroupingCounter();
    newExecution(new GroupingExecutor(), cnt).search(query);
    assertEquals(2, cnt.passList.size());
    assertEquals(2, cnt.passList.get(0).intValue());
    assertEquals(2, cnt.passList.get(1).intValue());
}
Also used : Query(com.yahoo.search.Query) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) Test(org.junit.Test)

Aggregations

GroupingRequest (com.yahoo.search.grouping.GroupingRequest)22 Query (com.yahoo.search.Query)18 Test (org.junit.Test)17 Grouping (com.yahoo.searchlib.aggregation.Grouping)12 Execution (com.yahoo.search.searchchain.Execution)10 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)9 Group (com.yahoo.search.grouping.result.Group)9 StringResultNode (com.yahoo.searchlib.expression.StringResultNode)9 HitsAggregationResult (com.yahoo.searchlib.aggregation.HitsAggregationResult)8 MaxAggregationResult (com.yahoo.searchlib.aggregation.MaxAggregationResult)8 Result (com.yahoo.search.Result)7 MinAggregationResult (com.yahoo.searchlib.aggregation.MinAggregationResult)7 CountAggregationResult (com.yahoo.searchlib.aggregation.CountAggregationResult)6 FastHit (com.yahoo.prelude.fastsearch.FastHit)4 GroupList (com.yahoo.search.grouping.result.GroupList)4 Hit (com.yahoo.search.result.Hit)4 DocumentId (com.yahoo.document.DocumentId)2 GlobalId (com.yahoo.document.GlobalId)2 MockBackend (com.yahoo.prelude.fastsearch.test.fs4mock.MockBackend)2 AllOperation (com.yahoo.search.grouping.request.AllOperation)2