Search in sources :

Example 6 with Searcher

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);
}
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 7 with Searcher

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;
}
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 8 with Searcher

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);
}
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 9 with Searcher

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);
}
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 10 with Searcher

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));
}
Also used : FS4Hit(com.yahoo.searchlib.aggregation.FS4Hit) FS4Hit(com.yahoo.searchlib.aggregation.FS4Hit) GroupingListHit(com.yahoo.prelude.fastsearch.GroupingListHit) FastHit(com.yahoo.prelude.fastsearch.FastHit) Hit(com.yahoo.search.result.Hit) VdsHit(com.yahoo.searchlib.aggregation.VdsHit) FastHit(com.yahoo.prelude.fastsearch.FastHit) Query(com.yahoo.search.Query) Searcher(com.yahoo.search.Searcher) Test(org.junit.Test)

Aggregations

Searcher (com.yahoo.search.Searcher)130 Result (com.yahoo.search.Result)94 Execution (com.yahoo.search.searchchain.Execution)88 Query (com.yahoo.search.Query)82 Test (org.junit.Test)74 Chain (com.yahoo.component.chain.Chain)57 FeedContext (com.yahoo.feedapi.FeedContext)20 MessagePropertyProcessor (com.yahoo.feedapi.MessagePropertyProcessor)20 NullFeedMetric (com.yahoo.feedhandler.NullFeedMetric)20 ClusterList (com.yahoo.vespaclient.ClusterList)20 Hit (com.yahoo.search.result.Hit)17 DocumentSourceSearcher (com.yahoo.search.searchchain.testutil.DocumentSourceSearcher)14 HashMap (java.util.HashMap)14 GetDocumentReply (com.yahoo.documentapi.messagebus.protocol.GetDocumentReply)13 FederationSearcher (com.yahoo.search.federation.FederationSearcher)11 FieldCollapsingSearcher (com.yahoo.prelude.searcher.FieldCollapsingSearcher)10 ArrayList (java.util.ArrayList)10 AsyncExecution (com.yahoo.search.searchchain.AsyncExecution)9 ComponentId (com.yahoo.component.ComponentId)8 FastHit (com.yahoo.prelude.fastsearch.FastHit)8