Search in sources :

Example 11 with StringResultNode

use of com.yahoo.searchlib.expression.StringResultNode 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)

Aggregations

StringResultNode (com.yahoo.searchlib.expression.StringResultNode)11 GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)9 Query (com.yahoo.search.Query)9 GroupingRequest (com.yahoo.search.grouping.GroupingRequest)9 Group (com.yahoo.search.grouping.result.Group)9 Grouping (com.yahoo.searchlib.aggregation.Grouping)9 Test (org.junit.Test)9 Execution (com.yahoo.search.searchchain.Execution)8 MaxAggregationResult (com.yahoo.searchlib.aggregation.MaxAggregationResult)7 HitsAggregationResult (com.yahoo.searchlib.aggregation.HitsAggregationResult)6 MinAggregationResult (com.yahoo.searchlib.aggregation.MinAggregationResult)6 Result (com.yahoo.search.Result)5 FastHit (com.yahoo.prelude.fastsearch.FastHit)4 CountAggregationResult (com.yahoo.searchlib.aggregation.CountAggregationResult)4 GroupList (com.yahoo.search.grouping.result.GroupList)3 Hit (com.yahoo.search.result.Hit)3 IntegerResultNode (com.yahoo.searchlib.expression.IntegerResultNode)3 DocumentId (com.yahoo.document.DocumentId)2 GlobalId (com.yahoo.document.GlobalId)2 DoubleValue (com.yahoo.search.grouping.request.DoubleValue)2