use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class FederationSearcherTestCase method searchWithPropertyPropagation.
private Result searchWithPropertyPropagation(PropagateSourceProperties.Enum propagateSourceProperties) {
addChained(new MockSearcher(), "mySource1");
addChained(new MockSearcher(), "mySource2");
Chain<Searcher> mainChain = new Chain<>("default", createFederationSearcher(propagateSourceProperties));
Query q = new Query(QueryTestCase.httpEncode("?query=test&source.mySource1.presentation.summary=nalle"));
Result result = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null)).search(q);
assertNull(result.hits().getError());
return result;
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class FederationSearcherTestCase method testQueryProfileNestedReferencing.
@Test
public void testQueryProfileNestedReferencing() {
addChained(new MockSearcher(), "mySource1");
addChained(new MockSearcher(), "mySource2");
Chain<Searcher> mainChain = new Chain<>("default", createFederationSearcher());
QueryProfile defaultProfile = new QueryProfile("default");
defaultProfile.set("source.mySource1.hits", "%{hits}", null);
defaultProfile.freeze();
Query q = new Query(QueryTestCase.httpEncode("?query=test"), defaultProfile.compile(null));
Result result = new Execution(mainChain, Execution.Context.createContextStub(chainRegistry, null)).search(q);
assertNull(result.hits().getError());
assertEquals("source:mySource1", result.hits().get(0).getId().stringValue());
assertEquals("source:mySource2", result.hits().get(1).getId().stringValue());
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class StemmingSearcherTestCase method testEmptyIndexInfo.
@Test
public void testEmptyIndexInfo() {
String indexInfoConfigID = "file:src/test/java/com/yahoo/prelude/querytransform/test/emptyindexinfo.cfg";
ConfigGetter<IndexInfoConfig> getter = new ConfigGetter<>(IndexInfoConfig.class);
IndexInfoConfig config = getter.getConfig(indexInfoConfigID);
IndexFacts indexFacts = new IndexFacts(new IndexModel(config, (QrSearchersConfig) null));
Query q = new Query(QueryTestCase.httpEncode("?query=cars"));
new Execution(new Chain<Searcher>(new StemmingSearcher(linguistics)), new Execution.Context(null, indexFacts, null, null, linguistics)).search(q);
assertEquals("cars", q.getModel().getQueryTree().getRoot().toString());
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class TilingTestCase method testTiling.
/**
* This result contains two blocks (center and right).
* The center block contains multiple subblocks while the right one contains a single block of ads.
* <p>
* Incidentally, this also tests using an old searcher in new search chains.
*/
public void testTiling() throws IOException {
Chain<Searcher> chain = new Chain<>("tiling", new TiledResultProducer());
// 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/tilingexample.xml")), result);
}
use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.
the class AsyncExecutionTestCase method testAsync.
// This should take ~50+ ms
public void testAsync() {
List<Searcher> searchList = new ArrayList<>();
searchList.add(new WaitingSearcher("one", 60000));
searchList.add(new WaitingSearcher("two", 0));
Chain<Searcher> searchChain = new Chain<>(new ComponentId("chain"), searchList);
AsyncExecution asyncExecution = new AsyncExecution(searchChain, Execution.Context.createContextStub());
FutureResult future = asyncExecution.search(new Query("?hits=0"));
Result result = future.get(0, TimeUnit.MILLISECONDS);
assertTrue(result.hits().getError() != null);
}
Aggregations