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());
}
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());
}
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)"));
}
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);
}
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());
}
Aggregations