Search in sources :

Example 1 with CountAggregationResult

use of com.yahoo.searchlib.aggregation.CountAggregationResult in project vespa by vespa-engine.

the class GroupingExecutorTestCase method requireThatGroupRelevanceCanBeSynthesized.

@Test
public void requireThatGroupRelevanceCanBeSynthesized() {
    Query query = newQuery();
    GroupingRequest req = GroupingRequest.newInstance(query);
    req.setRootOperation(GroupingOperation.fromString("all(group(foo) order(count()) each(output(count())))"));
    Grouping grp = new Grouping(0);
    grp.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new CountAggregationResult(1)).addOrderBy(new AggregationRefNode(0), true)).addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("bar")).addAggregationResult(new CountAggregationResult(2)).addOrderBy(new AggregationRefNode(0), true)));
    Result res = newExecution(new GroupingExecutor(), new ResultProvider(Arrays.asList(new GroupingListHit(Arrays.asList(grp), null), new GroupingListHit(Arrays.asList(grp), null)))).search(query);
    GroupList groupList = (GroupList) req.getResultGroup(res).get(0);
    assertEquals(1.0, groupList.get(0).getRelevance().getScore(), 1E-6);
    assertEquals(0.5, groupList.get(1).getRelevance().getScore(), 1E-6);
}
Also used : Group(com.yahoo.search.grouping.result.Group) Query(com.yahoo.search.Query) Grouping(com.yahoo.searchlib.aggregation.Grouping) AggregationRefNode(com.yahoo.searchlib.expression.AggregationRefNode) 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) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) GroupList(com.yahoo.search.grouping.result.GroupList) CountAggregationResult(com.yahoo.searchlib.aggregation.CountAggregationResult) GroupingRequest(com.yahoo.search.grouping.GroupingRequest) StringResultNode(com.yahoo.searchlib.expression.StringResultNode) Test(org.junit.Test)

Aggregations

GroupingListHit (com.yahoo.prelude.fastsearch.GroupingListHit)1 Query (com.yahoo.search.Query)1 Result (com.yahoo.search.Result)1 GroupingRequest (com.yahoo.search.grouping.GroupingRequest)1 Group (com.yahoo.search.grouping.result.Group)1 GroupList (com.yahoo.search.grouping.result.GroupList)1 CountAggregationResult (com.yahoo.searchlib.aggregation.CountAggregationResult)1 Grouping (com.yahoo.searchlib.aggregation.Grouping)1 HitsAggregationResult (com.yahoo.searchlib.aggregation.HitsAggregationResult)1 MaxAggregationResult (com.yahoo.searchlib.aggregation.MaxAggregationResult)1 MinAggregationResult (com.yahoo.searchlib.aggregation.MinAggregationResult)1 AggregationRefNode (com.yahoo.searchlib.expression.AggregationRefNode)1 StringResultNode (com.yahoo.searchlib.expression.StringResultNode)1 Test (org.junit.Test)1