Search in sources :

Example 11 with Execution

use of com.yahoo.search.searchchain.Execution in project vespa by vespa-engine.

the class GroupingQueryParserTestCase method executeQuery.

private static List<GroupingRequest> executeQuery(String request, String continuation, String timeZone) {
    Query query = new Query();
    query.properties().set(GroupingQueryParser.PARAM_REQUEST, request);
    query.properties().set(GroupingQueryParser.PARAM_CONTINUE, continuation);
    query.properties().set(GroupingQueryParser.PARAM_TIMEZONE, timeZone);
    new Execution(new GroupingQueryParser(), Execution.Context.createContextStub()).search(query);
    return GroupingRequest.getRequests(query);
}
Also used : Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query)

Example 12 with Execution

use of com.yahoo.search.searchchain.Execution 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);
}
Also used : 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 13 with Execution

use of com.yahoo.search.searchchain.Execution 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"));
}
Also used : QueryProfile(com.yahoo.search.query.profile.QueryProfile) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Result(com.yahoo.search.Result)

Example 14 with Execution

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

Example 15 with Execution

use of com.yahoo.search.searchchain.Execution 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);
}
Also used : 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)

Aggregations

Execution (com.yahoo.search.searchchain.Execution)232 Query (com.yahoo.search.Query)184 Result (com.yahoo.search.Result)127 Test (org.junit.Test)123 Searcher (com.yahoo.search.Searcher)88 Chain (com.yahoo.component.chain.Chain)59 IndexFacts (com.yahoo.prelude.IndexFacts)34 Hit (com.yahoo.search.result.Hit)25 FeedContext (com.yahoo.feedapi.FeedContext)20 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)20 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)20 ClusterList (com.yahoo.vespaclient.ClusterList)20 AndItem (com.yahoo.prelude.query.AndItem)18 WordItem (com.yahoo.prelude.query.WordItem)17 ComponentId (com.yahoo.component.ComponentId)13 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)13 FastHit (com.yahoo.prelude.fastsearch.FastHit)13 FederationSearcher (com.yahoo.search.federation.FederationSearcher)13 ArrayList (java.util.ArrayList)12 CompositeItem (com.yahoo.prelude.query.CompositeItem)11