Search in sources :

Example 66 with Chain

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;
}
Also used : Chain(com.yahoo.component.chain.Chain) SearchChain(com.yahoo.search.searchchain.SearchChain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) FederationSearcher(com.yahoo.search.federation.FederationSearcher) Result(com.yahoo.search.Result)

Example 67 with Chain

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());
}
Also used : Chain(com.yahoo.component.chain.Chain) SearchChain(com.yahoo.search.searchchain.SearchChain) QueryProfile(com.yahoo.search.query.profile.QueryProfile) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) FederationSearcher(com.yahoo.search.federation.FederationSearcher) Result(com.yahoo.search.Result) Test(org.junit.Test)

Example 68 with Chain

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());
}
Also used : Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) IndexFacts(com.yahoo.prelude.IndexFacts) Query(com.yahoo.search.Query) ConfigGetter(com.yahoo.config.subscription.ConfigGetter) QrSearchersConfig(com.yahoo.container.QrSearchersConfig) StemmingSearcher(com.yahoo.prelude.querytransform.StemmingSearcher) IndexInfoConfig(com.yahoo.search.config.IndexInfoConfig) IndexModel(com.yahoo.prelude.IndexModel) Test(org.junit.Test)

Example 69 with Chain

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);
}
Also used : Chain(com.yahoo.component.chain.Chain) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) HTTPProviderSearcher(com.yahoo.search.federation.http.HTTPProviderSearcher) File(java.io.File) Result(com.yahoo.search.Result)

Example 70 with Chain

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);
}
Also used : Chain(com.yahoo.component.chain.Chain) FutureResult(com.yahoo.search.searchchain.FutureResult) Query(com.yahoo.search.Query) AsyncExecution(com.yahoo.search.searchchain.AsyncExecution) Searcher(com.yahoo.search.Searcher) ArrayList(java.util.ArrayList) ComponentId(com.yahoo.component.ComponentId) FutureResult(com.yahoo.search.searchchain.FutureResult) Result(com.yahoo.search.Result)

Aggregations

Chain (com.yahoo.component.chain.Chain)92 Execution (com.yahoo.search.searchchain.Execution)59 Searcher (com.yahoo.search.Searcher)57 Test (org.junit.Test)56 Result (com.yahoo.search.Result)48 Query (com.yahoo.search.Query)47 FeedContext (com.yahoo.feedapi.FeedContext)21 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)21 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)21 ClusterList (com.yahoo.vespaclient.ClusterList)21 Processor (com.yahoo.processing.Processor)17 Request (com.yahoo.processing.Request)10 Response (com.yahoo.processing.Response)10 ComponentId (com.yahoo.component.ComponentId)8 FederationSearcher (com.yahoo.search.federation.FederationSearcher)8 ArrayList (java.util.ArrayList)8 GetDocumentMessage (com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage)7 Message (com.yahoo.messagebus.Message)7 Hit (com.yahoo.search.result.Hit)7 AsyncExecution (com.yahoo.search.searchchain.AsyncExecution)6