Search in sources :

Example 16 with GroupingRequest

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

the class GroupingExecutorTestCase method requireThatParallelGroupingIsNotRedundant.

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

Example 17 with GroupingRequest

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

the class GroupingExecutorTestCase method requireThatUnfilledHitsRenderError.

@Test
public void requireThatUnfilledHitsRenderError() throws IOException {
    Query query = newQuery();
    GroupingRequest req = GroupingRequest.newInstance(query);
    req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(each(output(summary(bar)))))"));
    Grouping grp0 = new Grouping(0);
    grp0.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, "bar"))));
    Grouping grp1 = new Grouping(0);
    grp1.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, "bar").addHit(new com.yahoo.searchlib.aggregation.FS4Hit()))));
    Execution exec = newExecution(new GroupingExecutor(), new ResultProvider(Arrays.asList(new GroupingListHit(Arrays.asList(grp0), null), new GroupingListHit(Arrays.asList(grp1), null))), new FillErrorProvider());
    Result res = exec.search(query);
    exec.fill(res);
    assertNotNull(res.hits().getError());
}
Also used : Group(com.yahoo.search.grouping.result.Group) Query(com.yahoo.search.Query) Grouping(com.yahoo.searchlib.aggregation.Grouping) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) 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) HitsAggregationResult(com.yahoo.searchlib.aggregation.HitsAggregationResult) Execution(com.yahoo.search.searchchain.Execution) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) StringResultNode(com.yahoo.searchlib.expression.StringResultNode) Test(org.junit.Test)

Example 18 with GroupingRequest

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

the class GroupingExecutorTestCase method requireThatPassResultsAreMerged.

@Test
public void requireThatPassResultsAreMerged() {
    Query query = newQuery();
    GroupingRequest req = GroupingRequest.newInstance(query);
    req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(output(min(bar), max(bar))))"));
    Grouping grpA = new Grouping(0);
    grpA.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("uniqueA")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(6)).setTag(4))).addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("common")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(9)).setTag(4))));
    Grouping grpB = new Grouping(0);
    grpB.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("uniqueB")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(9)).setTag(4))).addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("common")).addAggregationResult(new MinAggregationResult().setMin(new IntegerResultNode(6)).setTag(3))));
    Execution exec = newExecution(new GroupingExecutor(), new ResultProvider(Arrays.asList(new GroupingListHit(Arrays.asList(grpA), null), new GroupingListHit(Arrays.asList(grpB), null))));
    Group grp = req.getResultGroup(exec.search(query));
    assertEquals(1, grp.size());
    Hit hit = grp.get(0);
    assertTrue(hit instanceof GroupList);
    GroupList lst = (GroupList) hit;
    assertEquals(3, lst.size());
    assertNotNull(hit = lst.get("group:string:uniqueA"));
    assertEquals(6L, hit.getField("max(bar)"));
    assertNotNull(hit = lst.get("group:string:uniqueB"));
    assertEquals(9L, hit.getField("max(bar)"));
    assertNotNull(hit = lst.get("group:string:common"));
    assertEquals(6L, hit.getField("min(bar)"));
    assertEquals(9L, hit.getField("max(bar)"));
}
Also used : Group(com.yahoo.search.grouping.result.Group) Query(com.yahoo.search.Query) MinAggregationResult(com.yahoo.searchlib.aggregation.MinAggregationResult) Grouping(com.yahoo.searchlib.aggregation.Grouping) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) MaxAggregationResult(com.yahoo.searchlib.aggregation.MaxAggregationResult) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) FastHit(com.yahoo.prelude.fastsearch.FastHit) Hit(com.yahoo.search.result.Hit) Execution(com.yahoo.search.searchchain.Execution) IntegerResultNode(com.yahoo.searchlib.expression.IntegerResultNode) GroupList(com.yahoo.search.grouping.result.GroupList) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) StringResultNode(com.yahoo.searchlib.expression.StringResultNode) Test(org.junit.Test)

Example 19 with GroupingRequest

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

the class GroupingExecutorTestCase method requireThatSearchIsMultiPass.

@Test
public void requireThatSearchIsMultiPass() {
    Query query = newQuery();
    GroupingRequest req = GroupingRequest.newInstance(query);
    req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(output(max(bar))))"));
    PassCounter cnt = new PassCounter();
    newExecution(new GroupingExecutor(), cnt).search(query);
    assertEquals(2, cnt.numPasses);
}
Also used : Query(com.yahoo.search.Query) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) Test(org.junit.Test)

Example 20 with GroupingRequest

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

the class MinimalQueryInserterTestCase method assertGrouping.

private static void assertGrouping(String expected, Query query) {
    List<String> actual = new ArrayList<>();
    for (GroupingRequest request : GroupingRequest.getRequests(query)) {
        actual.add(request.continuations().toString() + request.getRootOperation());
    }
    assertEquals(expected, actual.toString());
}
Also used : ArrayList(java.util.ArrayList) GroupingRequest(com.yahoo.search.grouping.GroupingRequest)

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