Search in sources :

Example 16 with Chain

use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.

the class FederationTester method addSearchChain.

void addSearchChain(String id, FederationOptions federationOptions, Searcher... searchers) {
    ComponentId searchChainId = ComponentId.fromString(id);
    builder.addSearchChain(searchChainId, federationOptions, Collections.<String>emptyList());
    Chain<Searcher> chain = new Chain<>(searchChainId, searchers);
    registry.register(chain);
}
Also used : Chain(com.yahoo.component.chain.Chain) FederationSearcher(com.yahoo.search.federation.FederationSearcher) Searcher(com.yahoo.search.Searcher) ComponentId(com.yahoo.component.ComponentId)

Example 17 with Chain

use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.

the class VespaIntegrationTestCase method testIt.

// TODO: Setup the answering vespa searcher from this test....
public void testIt() {
    if (System.currentTimeMillis() > 0)
        return;
    Chain<Searcher> chain = new Chain<>(new VespaSearcher("test", "example.yahoo.com", 19010, ""));
    Result result = new Execution(chain, Execution.Context.createContextStub()).search(new Query("?query=test"));
    assertEquals(23, result.hits().size());
}
Also used : Chain(com.yahoo.component.chain.Chain) VespaSearcher(com.yahoo.search.federation.vespa.VespaSearcher) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) VespaSearcher(com.yahoo.search.federation.vespa.VespaSearcher) Searcher(com.yahoo.search.Searcher) Result(com.yahoo.search.Result)

Example 18 with Chain

use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.

the class GetSearcherTestCase method testQueryOverridesDefaults.

@Test
public void testQueryOverridesDefaults() throws Exception {
    DocumentSessionFactory factory = new DocumentSessionFactory(docType);
    GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
    Chain<Searcher> searchChain = new Chain<>(searcher);
    Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id[0]=userdoc:kittens:1:2&id[1]=userdoc:kittens:3:4&priority=LOW_2&route=highwaytohell&timeout=58"));
    assertEquals(2, factory.messages.size());
    long lastTimeout = 58000;
    {
        Message m = factory.messages.get(0);
        assertEquals(DocumentProtocol.MESSAGE_GETDOCUMENT, m.getType());
        GetDocumentMessage gdm = (GetDocumentMessage) m;
        DocumentId d = gdm.getDocumentId();
        assertEquals("userdoc:kittens:1:2", d.toString());
        assertEquals("[all]", gdm.getFieldSet());
        assertEquals(DocumentProtocol.Priority.LOW_2, gdm.getPriority());
        assertEquals(Route.parse("highwaytohell"), gdm.getRoute());
        assertTrue(lastTimeout >= gdm.getTimeRemaining());
        lastTimeout = gdm.getTimeRemaining();
    }
    {
        Message m = factory.messages.get(1);
        assertEquals(DocumentProtocol.MESSAGE_GETDOCUMENT, m.getType());
        GetDocumentMessage gdm = (GetDocumentMessage) m;
        DocumentId d = gdm.getDocumentId();
        assertEquals("userdoc:kittens:3:4", d.toString());
        assertEquals("[all]", gdm.getFieldSet());
        assertEquals(DocumentProtocol.Priority.LOW_2, gdm.getPriority());
        assertEquals(Route.parse("highwaytohell"), gdm.getRoute());
        assertTrue(lastTimeout >= gdm.getTimeRemaining());
    }
}
Also used : Chain(com.yahoo.component.chain.Chain) ClusterList(com.yahoo.vespaclient.ClusterList) Message(com.yahoo.messagebus.Message) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) Searcher(com.yahoo.search.Searcher) Result(com.yahoo.search.Result) Execution(com.yahoo.search.searchchain.Execution) FeedContext(com.yahoo.feedapi.FeedContext) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) MessagePropertyProcessor(com.yahoo.feedapi.MessagePropertyProcessor) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric) Test(org.junit.Test)

Example 19 with Chain

use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.

the class GetSearcherTestCase method testGetSingleDocumentQuery.

@Test
public void testGetSingleDocumentQuery() throws Exception {
    // Needs auto-reply
    DocumentSessionFactory factory = new DocumentSessionFactory(docType);
    GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
    Chain<Searcher> searchChain = new Chain<>(searcher);
    Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id=userdoc:kittens:1:2"));
    System.out.println("HTTP request is " + result.getQuery().getHttpRequest());
    assertEquals(1, factory.messages.size());
    {
        Message m = factory.messages.get(0);
        assertEquals(DocumentProtocol.MESSAGE_GETDOCUMENT, m.getType());
        GetDocumentMessage gdm = (GetDocumentMessage) m;
        DocumentId d = gdm.getDocumentId();
        assertEquals("userdoc:kittens:1:2", d.toString());
        assertEquals("[all]", gdm.getFieldSet());
    }
    assertEquals(1, result.hits().size());
    assertHits(result.hits(), "userdoc:kittens:1:2");
    // By default, document hit should not have its hit fields set
    DocumentHit hit = (DocumentHit) result.hits().get(0);
    assertEquals(0, hit.fieldKeys().size());
}
Also used : Chain(com.yahoo.component.chain.Chain) ClusterList(com.yahoo.vespaclient.ClusterList) Message(com.yahoo.messagebus.Message) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) Searcher(com.yahoo.search.Searcher) Result(com.yahoo.search.Result) Execution(com.yahoo.search.searchchain.Execution) FeedContext(com.yahoo.feedapi.FeedContext) GetDocumentMessage(com.yahoo.documentapi.messagebus.protocol.GetDocumentMessage) MessagePropertyProcessor(com.yahoo.feedapi.MessagePropertyProcessor) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric) Test(org.junit.Test)

Example 20 with Chain

use of com.yahoo.component.chain.Chain in project vespa by vespa-engine.

the class GetSearcherTestCase method testDocumentFieldWithDocumentNotFound.

@Test
public void testDocumentFieldWithDocumentNotFound() throws Exception {
    DocumentSessionFactory factory = new DocumentSessionFactory(docType, null, true);
    factory.setNullReply(true);
    GetSearcher searcher = new GetSearcher(new FeedContext(new MessagePropertyProcessor(defFeedCfg, defLoadTypeCfg), factory, docMan, new ClusterList(), new NullFeedMetric()));
    Chain<Searcher> searchChain = new Chain<>(searcher);
    Result result = new Execution(searchChain, Execution.Context.createContextStub()).search(newQuery("?id=userdoc:kittens:1:2&field=name"));
    assertNotNull(result.hits().getErrorHit());
    assertRendered("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<result>\n" + "<errors>\n" + "<error type=\"searcher\" code=\"16\" message=\"Resource not found.: " + "Document not found, could not return field 'name'\"/>\n" + "</errors>\n" + "</result>\n", result);
}
Also used : Chain(com.yahoo.component.chain.Chain) ClusterList(com.yahoo.vespaclient.ClusterList) Execution(com.yahoo.search.searchchain.Execution) FeedContext(com.yahoo.feedapi.FeedContext) Searcher(com.yahoo.search.Searcher) MessagePropertyProcessor(com.yahoo.feedapi.MessagePropertyProcessor) NullFeedMetric(com.yahoo.feedhandler.NullFeedMetric) Result(com.yahoo.search.Result) Test(org.junit.Test)

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