use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class FederationSearcherTestCase method testTraceOneSourceNoCloning.
@Test
public void testTraceOneSourceNoCloning() {
Chain<Searcher> mainChain = twoTracingSources(true);
Query q = new Query(com.yahoo.search.test.QueryTestCase.httpEncode("?query=test&traceLevel=1&sources=source1"));
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);
assertFalse(lookForTraces.traceFromSource2);
}
use of com.yahoo.search.Searcher 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.Searcher 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.Searcher in project vespa by vespa-engine.
the class TilingTestCase method testTiling2.
/**
* This result contains center section and meta blocks.
* <p>
* Incidentally, this also tests using an old searcher in new search chains.
*/
public void testTiling2() throws IOException {
Chain<Searcher> chain = new Chain<>("tiling", new TiledResultProducer2());
// Query it
Query query = new Query("/tiled?query=foo");
Result result = callSearchAndSetRenderer(chain, query);
assertRendered(IOUtils.readFile(new File("src/test/java/com/yahoo/prelude/templates/test/tilingexample2.xml")), result);
}
use of com.yahoo.search.Searcher in project vespa by vespa-engine.
the class HitConverterTestCase method requireThatSummaryClassIsSet.
@Test
public void requireThatSummaryClassIsSet() {
Searcher searcher = new MySearcher();
HitConverter converter = new HitConverter(searcher, new Query());
Hit hit = converter.toSearchHit("69", new FS4Hit(1, createGlobalId(2), 3).setContext(new Hit("hit:ctx")));
assertNotNull(hit);
assertTrue(hit instanceof FastHit);
assertEquals("69", hit.getSearcherSpecificMetaData(searcher));
}
Aggregations