use of com.yahoo.search.Result in project vespa by vespa-engine.
the class FederationSearcherTestCase method assertSelects.
private void assertSelects(String providerName, SearchChainRegistry registry) {
QueryProfile profile = new QueryProfile("test");
profile.set("source.news.provider", providerName, null);
Query query = new Query(QueryTestCase.httpEncode("?query=test&model.sources=news"), profile.compile(null));
Result result = new Execution(registry.getComponent("default"), Execution.Context.createContextStub(registry, null)).search(query);
assertEquals(1, result.hits().size());
assertNotNull(result.hits().get(providerName + ":1"));
}
use of com.yahoo.search.Result in project vespa by vespa-engine.
the class FederationSearcherTestCase method testDisablePropertyPropagation.
@Test
public void testDisablePropertyPropagation() {
Result result = searchWithPropertyPropagation(PropagateSourceProperties.NONE);
assertNull(result.hits().get(0).getQuery().getPresentation().getSummary());
}
use of com.yahoo.search.Result in project vespa by vespa-engine.
the class FederationSearcherTestCase method twoTracingSources.
private Chain<Searcher> twoTracingSources(boolean strictContracts) {
addChained(new Searcher() {
@Override
public Result search(Query query, Execution execution) {
query.trace(SOURCE1, 1);
return execution.search(query);
}
}, SOURCE1);
addChained(new Searcher() {
@Override
public Result search(Query query, Execution execution) {
query.trace(SOURCE2, 1);
return execution.search(query);
}
}, SOURCE2);
Chain<Searcher> mainChain = new Chain<>("default", new FederationSearcher(new FederationConfig(builder), new StrictContractsConfig(new StrictContractsConfig.Builder().searchchains(strictContracts)), new ComponentRegistry<>()));
return mainChain;
}
use of com.yahoo.search.Result in project vespa by vespa-engine.
the class FederationSearcherTestCase method testTraceTwoSources.
@Test
public void testTraceTwoSources() {
Chain<Searcher> mainChain = twoTracingSources(false);
Query q = new Query(com.yahoo.search.test.QueryTestCase.httpEncode("?query=test&traceLevel=1"));
Execution execution = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null));
Result result = execution.search(q);
assertNull(result.hits().getError());
TwoSourceChecker lookForTraces = new TwoSourceChecker();
execution.trace().accept(lookForTraces);
assertTrue(lookForTraces.traceFromSource1);
assertTrue(lookForTraces.traceFromSource2);
}
use of com.yahoo.search.Result in project vespa by vespa-engine.
the class GroupedResultTestCase method testGroupedResult.
public void testGroupedResult() {
Result result = new Result(new Query("?query=foo"));
HitGroup hitGroup1 = new HitGroup("group1", 300);
hitGroup1.add(new Hit("group1.1", 200));
HitGroup hitGroup2 = new HitGroup("group2", 600);
Hit topLevelHit1 = new Hit("toplevel.1", 500);
Hit topLevelHit2 = new Hit("toplevel.2", 700);
result.hits().add(hitGroup1);
result.hits().add(topLevelHit1);
result.hits().add(hitGroup2);
result.hits().add(topLevelHit2);
hitGroup1.add(new Hit("group1.2", 800));
hitGroup2.add(new Hit("group2.1", 800));
hitGroup2.add(new Hit("group2.2", 300));
hitGroup2.add(new Hit("group2.3", 500));
// Should have 7 concrete hits, ordered as
// toplevel.2
// group2
// group2.1
// group2.3
// group2.2
// toplevel.1
// group1
// group1.2
// group1.1
// Assert this:
assertEquals(7, result.getConcreteHitCount());
assertEquals(4, result.getHitCount());
Hit topLevel2 = result.hits().get(0);
assertEquals("toplevel.2", topLevel2.getId().stringValue());
HitGroup returnedGroup2 = (HitGroup) result.hits().get(1);
assertEquals(3, returnedGroup2.getConcreteSize());
assertEquals(3, returnedGroup2.size());
assertEquals("group2.1", returnedGroup2.get(0).getId().stringValue());
assertEquals("group2.3", returnedGroup2.get(1).getId().stringValue());
assertEquals("group2.2", returnedGroup2.get(2).getId().stringValue());
Hit topLevel1 = result.hits().get(2);
assertEquals("toplevel.1", topLevel1.getId().stringValue());
HitGroup returnedGroup1 = (HitGroup) result.hits().get(3);
assertEquals(2, returnedGroup1.getConcreteSize());
assertEquals(2, returnedGroup1.size());
assertEquals("group1.2", returnedGroup1.get(0).getId().stringValue());
assertEquals("group1.1", returnedGroup1.get(1).getId().stringValue());
}
Aggregations