use of com.yahoo.search.Result in project vespa by vespa-engine.
the class GroupingExecutorTestCase method testIllegalQuery.
@Test
public void testIllegalQuery() {
Execution exc = newExecution(new GroupingExecutor());
Query query = new Query();
NotItem notItem = new NotItem();
notItem.addNegativeItem(new WordItem("negative"));
query.getModel().getQueryTree().setRoot(notItem);
Result result = exc.search(query);
com.yahoo.search.result.ErrorMessage message = result.hits().getError();
assertNotNull("Got error", message);
assertEquals("Illegal query", message.getMessage());
assertEquals("Can not search for only negative items", message.getDetailedMessage());
assertEquals(3, message.getCode());
}
use of com.yahoo.search.Result in project vespa by vespa-engine.
the class GroupingExecutorTestCase method requireThatEmptyRequestsPass.
@Test
public void requireThatEmptyRequestsPass() {
Query query = newQuery();
GroupingRequest.newInstance(query).setRootOperation(new AllOperation());
Result res = newExecution(new GroupingExecutor()).search(query);
assertNotNull(res);
assertEquals(0, res.hits().size());
}
use of com.yahoo.search.Result in project vespa by vespa-engine.
the class GroupingExecutorTestCase method requireThatHitsAreFilled.
@Test
public void requireThatHitsAreFilled() {
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 FillRequestThrower());
Result res = exec.search(query);
// Fill with summary specified in grouping
try {
exec.fill(res);
fail();
} catch (FillRequestException e) {
assertEquals("bar", e.summaryClass);
}
// Fill again, with another summary
try {
exec.fill(res, "otherSummary");
fail();
} catch (FillRequestException e) {
assertEquals("otherSummary", e.summaryClass);
}
}
use of com.yahoo.search.Result in project vespa by vespa-engine.
the class GroupingExecutorTestCase method requireThatErrorsAreHandled.
@Test
public void requireThatErrorsAreHandled() {
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()))));
ErrorProvider err = new ErrorProvider(1);
Execution exec = newExecution(new GroupingExecutor(), err, new ResultProvider(Arrays.asList(new GroupingListHit(Arrays.asList(grp0), null), new GroupingListHit(Arrays.asList(grp1), null))));
Result res = exec.search(query);
assertTrue(res.hits().getError() != null);
assertEquals(Error.TIMEOUT.code, res.hits().getError().getCode());
assertFalse(err.continuedOnFail);
err = new ErrorProvider(0);
exec = newExecution(new GroupingExecutor(), err, new ResultProvider(Arrays.asList(new GroupingListHit(Arrays.asList(grp0), null), new GroupingListHit(Arrays.asList(grp1), null))));
res = exec.search(query);
assertTrue(res.hits().getError() != null);
assertEquals(Error.TIMEOUT.code, res.hits().getError().getCode());
assertFalse(err.continuedOnFail);
}
use of com.yahoo.search.Result 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);
}
Aggregations