use of com.yahoo.search.searchchain.Execution 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.searchchain.Execution 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.searchchain.Execution in project vespa by vespa-engine.
the class GroupingExecutorTestCase method requireThatUnexpectedGroupingResultsAreIgnored.
@Test
public void requireThatUnexpectedGroupingResultsAreIgnored() {
Query query = newQuery();
GroupingRequest req = GroupingRequest.newInstance(query);
req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(output(max(bar))))"));
Grouping grpExpected = new Grouping(0);
grpExpected.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("expected")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(69)).setTag(3))));
Grouping grpUnexpected = new Grouping(1);
grpUnexpected.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("unexpected")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(96)).setTag(3))));
Execution exec = newExecution(new GroupingExecutor(), new ResultProvider(Arrays.asList(new GroupingListHit(Arrays.asList(grpExpected), null), new GroupingListHit(Arrays.asList(grpUnexpected), 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(1, lst.size());
assertNotNull(hit = lst.get("group:string:expected"));
assertEquals(69L, hit.getField("max(bar)"));
assertNull(lst.get("group:string:unexpected"));
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class GroupingExecutorTestCase method requireThatDefaultSummaryNameFillsHitsWithNull.
@Test
public void requireThatDefaultSummaryNameFillsHitsWithNull() {
Query query = newQuery();
GroupingRequest req = GroupingRequest.newInstance(query);
req.setRootOperation(GroupingOperation.fromString("all(group(foo) each(each(output(summary()))) as(foo))"));
Grouping pass0 = new Grouping(0);
pass0.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, ExpressionConverter.DEFAULT_SUMMARY_NAME))));
Grouping pass1 = new Grouping(0);
pass1.setRoot(new com.yahoo.searchlib.aggregation.Group().addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("foo")).addAggregationResult(new HitsAggregationResult(1, ExpressionConverter.DEFAULT_SUMMARY_NAME).addHit(new com.yahoo.searchlib.aggregation.FS4Hit()))));
Execution exec = newExecution(new GroupingExecutor(), new ResultProvider(Arrays.asList(new GroupingListHit(Arrays.asList(pass0), null), new GroupingListHit(Arrays.asList(pass1), null))));
Result res = exec.search(query);
exec.fill(res);
Hit hit = ((HitList) ((Group) ((GroupList) req.getResultGroup(res).get(0)).get(0)).get(0)).get(0);
assertTrue(hit instanceof FastHit);
assertTrue(hit.isFilled(null));
}
use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.
the class ClusteredConnectionTestCase method testClusteringWithPing.
public void testClusteringWithPing() {
Connection connection0 = new Connection("0");
Connection connection1 = new Connection("1");
Connection connection2 = new Connection("2");
List<Connection> connections = new ArrayList<>();
connections.add(connection0);
connections.add(connection1);
connections.add(connection2);
MyBackend myBackend = new MyBackend(new ComponentId("test"), connections);
Result r;
// Note that we cannot make any successful queries here or we have to wait 10 seconds for
// the traffic monitor to agree that these nodes are really not responding
connection2.setInService(false);
connection1.setInService(false);
connection0.setInService(false);
forcePing(myBackend);
r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
assertEquals("No backends in service. Try later", r.hits().getError().getMessage());
connection2.setInService(true);
connection1.setInService(true);
connection0.setInService(true);
forcePing(myBackend);
r = new Execution(myBackend, Execution.Context.createContextStub()).search(new SimpleQuery(0));
assertNull(r.hits().getError());
}
Aggregations