use of com.yahoo.search.Result 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.Result in project vespa by vespa-engine.
the class ResultTestCase method testHitOrdering.
public void testHitOrdering() {
Result result = new Result(new Query("dummy"));
result.hits().add(new Hit("test:hit1", 80));
result.hits().add(new Hit("test:hit2", 90));
result.hits().add(new Hit("test:hit3", 70));
Iterator<?> hits = result.hits().deepIterator();
assertEquals(new Hit("test:hit2", 90), hits.next());
assertEquals(new Hit("test:hit1", 80), hits.next());
assertEquals(new Hit("test:hit3", 70), hits.next());
}
use of com.yahoo.search.Result in project vespa by vespa-engine.
the class ResultTestCase method testHitTrimming.
public void testHitTrimming() {
Result result = new Result(new Query("dummy"));
// case 1: keep some hits in the middle
resultInit(result);
result.hits().trim(3, 3);
assertEquals(3, result.getHitCount());
Iterator<Hit> hits = result.hits().deepIterator();
assertEquals(new Hit("test:hit3", 70), hits.next());
assertEquals(new Hit("test:hit8", 55), hits.next());
assertEquals(new Hit("test:hit5", 50), hits.next());
assertEquals(false, hits.hasNext());
// case 2: keep some hits at the end
result = new Result(new Query("dummy"));
resultInit(result);
result.hits().trim(5, 4);
hits = result.hits().deepIterator();
assertEquals(new Hit("test:hit5", 50), hits.next());
assertEquals(new Hit("test:hit4", 40), hits.next());
assertEquals(new Hit("test:hit6", 20), hits.next());
assertEquals(new Hit("test:hit7", 20), hits.next());
assertEquals(false, hits.hasNext());
// case 3: keep some hits at the beginning
result = new Result(new Query("dummy"));
resultInit(result);
result.hits().trim(0, 4);
hits = result.hits().deepIterator();
assertEquals(new Hit("test:hit2", 90), hits.next());
assertEquals(new Hit("test:hit1", 80), hits.next());
assertEquals(new Hit("test:hit9", 75), hits.next());
assertEquals(new Hit("test:hit3", 70), hits.next());
assertEquals(false, hits.hasNext());
// case 4: keep no hits
result = new Result(new Query("dummy"));
resultInit(result);
result.hits().trim(10, 4);
hits = result.hits().deepIterator();
assertEquals(false, hits.hasNext());
}
use of com.yahoo.search.Result in project vespa by vespa-engine.
the class SecondSearcher method search.
public Result search(com.yahoo.search.Query query, Execution execution) {
Result result = execution.search(query);
result.hits().add(new Hit("searcher:2", 996));
return result;
}
use of com.yahoo.search.Result 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