use of com.yahoo.search.Query 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.Query 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.Query 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.Query in project vespa by vespa-engine.
the class HttpPostTestCase method testPostingSearcher.
@Test
public void testPostingSearcher() throws Exception {
StupidSingleThreadedHttpServer server = new StupidSingleThreadedHttpServer();
server.start();
TestPostSearcher searcher = new TestPostSearcher(new ComponentId("foo:1"), Arrays.asList(new Connection("localhost", server.getServerPort())), "/");
Query q = new Query("");
q.setTimeout(10000000L);
Execution e = new Execution(searcher, Execution.Context.createContextStub());
searcher.search(q, e);
assertThat(server.getRequest(), containsString("My POST body"));
server.stop();
}
use of com.yahoo.search.Query in project vespa by vespa-engine.
the class SemanticSearcherTestCase method testNullQuery.
public void testNullQuery() {
// Causes a query containing a NullItem
Query query = new Query("");
doSearch(searcher, query, 0, 10);
// Still a NullItem
assertEquals(NullItem.class, query.getModel().getQueryTree().getRoot().getClass());
}
Aggregations